From e1081d9264ad9e19fe32071b6b99e3dde2d7f122 Mon Sep 17 00:00:00 2001 From: "twiz@google.com" Date: Fri, 10 Sep 2010 20:29:11 +0000 Subject: Partial clone of the following CL: http://codereview.chromium.org/3013045/show Differences from the above CL include the following: - RendererPreferences settings for ExtensionHosts are now extracted from the associated_tab_contents(). This ensures that extension hosts will also forward top level navigation requests. - Instead of explicitly setting the delegate on the TabContents in ExtensionHost::ShowCreatedWindow, instead I instruct the associated tab-contents to add the newly build tab-contents. Note that this is the exact same behaviour performed by TabContents when initiating a top-level navigation to the host browser. Points of interest: - See the TODO in navigation_controller.cc. This problem of an unrecognized navigation entry needs further investigation. - Also, I found that if the ActiveX control is navigated to a chrome-extension URL, then the top-level-navigation will fail because of the format of the URL. The fix was to construct a temporary url in place of the chrome-extension url. BUG=51091 TEST=None Review URL: http://codereview.chromium.org/3357013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59142 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/extensions/extension_host.cc | 34 +++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'chrome/browser/extensions/extension_host.cc') diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 13619ff..334c28e 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -457,6 +457,13 @@ void ExtensionHost::Close(RenderViewHost* render_view_host) { RendererPreferences ExtensionHost::GetRendererPrefs(Profile* profile) const { RendererPreferences preferences; + + TabContents* associated_contents = associated_tab_contents(); + if (associated_contents) + preferences = + static_cast(associated_contents)-> + GetRendererPrefs(profile); + renderer_preferences_util::UpdateFromSystemSettings(&preferences, profile); return preferences; } @@ -501,7 +508,7 @@ void ExtensionHost::CreateNewWindow( const string16& frame_name) { // TODO(aa): Use the browser's profile if the extension is split mode // incognito. - delegate_view_helper_.CreateNewWindow( + TabContents* new_contents = delegate_view_helper_.CreateNewWindow( route_id, render_view_host()->process()->profile(), site_instance(), @@ -510,6 +517,10 @@ void ExtensionHost::CreateNewWindow( this, window_container_type, frame_name); + + TabContents* associated_contents = associated_tab_contents(); + if (associated_contents && associated_contents->delegate()) + associated_contents->delegate()->TabContentsCreated(new_contents); } void ExtensionHost::CreateNewWidget(int route_id, @@ -542,11 +553,26 @@ void ExtensionHost::ShowCreatedWindow(int route_id, Browser::TYPE_NORMAL, false); // Match incognito exactly. if (!browser) { - browser = Browser::Create(contents->profile()); - browser->window()->Show(); + // If no browser is associated with the created TabContents, then the + // created TabContents may be an intermediate structure used during topmost + // url navigation from within an experimental extension popup view. + // + // If the ExtensionHost has an associated TabContents, then register the + // new contents with this contents. This will allow top-level link + // navigation within the new contents to function just as navigation + // within the current host. + TabContents* associated_contents = associated_tab_contents(); + if (associated_contents) { + associated_contents->AddNewContents(contents, disposition, initial_pos, + user_gesture); + } else { + browser = Browser::Create(contents->profile()); + browser->window()->Show(); + } } - browser->AddTabContents(contents, disposition, initial_pos, user_gesture); + if (browser) + browser->AddTabContents(contents, disposition, initial_pos, user_gesture); } void ExtensionHost::ShowCreatedWidget(int route_id, -- cgit v1.1