- HandleAddressChange and HandleTitleChange will always be called for the main frame and only the main frame (issue #200).

- The |frame| parameter to HandleLoadStart and HandleLoadEnd will always be non-empty. The CefFrame::IsMain() method can be used to check if the notification is for the main frame. The |isMainContent| parameter has been removed.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@202 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2011-03-08 19:33:18 +00:00
parent 11b831119a
commit 327ad9d9de
16 changed files with 85 additions and 185 deletions

View File

@ -674,27 +674,26 @@ public:
CefRefPtr<CefRequest> request,
NavType navType, bool isRedirect) =0;
// Called on the UI thread when the browser begins loading a page. The |frame|
// pointer will be empty if the event represents the overall load status and
// not the load status for a particular frame. |isMainContent| will be true if
// this load is for the main content area and not an iframe. This method may
// not be called if the load request fails. The return value is currently
// ignored.
// Called on the UI thread when the browser begins loading a frame. The
// |frame| value will never be empty -- call the IsMain() method to check if
// this frame is the main frame. Multiple frames may be loading at the same
// time. Sub-frames may start or continue loading after the main frame load
// has ended. This method may not be called for a particular frame if the load
// request for that frame fails. The return value is currently ignored.
/*--cef()--*/
virtual RetVal HandleLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isMainContent) =0;
CefRefPtr<CefFrame> frame) =0;
// Called on the UI thread when the browser is done loading a page. The
// |frame| pointer will be empty if the event represents the overall load
// status and not the load status for a particular frame. |isMainContent| will
// be true if this load is for the main content area and not an iframe. This
// method will be called irrespective of whether the request completes
// successfully. The return value is currently ignored.
// Called on the UI thread when the browser is done loading a frame. The
// |frame| value will never be empty -- call the IsMain() method to check if
// this frame is the main frame. Multiple frames may be loading at the same
// time. Sub-frames may start or continue loading after the main frame load
// has ended. This method will always be called for all frames irrespective of
// whether the request completes successfully. The return value is currently
// ignored.
/*--cef()--*/
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isMainContent,
int httpStatusCode) =0;
// Supported error code values. See net\base\net_error_list.h for complete

View File

@ -481,25 +481,26 @@ typedef struct _cef_handler_t
struct _cef_frame_t* frame, struct _cef_request_t* request,
enum cef_handler_navtype_t navType, int isRedirect);
// Called on the UI thread when the browser begins loading a page. The |frame|
// pointer will be NULL if the event represents the overall load status and
// not the load status for a particular frame. |isMainContent| will be true
// (1) if this load is for the main content area and not an iframe. This
// function may not be called if the load request fails. The return value is
// currently ignored.
// Called on the UI thread when the browser begins loading a frame. The
// |frame| value will never be NULL -- call the is_main() function to check if
// this frame is the main frame. Multiple frames may be loading at the same
// time. Sub-frames may start or continue loading after the main frame load
// has ended. This function may not be called for a particular frame if the
// load request for that frame fails. The return value is currently ignored.
enum cef_retval_t (CEF_CALLBACK *handle_load_start)(
struct _cef_handler_t* self, struct _cef_browser_t* browser,
struct _cef_frame_t* frame, int isMainContent);
struct _cef_frame_t* frame);
// Called on the UI thread when the browser is done loading a page. The
// |frame| pointer will be NULL if the event represents the overall load
// status and not the load status for a particular frame. |isMainContent| will
// be true (1) if this load is for the main content area and not an iframe.
// This function will be called irrespective of whether the request completes
// successfully. The return value is currently ignored.
// Called on the UI thread when the browser is done loading a frame. The
// |frame| value will never be NULL -- call the is_main() function to check if
// this frame is the main frame. Multiple frames may be loading at the same
// time. Sub-frames may start or continue loading after the main frame load
// has ended. This function will always be called for all frames irrespective
// of whether the request completes successfully. The return value is
// currently ignored.
enum cef_retval_t (CEF_CALLBACK *handle_load_end)(struct _cef_handler_t* self,
struct _cef_browser_t* browser, struct _cef_frame_t* frame,
int isMainContent, int httpStatusCode);
int httpStatusCode);
// Called on the UI thread when the browser fails to load a resource.
// |errorCode| is the error code number and |failedUrl| is the URL that failed

View File

@ -100,38 +100,6 @@ v8::Handle<v8::Context> GetV8Context(WebKit::WebFrame* frame)
return WebCore::V8Proxy::context(core_frame);
}
FrameLoadType GetFrameLoadType(WebKit::WebFrame* frame)
{
WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(frame);
WebCore::FrameLoader* loader = webFrameImpl->frame()->loader();
switch(loader->loadType()) {
case WebCore::FrameLoadTypeStandard:
return FLT_STANDARD;
case WebCore::FrameLoadTypeForward:
case WebCore::FrameLoadTypeBack:
case WebCore::FrameLoadTypeBackWMLDeckNotAccessible:
case WebCore::FrameLoadTypeIndexedBackForward:
return FLT_HISTORY;
case WebCore::FrameLoadTypeRedirectWithLockedBackForwardList:
return FLT_REDIRECT;
case WebCore::FrameLoadTypeReload:
case WebCore::FrameLoadTypeReloadFromOrigin:
case WebCore::FrameLoadTypeSame:
case WebCore::FrameLoadTypeReplace:
return FLT_RELOAD;
}
return FLT_UNKNOWN;
}
bool FrameHasSubsituteData(WebKit::WebFrame* frame)
{
WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(frame);
WebCore::DocumentLoader* docLoader =
webFrameImpl->frame()->loader()->documentLoader();
return docLoader->substituteData().isValid();
}
void CloseIdleConnections() {
// Used in benchmarking, Ignored for CEF.
}

View File

@ -39,20 +39,6 @@ base::StringPiece NetResourceProvider(int key);
// Retrieve the V8 context associated with the frame.
v8::Handle<v8::Context> GetV8Context(WebKit::WebFrame* frame);
enum FrameLoadType {
FLT_UNKNOWN = 0,
FLT_STANDARD,
FLT_HISTORY,
FLT_REDIRECT,
FLT_RELOAD,
};
// Returns the frame load type.
FrameLoadType GetFrameLoadType(WebKit::WebFrame* frame);
// Returns true if the frame is loading substitute data.
bool FrameHasSubsituteData(WebKit::WebFrame* frame);
// Clear all cached data.
void ClearCache();

View File

@ -660,10 +660,6 @@ void BrowserWebViewDelegate::didCreateDataSource(
}
void BrowserWebViewDelegate::didStartProvisionalLoad(WebFrame* frame) {
if (!top_loading_frame_) {
top_loading_frame_ = frame;
is_main_content_ = true;
}
}
void BrowserWebViewDelegate::didReceiveServerRedirectForProvisionalLoad(
@ -723,29 +719,10 @@ void BrowserWebViewDelegate::didFailProvisionalLoad(
void BrowserWebViewDelegate::didCommitProvisionalLoad(
WebFrame* frame, bool is_new_navigation) {
// Determine if this commit represents the main content.
if (frame == top_loading_frame_) {
is_main_content_ = false;
if (is_new_navigation) {
// New navigations will be the main content.
is_main_content_ = true;
} else if(webkit_glue::FrameHasSubsituteData(frame)) {
// Loading from a string will be main content.
is_main_content_ = true;
} else {
// Session history navigations and reloads will be the main content.
webkit_glue::FrameLoadType load_type =
webkit_glue::GetFrameLoadType(frame);
if (load_type == webkit_glue::FLT_HISTORY ||
load_type == webkit_glue::FLT_RELOAD) {
is_main_content_ = true;
}
}
if (is_main_content_) {
// Clear the title so we can tell if it wasn't provided by the page.
browser_->UIT_SetTitle(std::wstring());
}
bool is_main_frame = (frame->parent() == 0);
if (is_main_frame) {
// Clear the title so we can tell if it wasn't provided by the page.
browser_->UIT_SetTitle(std::wstring());
}
UpdateForCommittedLoad(frame, is_new_navigation);
@ -753,13 +730,11 @@ void BrowserWebViewDelegate::didCommitProvisionalLoad(
CefRefPtr<CefHandler> handler = browser_->GetHandler();
if(handler.get()) {
// Notify the handler that loading has started.
handler->HandleLoadStart(browser_,
(frame == top_loading_frame_) ? NULL : browser_->UIT_GetCefFrame(frame),
is_main_content_);
handler->HandleLoadStart(browser_, browser_->UIT_GetCefFrame(frame));
}
// Apply zoom settings only on top-level frames.
if(frame->parent() == NULL) {
if(is_main_frame) {
// Restore the zoom value that we have for this URL, if any.
double zoomLevel = 0.0;
ZoomMap::GetInstance()->get(frame->url(), zoomLevel);
@ -786,8 +761,8 @@ void BrowserWebViewDelegate::didClearWindowObject(WebFrame* frame) {
void BrowserWebViewDelegate::didReceiveTitle(
WebFrame* frame, const WebString& title) {
if (top_loading_frame_ == NULL ||
(frame == top_loading_frame_ && is_main_content_)) {
bool is_main_frame = (frame->parent() == 0);
if (is_main_frame) {
CefString titleStr = string16(title);
browser_->UIT_SetTitle(titleStr);
CefRefPtr<CefHandler> handler = browser_->GetHandler();
@ -857,8 +832,6 @@ BrowserWebViewDelegate::BrowserWebViewDelegate(CefBrowserImpl* browser)
policy_delegate_is_permissive_(false),
policy_delegate_should_notify_done_(false),
browser_(browser),
top_loading_frame_(NULL),
is_main_content_(false),
page_id_(-1),
last_page_id_updated_(-1),
smart_insert_delete_enabled_(true),
@ -935,32 +908,23 @@ void BrowserWebViewDelegate::ShowStatus(const WebString& text,
void BrowserWebViewDelegate::LocationChangeDone(WebFrame* frame) {
CefRefPtr<CefHandler> handler = browser_->GetHandler();
bool is_top_frame = false;
if (!handler.get())
return;
if (frame == top_loading_frame_) {
top_loading_frame_ = NULL;
is_top_frame = true;
if(is_main_content_ && handler.get()) {
CefString title = browser_->UIT_GetTitle();
if (title.empty()) {
// No title was provided by the page, so send a blank string to the
// client.
handler->HandleTitleChange(browser_, title);
}
bool is_main_frame = (frame->parent() == 0);
if (is_main_frame) {
CefString title = browser_->UIT_GetTitle();
if (title.empty()) {
// No title was provided by the page, so send a blank string to the
// client.
handler->HandleTitleChange(browser_, title);
}
}
if(handler.get()) {
// Notify the handler that loading has ended.
int httpStatusCode = frame->dataSource()->response().httpStatusCode();
handler->HandleLoadEnd(browser_,
(is_top_frame) ? NULL : browser_->UIT_GetCefFrame(frame),
is_main_content_, httpStatusCode);
}
if (is_top_frame && is_main_content_)
is_main_content_ = false;
// Notify the handler that loading has ended.
int httpStatusCode = frame->dataSource()->response().httpStatusCode();
handler->HandleLoadEnd(browser_, browser_->UIT_GetCefFrame(frame),
httpStatusCode);
}
WebWidgetHost* BrowserWebViewDelegate::GetWidgetHost() {
@ -1020,7 +984,8 @@ void BrowserWebViewDelegate::UpdateURL(WebFrame* frame) {
entry->SetURL(request.url());
}
if (is_main_content_) {
bool is_main_frame = (frame->parent() == 0);
if (is_main_frame) {
CefRefPtr<CefHandler> handler = browser_->GetHandler();
if(handler.get()) {
// Notify the handler of an address change

View File

@ -209,7 +209,6 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
void SetSelectTrailingWhitespaceEnabled(bool enabled);
// Additional accessors
WebKit::WebFrame* top_loading_frame() { return top_loading_frame_; }
#if defined(OS_WIN)
BrowserDragDelegate* drag_delegate() { return drag_delegate_.get(); }
WebDropTarget* drop_target() { return drop_target_.get(); }
@ -302,11 +301,6 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient,
// Non-owning pointer. The delegate is owned by the host.
CefBrowserImpl* browser_;
// This is non-NULL if a load is in progress.
WebKit::WebFrame* top_loading_frame_;
// This is true if the in-progress load is the main content.
bool is_main_content_;
// For tracking session history. See RenderView.
int page_id_;
int last_page_id_updated_;

View File

@ -135,8 +135,7 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_browse(
}
enum cef_retval_t CEF_CALLBACK handler_handle_load_start(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
int isMainContent)
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame)
{
DCHECK(self);
DCHECK(browser);
@ -148,12 +147,12 @@ enum cef_retval_t CEF_CALLBACK handler_handle_load_start(
framePtr = CefFrameCToCpp::Wrap(frame);
return CefHandlerCppToC::Get(self)->HandleLoadStart(
CefBrowserCToCpp::Wrap(browser), framePtr, isMainContent?true:false);
CefBrowserCToCpp::Wrap(browser), framePtr);
}
enum cef_retval_t CEF_CALLBACK handler_handle_load_end(
struct _cef_handler_t* self, cef_browser_t* browser, cef_frame_t* frame,
int isMainContent, int httpStatusCode)
int httpStatusCode)
{
DCHECK(self);
DCHECK(browser);
@ -165,8 +164,7 @@ enum cef_retval_t CEF_CALLBACK handler_handle_load_end(
framePtr = CefFrameCToCpp::Wrap(frame);
return CefHandlerCppToC::Get(self)->HandleLoadEnd(
CefBrowserCToCpp::Wrap(browser), framePtr,
isMainContent?true:false, httpStatusCode);
CefBrowserCToCpp::Wrap(browser), framePtr, httpStatusCode);
}
enum cef_retval_t CEF_CALLBACK handler_handle_load_error(

View File

@ -98,8 +98,7 @@ CefHandler::RetVal CefHandlerCToCpp::HandleBeforeBrowse(
}
CefHandler::RetVal CefHandlerCToCpp::HandleLoadStart(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
bool isMainContent)
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame)
{
if(CEF_MEMBER_MISSING(struct_, handle_load_start))
return RV_CONTINUE;
@ -109,12 +108,12 @@ CefHandler::RetVal CefHandlerCToCpp::HandleLoadStart(
frameStruct = CefFrameCppToC::Wrap(frame);
return struct_->handle_load_start(struct_, CefBrowserCppToC::Wrap(browser),
frameStruct, isMainContent);
frameStruct);
}
CefHandler::RetVal CefHandlerCToCpp::HandleLoadEnd(
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
bool isMainContent, int httpStatusCode)
int httpStatusCode)
{
if(CEF_MEMBER_MISSING(struct_, handle_load_end))
return RV_CONTINUE;
@ -124,7 +123,7 @@ CefHandler::RetVal CefHandlerCToCpp::HandleLoadEnd(
frameStruct = CefFrameCppToC::Wrap(frame);
return struct_->handle_load_end(struct_, CefBrowserCppToC::Wrap(browser),
frameStruct, isMainContent, httpStatusCode);
frameStruct, httpStatusCode);
}
CefHandler::RetVal CefHandlerCToCpp::HandleLoadError(

View File

@ -44,9 +44,9 @@ public:
CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request,
NavType navType, bool isRedirect);
virtual RetVal HandleLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, bool isMainContent);
CefRefPtr<CefFrame> frame);
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, bool isMainContent, int httpStatusCode);
CefRefPtr<CefFrame> frame, int httpStatusCode);
virtual RetVal HandleLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, ErrorCode errorCode,
const CefString& failedUrl, CefString& errorText);

View File

@ -63,11 +63,11 @@ CefHandler::RetVal ClientHandler::HandleAfterCreated(
}
CefHandler::RetVal ClientHandler::HandleLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, bool isMainContent)
CefRefPtr<CefFrame> frame)
{
REQUIRE_UI_THREAD();
if(!browser->IsPopup() && !frame.get())
if(!browser->IsPopup() && frame->IsMain())
{
Lock();
// We've just started loading a page
@ -80,11 +80,11 @@ CefHandler::RetVal ClientHandler::HandleLoadStart(CefRefPtr<CefBrowser> browser,
}
CefHandler::RetVal ClientHandler::HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, bool isMainContent, int httpStatusCode)
CefRefPtr<CefFrame> frame, int httpStatusCode)
{
REQUIRE_UI_THREAD();
if(!browser->IsPopup() && !frame.get())
if(!browser->IsPopup() && frame->IsMain())
{
Lock();
// We've just finished loading a page
@ -92,7 +92,6 @@ CefHandler::RetVal ClientHandler::HandleLoadEnd(CefRefPtr<CefBrowser> browser,
m_bCanGoBack = browser->CanGoBack();
m_bCanGoForward = browser->CanGoForward();
CefRefPtr<CefFrame> frame = browser->GetMainFrame();
CefRefPtr<CefDOMVisitor> visitor = GetDOMVisitor(frame->GetURL());
if(visitor.get())
frame->VisitDOM(visitor);

View File

@ -80,25 +80,24 @@ public:
return RV_CONTINUE;
}
// Called on the UI thread when the browser begins loading a page. The |frame|
// pointer will be empty if the event represents the overall load status and
// not the load status for a particular frame. |isMainContent| will be true if
// this load is for the main content area and not an iframe. This method may
// not be called if the load request fails. The return value is currently
// ignored.
// Called on the UI thread when the browser begins loading a frame. The
// |frame| value will never be empty -- call the IsMain() method to check if
// this frame is the main frame. Multiple frames may be loading at the same
// time. Sub-frames may start or continue loading after the main frame load
// has ended. This method may not be called for a particular frame if the load
// request for that frame fails. The return value is currently ignored.
virtual RetVal HandleLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isMainContent);
CefRefPtr<CefFrame> frame);
// Called on the UI thread when the browser is done loading a page. The
// |frame| pointer will be empty if the event represents the overall load
// status and not the load status for a particular frame. |isMainContent| will
// be true if this load is for the main content area and not an iframe. This
// method will be called irrespective of whether the request completes
// successfully. The return value is currently ignored.
// Called on the UI thread when the browser is done loading a frame. The
// |frame| value will never be empty -- call the IsMain() method to check if
// this frame is the main frame. Multiple frames may be loading at the same
// time. Sub-frames may start or continue loading after the main frame load
// has ended. This method will always be called for all frames irrespective of
// whether the request completes successfully. The return value is currently
// ignored.
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isMainContent,
int httpStatusCode);
// Called on the UI thread when the browser fails to load a resource.

View File

@ -228,10 +228,9 @@ public:
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isMainContent,
int httpStatusCode)
{
if(!frame.get()) {
if(frame->IsMain()) {
// The page is done loading so visit the DOM.
browser->GetMainFrame()->VisitDOM(visitor_.get());
}

View File

@ -273,10 +273,9 @@ public:
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isMainContent,
int httpStatusCode)
{
if(!browser->IsPopup() && !frame.get())
if(!browser->IsPopup() && frame->IsMain())
DestroyTest();
return RV_CONTINUE;
}
@ -386,10 +385,9 @@ public:
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isMainContent,
int httpStatusCode)
{
if(!browser->IsPopup() && !frame.get())
if(!browser->IsPopup() && frame->IsMain())
{
CefString url = browser->GetMainFrame()->GetURL();
if(url == "http://tests/run.html")

View File

@ -80,15 +80,13 @@ public:
}
virtual RetVal HandleLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isMainContent)
CefRefPtr<CefFrame> frame)
{
return RV_CONTINUE;
}
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isMainContent,
int httpStatusCode)
{
return RV_CONTINUE;

View File

@ -251,10 +251,9 @@ public:
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isMainContent,
int httpStatusCode)
{
if(!browser->IsPopup() && !frame.get())
if(!browser->IsPopup() && frame->IsMain())
DestroyTest();
return RV_CONTINUE;
}
@ -487,7 +486,6 @@ public:
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isMainContent,
int httpStatusCode)
{
return RV_CONTINUE;

View File

@ -59,7 +59,6 @@ public:
virtual RetVal HandleLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
bool isMainContent,
int httpStatusCode)
{
StartTest();