summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/web_navigation
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-09 15:45:14 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-09 15:45:14 +0000
commit3619ca8852a449d41118c6e984811ae7b75a7aa1 (patch)
treea48250f9644dc888f4deacfced9cbf7125881191 /chrome/browser/extensions/api/web_navigation
parent723431f4b19b84ca13e54edbcfa3d49aa53c1f02 (diff)
downloadchromium_src-3619ca8852a449d41118c6e984811ae7b75a7aa1.zip
chromium_src-3619ca8852a449d41118c6e984811ae7b75a7aa1.tar.gz
chromium_src-3619ca8852a449d41118c6e984811ae7b75a7aa1.tar.bz2
Convert remaining WebContentsObservers loading callbacks to use RFH.
Fix several WebContentsObserver implementations that are incorrectly caching only frame routing IDs in order to act only on that frame in later callbacks. Frame routing IDs by themselves are not suitable for identity comparisons, since they are only unique within a given RenderProcessHost. Also clean up WebContentsObservers with a redundant WebContents field. By definition, a WebContentsObserver must know which WebContents it's observing, so there's no need for derived classes to maintain their own WebContents field. BUG=none Review URL: https://codereview.chromium.org/373623002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282043 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/web_navigation')
-rw-r--r--chrome/browser/extensions/api/web_navigation/web_navigation_api.cc60
-rw-r--r--chrome/browser/extensions/api/web_navigation/web_navigation_api.h21
2 files changed, 39 insertions, 42 deletions
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
index 0ac6ef8..35d271b 100644
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
@@ -495,21 +495,23 @@ void WebNavigationTabObserver::DidFailProvisionalLoad(
}
void WebNavigationTabObserver::DocumentLoadedInFrame(
- int64 frame_num,
- content::RenderViewHost* render_view_host) {
+ content::RenderFrameHost* render_frame_host) {
+ content::RenderViewHost* render_view_host =
+ render_frame_host->GetRenderViewHost();
DVLOG(2) << "DocumentLoadedInFrame("
<< "render_view_host=" << render_view_host
- << ", frame_num=" << frame_num << ")";
+ << ", frame_num=" << render_frame_host->GetRoutingID() << ")";
if (render_view_host != render_view_host_)
return;
- FrameNavigationState::FrameID frame_id(frame_num, render_view_host);
+ FrameNavigationState::FrameID frame_id(render_frame_host->GetRoutingID(),
+ render_view_host);
if (!navigation_state_.CanSendEvents(frame_id))
return;
navigation_state_.SetParsingFinished(frame_id);
helpers::DispatchOnDOMContentLoaded(web_contents(),
navigation_state_.GetUrl(frame_id),
navigation_state_.IsMainFrame(frame_id),
- frame_num);
+ frame_id.frame_num);
if (!navigation_state_.GetNavigationCompleted(frame_id))
return;
@@ -520,21 +522,22 @@ void WebNavigationTabObserver::DocumentLoadedInFrame(
helpers::DispatchOnCompleted(web_contents(),
navigation_state_.GetUrl(frame_id),
navigation_state_.IsMainFrame(frame_id),
- frame_num);
+ frame_id.frame_num);
}
void WebNavigationTabObserver::DidFinishLoad(
- int64 frame_num,
- const GURL& validated_url,
- bool is_main_frame,
- content::RenderViewHost* render_view_host) {
+ content::RenderFrameHost* render_frame_host,
+ const GURL& validated_url) {
+ content::RenderViewHost* render_view_host =
+ render_frame_host->GetRenderViewHost();
DVLOG(2) << "DidFinishLoad("
<< "render_view_host=" << render_view_host
- << ", frame_num=" << frame_num
+ << ", frame_num=" << render_frame_host->GetRoutingID()
<< ", url=" << validated_url << ")";
if (render_view_host != render_view_host_)
return;
- FrameNavigationState::FrameID frame_id(frame_num, render_view_host);
+ FrameNavigationState::FrameID frame_id(render_frame_host->GetRoutingID(),
+ render_view_host);
// When showing replacement content, we might get load signals for frames
// that weren't reguarly loaded.
if (!navigation_state_.IsValidFrame(frame_id))
@@ -548,7 +551,8 @@ void WebNavigationTabObserver::DidFinishLoad(
validated_url == GURL(url::kAboutBlankURL)))
<< "validated URL is " << validated_url << " but we expected "
<< navigation_state_.GetUrl(frame_id);
- DCHECK_EQ(navigation_state_.IsMainFrame(frame_id), is_main_frame);
+ DCHECK_EQ(navigation_state_.IsMainFrame(frame_id),
+ !render_frame_host->GetParent());
// The load might already have finished by the time we finished parsing. For
// compatibility reasons, we artifically delay the load completed signal until
@@ -557,36 +561,36 @@ void WebNavigationTabObserver::DidFinishLoad(
return;
helpers::DispatchOnCompleted(web_contents(),
navigation_state_.GetUrl(frame_id),
- is_main_frame,
- frame_num);
+ !render_frame_host->GetParent(),
+ frame_id.frame_num);
}
void WebNavigationTabObserver::DidFailLoad(
- int64 frame_num,
+ content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
- bool is_main_frame,
int error_code,
- const base::string16& error_description,
- content::RenderViewHost* render_view_host) {
+ const base::string16& error_description) {
+ content::RenderViewHost* render_view_host =
+ render_frame_host->GetRenderViewHost();
DVLOG(2) << "DidFailLoad("
<< "render_view_host=" << render_view_host
- << ", frame_num=" << frame_num
+ << ", frame_num=" << render_frame_host->GetRoutingID()
<< ", url=" << validated_url << ")";
if (render_view_host != render_view_host_)
return;
- FrameNavigationState::FrameID frame_id(frame_num, render_view_host);
+ FrameNavigationState::FrameID frame_id(render_frame_host->GetRoutingID(),
+ render_view_host);
// When showing replacement content, we might get load signals for frames
// that weren't reguarly loaded.
if (!navigation_state_.IsValidFrame(frame_id))
return;
if (navigation_state_.CanSendEvents(frame_id)) {
- helpers::DispatchOnErrorOccurred(
- web_contents(),
- render_view_host->GetProcess()->GetID(),
- navigation_state_.GetUrl(frame_id),
- frame_num,
- is_main_frame,
- error_code);
+ helpers::DispatchOnErrorOccurred(web_contents(),
+ render_view_host->GetProcess()->GetID(),
+ navigation_state_.GetUrl(frame_id),
+ frame_id.frame_num,
+ !render_frame_host->GetParent(),
+ error_code);
}
navigation_state_.SetErrorOccurredInFrame(frame_id);
}
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api.h b/chrome/browser/extensions/api/web_navigation/web_navigation_api.h
index 3b81bca..35a2956 100644
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_api.h
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api.h
@@ -71,20 +71,13 @@ class WebNavigationTabObserver
int error_code,
const base::string16& error_description) OVERRIDE;
virtual void DocumentLoadedInFrame(
- int64 frame_num,
- content::RenderViewHost* render_view_host) OVERRIDE;
- virtual void DidFinishLoad(
- int64 frame_num,
- const GURL& validated_url,
- bool is_main_frame,
- content::RenderViewHost* render_view_host) OVERRIDE;
- virtual void DidFailLoad(
- int64 frame_num,
- const GURL& validated_url,
- bool is_main_frame,
- int error_code,
- const base::string16& error_description,
- content::RenderViewHost* render_view_host) OVERRIDE;
+ content::RenderFrameHost* render_frame_host) OVERRIDE;
+ virtual void DidFinishLoad(content::RenderFrameHost* render_frame_host,
+ const GURL& validated_url) OVERRIDE;
+ virtual void DidFailLoad(content::RenderFrameHost* render_frame_host,
+ const GURL& validated_url,
+ int error_code,
+ const base::string16& error_description) OVERRIDE;
virtual void DidGetRedirectForResourceRequest(
content::RenderViewHost* render_view_host,
const content::ResourceRedirectDetails& details) OVERRIDE;