diff options
69 files changed, 224 insertions, 246 deletions
diff --git a/android_webview/lib/aw_browser_dependency_factory_impl.cc b/android_webview/lib/aw_browser_dependency_factory_impl.cc index 41cc792..c1dd345 100644 --- a/android_webview/lib/aw_browser_dependency_factory_impl.cc +++ b/android_webview/lib/aw_browser_dependency_factory_impl.cc @@ -9,7 +9,6 @@ #include "content/public/browser/content_browser_client.h" #include "content/public/browser/web_contents.h" #include "content/public/common/content_client.h" -#include "ipc/ipc_message.h" using content::BrowserContext; using content::WebContents; @@ -43,7 +42,7 @@ content::BrowserContext* AwBrowserDependencyFactoryImpl::GetBrowserContext( WebContents* AwBrowserDependencyFactoryImpl::CreateWebContents(bool incognito) { return content::WebContents::Create( - GetBrowserContext(incognito), 0, MSG_ROUTING_NONE, 0); + content::WebContents::CreateParams(GetBrowserContext(incognito))); } } // namespace android_webview diff --git a/chrome/browser/android/content_view_util.cc b/chrome/browser/android/content_view_util.cc index abcab24..2aaa466 100644 --- a/chrome/browser/android/content_view_util.cc +++ b/chrome/browser/android/content_view_util.cc @@ -9,7 +9,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "content/public/browser/web_contents.h" -#include "ipc/ipc_message.h" #include "jni/ContentViewUtil_jni.h" static jint CreateNativeWebContents( @@ -19,11 +18,10 @@ static jint CreateNativeWebContents( profile = profile->GetOffTheRecordProfile(); content::WebContents* web_contents = - content::WebContents::Create(profile, 0, MSG_ROUTING_NONE, 0); + content::WebContents::Create(content::WebContents::CreateParams(profile)); return reinterpret_cast<jint>(web_contents); } bool RegisterContentViewUtil(JNIEnv* env) { return RegisterNativesImpl(env); } - diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index a2e10eb..ca312d6 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -189,8 +189,8 @@ DevToolsWindow* DevToolsWindow::Create( DevToolsDockSide dock_side, bool shared_worker_frontend) { // Create TabContents with devtools. - TabContents* tab_contents = - chrome::TabContentsFactory(profile, NULL, MSG_ROUTING_NONE, NULL); + TabContents* tab_contents = chrome::TabContentsFactory( + content::WebContents::CreateParams(profile)); tab_contents->web_contents()->GetRenderViewHost()->AllowBindings( content::BINDINGS_POLICY_WEB_UI); tab_contents->web_contents()->GetController().LoadURL( diff --git a/chrome/browser/extensions/api/identity/web_auth_flow.cc b/chrome/browser/extensions/api/identity/web_auth_flow.cc index a702f6e..fa4f9b7 100644 --- a/chrome/browser/extensions/api/identity/web_auth_flow.cc +++ b/chrome/browser/extensions/api/identity/web_auth_flow.cc @@ -107,7 +107,7 @@ void WebAuthFlow::Start() { } WebContents* WebAuthFlow::CreateWebContents() { - return WebContents::Create(profile_, NULL, MSG_ROUTING_NONE, NULL); + return WebContents::Create(WebContents::CreateParams(profile_)); } void WebAuthFlow::ShowAuthFlowPopup() { diff --git a/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc b/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc index 0b0756f..d82db71 100644 --- a/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc +++ b/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc @@ -218,7 +218,7 @@ void OffscreenTab::Init(const GURL& url, ParentTab* parent_tab) { // Create the offscreen tab. web_contents_.reset( - WebContents::Create(profile, NULL, MSG_ROUTING_NONE, NULL)); + WebContents::Create(WebContents::CreateParams(profile))); extensions::TabHelper::CreateForWebContents(web_contents_.get()); // Setting the size starts the renderer. diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index ebc288d..3bae1ad 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -143,7 +143,7 @@ ExtensionHost::ExtensionHost(const Extension* extension, extension_host_type_(host_type), associated_web_contents_(NULL) { host_contents_.reset(WebContents::Create( - profile_, site_instance, MSG_ROUTING_NONE, NULL)); + WebContents::CreateParams(profile_, site_instance))), content::WebContentsObserver::Observe(host_contents_.get()); host_contents_->SetDelegate(this); chrome::SetViewType(host_contents_.get(), host_type); diff --git a/chrome/browser/extensions/startup_helper.cc b/chrome/browser/extensions/startup_helper.cc index 419316ad..0ae2dd6 100644 --- a/chrome/browser/extensions/startup_helper.cc +++ b/chrome/browser/extensions/startup_helper.cc @@ -127,8 +127,8 @@ bool StartupHelper::InstallFromWebstore(const CommandLine& cmd_line, // TODO(asargent) - it would be nice not to need a WebContents just to // use the standalone installer. (crbug.com/149039) - scoped_ptr<content::WebContents> web_contents( - content::WebContents::Create(profile, NULL, MSG_ROUTING_NONE, NULL)); + scoped_ptr<content::WebContents> web_contents(content::WebContents::Create( + content::WebContents::CreateParams(profile))); AppInstallHelper helper; WebstoreStandaloneInstaller::Callback callback = diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc index a0ec58c..d5c088c 100644 --- a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc @@ -222,8 +222,8 @@ void GeolocationPermissionContextTests::CheckPermissionMessageSentInternal( } void GeolocationPermissionContextTests::AddNewTab(const GURL& url) { - content::WebContents* new_tab = - content::WebContents::Create(profile(), NULL, MSG_ROUTING_NONE, NULL); + content::WebContents* new_tab = content::WebContents::Create( + content::WebContents::CreateParams(profile())); new_tab->GetController().LoadURL( url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); content::RenderViewHostTester::For(new_tab->GetRenderViewHost())-> diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc index ce135e6..53eefc8 100644 --- a/chrome/browser/instant/instant_loader.cc +++ b/chrome/browser/instant/instant_loader.cc @@ -187,8 +187,11 @@ InstantLoader::~InstantLoader() { } void InstantLoader::InitContents(const content::WebContents* active_tab) { + content::WebContents::CreateParams create_params( + active_tab->GetBrowserContext()); + create_params.base_web_contents = active_tab; contents_.reset(content::WebContents::CreateWithSessionStorage( - active_tab->GetBrowserContext(), NULL, MSG_ROUTING_NONE, active_tab, + create_params, active_tab->GetController().GetSessionStorageNamespaceMap())); // Not a leak. TabContents will delete itself when the WebContents is gone. TabContents::Factory::CreateTabContents(contents()); diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc index c0ac128..818262f 100644 --- a/chrome/browser/notifications/balloon_host.cc +++ b/chrome/browser/notifications/balloon_host.cc @@ -133,10 +133,7 @@ void BalloonHost::OnRequest(const ExtensionHostMsg_Request_Params& params) { void BalloonHost::Init() { DCHECK(!web_contents_.get()) << "BalloonViewHost already initialized."; web_contents_.reset(WebContents::Create( - balloon_->profile(), - site_instance_.get(), - MSG_ROUTING_NONE, - NULL)); + WebContents::CreateParams(balloon_->profile(), site_instance_.get()))); chrome::SetViewType(web_contents_.get(), chrome::VIEW_TYPE_NOTIFICATION); web_contents_->SetDelegate(this); Observe(web_contents_.get()); diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc index 7823fe8..e749a7b 100644 --- a/chrome/browser/prerender/prerender_contents.cc +++ b/chrome/browser/prerender/prerender_contents.cc @@ -487,7 +487,7 @@ WebContents* PrerenderContents::CreateWebContents( content::SessionStorageNamespaceMap session_storage_namespace_map; session_storage_namespace_map[""] = session_storage_namespace; return WebContents::CreateWithSessionStorage( - profile_, NULL, MSG_ROUTING_NONE, NULL, session_storage_namespace_map); + WebContents::CreateParams(profile_), session_storage_namespace_map); } void PrerenderContents::NotifyPrerenderStart() { diff --git a/chrome/browser/sessions/session_restore_android.cc b/chrome/browser/sessions/session_restore_android.cc index 7864667..4ad11bc 100644 --- a/chrome/browser/sessions/session_restore_android.cc +++ b/chrome/browser/sessions/session_restore_android.cc @@ -12,7 +12,6 @@ #include "chrome/browser/ui/android/tab_model/tab_model_list.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/web_contents.h" -#include "ipc/ipc_message.h" // The android implementation does not do anything "foreign session" specific. // We use it to restore tabs from "recently closed" too. @@ -30,7 +29,7 @@ void SessionRestore::RestoreForeignSessionTab( TabNavigation::CreateNavigationEntriesFromTabNavigations( session_tab.navigations, profile); content::WebContents* new_web_contents = content::WebContents::Create( - context, NULL, MSG_ROUTING_NONE, NULL); + content::WebContents::CreateParams(context)); int selected_index = session_tab.normalized_navigation_index(); new_web_contents->GetController().Restore( selected_index, diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc index 6510921..9c5b50a 100644 --- a/chrome/browser/sessions/session_restore_browsertest.cc +++ b/chrome/browser/sessions/session_restore_browsertest.cc @@ -889,7 +889,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, SessionStorageAfterTabReplace) { controller->GetDefaultSessionStorageNamespace(); scoped_ptr<content::WebContents> web_contents( content::WebContents::CreateWithSessionStorage( - browser()->profile(), NULL, MSG_ROUTING_NONE, NULL, + content::WebContents::CreateParams(browser()->profile()), session_storage_namespace_map)); TabStripModel* tab_strip_model = browser()->tab_strip_model(); diff --git a/chrome/browser/tab_contents/background_contents.cc b/chrome/browser/tab_contents/background_contents.cc index a223059..f98a812 100644 --- a/chrome/browser/tab_contents/background_contents.cc +++ b/chrome/browser/tab_contents/background_contents.cc @@ -29,8 +29,9 @@ BackgroundContents::BackgroundContents(SiteInstance* site_instance, site_instance->GetBrowserContext()); // TODO(rafaelw): Implement correct session storage. - web_contents_.reset(WebContents::Create( - profile_, site_instance, routing_id, NULL)); + WebContents::CreateParams create_params(profile_, site_instance); + create_params.routing_id = routing_id; + web_contents_.reset(WebContents::Create(create_params)); chrome::SetViewType( web_contents_.get(), chrome::VIEW_TYPE_BACKGROUND_CONTENTS); web_contents_->SetDelegate(this); diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc index 3818d11..8b2001a 100644 --- a/chrome/browser/ui/browser_browsertest.cc +++ b/chrome/browser/ui/browser_browsertest.cc @@ -874,7 +874,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, TabClosingWhenRemovingExtension) { ui_test_utils::NavigateToURL(browser(), url); WebContents* app_contents = WebContents::Create( - browser()->profile(), NULL, MSG_ROUTING_NONE, NULL); + WebContents::CreateParams(browser()->profile())); extensions::TabHelper::CreateForWebContents(app_contents); extensions::TabHelper* extensions_tab_helper = extensions::TabHelper::FromWebContents(app_contents); @@ -997,7 +997,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { const Extension* extension_app = GetExtension(); ui_test_utils::NavigateToURL(browser(), url); WebContents* app_contents = WebContents::Create( - browser()->profile(), NULL, MSG_ROUTING_NONE, NULL); + WebContents::CreateParams(browser()->profile())); extensions::TabHelper::CreateForWebContents(app_contents); extensions::TabHelper* extensions_tab_helper = extensions::TabHelper::FromWebContents(app_contents); diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc index e7d1a59..70b76ec 100644 --- a/chrome/browser/ui/browser_navigator.cc +++ b/chrome/browser/ui/browser_navigator.cc @@ -37,6 +37,10 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#if defined(USE_AURA) +#include "ui/aura/window.h" +#endif + using content::GlobalRequestID; using content::WebContents; @@ -474,11 +478,18 @@ void Navigate(NavigateParams* params) { } if (params->disposition != CURRENT_TAB) { - params->target_contents = WebContents::Create( + WebContents::CreateParams create_params( params->browser->profile(), - tab_util::GetSiteInstanceForNewTab(params->browser->profile(), url), - MSG_ROUTING_NONE, - params->source_contents); + tab_util::GetSiteInstanceForNewTab(params->browser->profile(), url)); + create_params.base_web_contents = params->source_contents; +#if defined(USE_AURA) + if (params->browser->window() && + params->browser->window()->GetNativeWindow()) { + create_params.context = + params->browser->window()->GetNativeWindow(); + } +#endif + params->target_contents = WebContents::Create(create_params); // New tabs can have WebUI URLs that will make calls back to arbitrary // tab helpers, so the entire set of tab helpers needs to be set up // immediately. diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc index 281d33b..d59acf0 100644 --- a/chrome/browser/ui/browser_navigator_browsertest.cc +++ b/chrome/browser/ui/browser_navigator_browsertest.cc @@ -91,11 +91,9 @@ Browser* BrowserNavigatorTest::CreateEmptyBrowserForApp(Browser::Type type, } WebContents* BrowserNavigatorTest::CreateWebContents() { - return WebContents::Create( - browser()->profile(), - NULL, - MSG_ROUTING_NONE, - chrome::GetActiveWebContents(browser())); + content::WebContents::CreateParams create_params(browser()->profile()); + create_params.base_web_contents = chrome::GetActiveWebContents(browser()); + return WebContents::Create(create_params); } void BrowserNavigatorTest::RunSuppressTest(WindowOpenDisposition disposition) { diff --git a/chrome/browser/ui/browser_tabrestore.cc b/chrome/browser/ui/browser_tabrestore.cc index ff04683..6ddc50a 100644 --- a/chrome/browser/ui/browser_tabrestore.cc +++ b/chrome/browser/ui/browser_tabrestore.cc @@ -17,7 +17,6 @@ #include "content/public/browser/session_storage_namespace.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" -#include "ipc/ipc_message.h" using content::WebContents; using content::NavigationController; @@ -52,11 +51,13 @@ WebContents* CreateRestoredTab( // into the map. content::SessionStorageNamespaceMap session_storage_namespace_map; session_storage_namespace_map[""] = session_storage_namespace; - WebContents* web_contents = content::WebContents::CreateWithSessionStorage( + WebContents::CreateParams create_params( browser->profile(), - tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url), - MSG_ROUTING_NONE, - browser->tab_strip_model()->GetActiveWebContents(), + tab_util::GetSiteInstanceForNewTab(browser->profile(), restore_url)); + create_params.base_web_contents = + browser->tab_strip_model()->GetActiveWebContents(); + WebContents* web_contents = content::WebContents::CreateWithSessionStorage( + create_params, session_storage_namespace_map); extensions::TabHelper::CreateForWebContents(web_contents); extensions::TabHelper::FromWebContents(web_contents)-> diff --git a/chrome/browser/ui/browser_tabstrip.cc b/chrome/browser/ui/browser_tabstrip.cc index 8582b93..70d37b5 100644 --- a/chrome/browser/ui/browser_tabstrip.cc +++ b/chrome/browser/ui/browser_tabstrip.cc @@ -129,15 +129,9 @@ void CloseWebContents(Browser* browser, content::WebContents* contents) { } TabContents* TabContentsFactory( - Profile* profile, - content::SiteInstance* site_instance, - int routing_id, - const content::WebContents* base_web_contents) { + const content::WebContents::CreateParams& create_params) { return BrowserTabstripTabContentsCreator::CreateTabContents( - content::WebContents::Create(profile, - site_instance, - routing_id, - base_web_contents)); + content::WebContents::Create(create_params)); } } // namespace chrome diff --git a/chrome/browser/ui/browser_tabstrip.h b/chrome/browser/ui/browser_tabstrip.h index 6ab6403..77edd40 100644 --- a/chrome/browser/ui/browser_tabstrip.h +++ b/chrome/browser/ui/browser_tabstrip.h @@ -7,6 +7,7 @@ #include "content/public/common/page_transition_types.h" #include "content/public/browser/navigation_controller.h" +#include "content/public/browser/web_contents.h" #include "webkit/glue/window_open_disposition.h" class Browser; @@ -16,7 +17,6 @@ class TabContents; namespace content { class SiteInstance; -class WebContents; } namespace gfx { @@ -56,10 +56,7 @@ void CloseWebContents(Browser* browser, content::WebContents* contents); // Centralized methods for creating a TabContents, configuring and // installing all its supporting objects and observers. TabContents* TabContentsFactory( - Profile* profile, - content::SiteInstance* site_instance, - int routing_id, - const content::WebContents* base_web_contents); + const content::WebContents::CreateParams& create_params); } // namespace chrome diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm index 03900981..1a11066 100644 --- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm +++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm @@ -16,7 +16,6 @@ #include "chrome/test/base/in_process_browser_test.h" #include "content/public/browser/web_contents.h" #include "googleurl/src/gurl.h" -#include "ipc/ipc_message.h" #include "testing/gmock/include/gmock/gmock.h" using ::testing::NiceMock; @@ -91,7 +90,7 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInInactiveTab) { // a tab works correctly. IN_PROC_BROWSER_TEST_F(ConstrainedWindowMacTest, ShowInUninitializedTab) { scoped_ptr<content::WebContents> web_contents(content::WebContents::Create( - browser()->profile(), NULL, MSG_ROUTING_NONE, NULL)); + content::WebContents::CreateParams(browser()->profile()))); bool was_blocked = false; chrome::AddWebContents(browser(), NULL, web_contents.release(), NEW_BACKGROUND_TAB, gfx::Rect(), false, &was_blocked); diff --git a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm index 157661f..520755e 100644 --- a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm @@ -15,7 +15,6 @@ #include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "content/public/test/test_utils.h" -#include "ipc/ipc_message.h" #include "testing/gtest_mac.h" #include "ui/base/accelerators/platform_accelerator_cocoa.h" @@ -67,7 +66,7 @@ class FullscreenExitBubbleControllerTest : public CocoaProfileTest { void AppendTabToStrip() { WebContents* web_contents = WebContents::Create( - profile(), site_instance_, MSG_ROUTING_NONE, NULL); + content::WebContents::CreateParams(profile(), site_instance_)); browser()->tab_strip_model()->AppendWebContents( web_contents, /*foreground=*/true); } diff --git a/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm b/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm index 9bd4306..dac2094 100644 --- a/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/infobars/infobar_controller_unittest.mm @@ -100,7 +100,7 @@ class LinkInfoBarControllerTest : public CocoaProfileTest, virtual void SetUp() { CocoaProfileTest::SetUp(); web_contents_.reset( - WebContents::Create(profile(), NULL, MSG_ROUTING_NONE, NULL)); + WebContents::Create(WebContents::CreateParams(profile()))); InfoBarTabHelper::CreateForWebContents(web_contents_.get()); InfoBarTabHelper* infobar_tab_helper = @@ -145,7 +145,7 @@ class ConfirmInfoBarControllerTest : public CocoaProfileTest, virtual void SetUp() { CocoaProfileTest::SetUp(); web_contents_.reset( - WebContents::Create(profile(), NULL, MSG_ROUTING_NONE, NULL)); + WebContents::Create(WebContents::CreateParams(profile()))); InfoBarTabHelper::CreateForWebContents(web_contents_.get()); InfoBarTabHelper* infobar_tab_helper = diff --git a/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm b/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm index a8e8257..8755e8c 100644 --- a/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm +++ b/chrome/browser/ui/cocoa/infobars/translate_infobar_unittest.mm @@ -65,7 +65,7 @@ class TranslationInfoBarTest : public CocoaProfileTest { virtual void SetUp() { CocoaProfileTest::SetUp(); web_contents_.reset( - WebContents::Create(profile(), NULL, MSG_ROUTING_NONE, NULL)); + WebContents::Create(WebContents::CreateParams(profile()))); InfoBarTabHelper::CreateForWebContents(web_contents_.get()); CreateInfoBar(); } diff --git a/chrome/browser/ui/cocoa/intents/web_intent_inline_service_view_controller_browsertest.mm b/chrome/browser/ui/cocoa/intents/web_intent_inline_service_view_controller_browsertest.mm index 1c3d4e7..faa0d56 100644 --- a/chrome/browser/ui/cocoa/intents/web_intent_inline_service_view_controller_browsertest.mm +++ b/chrome/browser/ui/cocoa/intents/web_intent_inline_service_view_controller_browsertest.mm @@ -12,7 +12,6 @@ #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/test/base/in_process_browser_test.h" #include "content/public/browser/web_contents.h" -#include "ipc/ipc_message.h" #import "testing/gtest_mac.h" namespace { @@ -91,11 +90,11 @@ IN_PROC_BROWSER_TEST_F(WebIntentInlineServiceViewControllerTest, WebView) { [view_controller_ setServiceName:kTitle]; GURL url("about:blank"); - content::WebContents* web_contents = content::WebContents::Create( + content::WebContents::CreateParams create_params( browser()->profile(), - tab_util::GetSiteInstanceForNewTab(browser()->profile(), url), - MSG_ROUTING_NONE, - NULL); + tab_util::GetSiteInstanceForNewTab(browser()->profile(), url)); + content::WebContents* web_contents = content::WebContents::Create( + create_params); // Create a web view EXPECT_CALL(delegate_, @@ -126,11 +125,11 @@ IN_PROC_BROWSER_TEST_F(WebIntentInlineServiceViewControllerTest, UnsetWebView) { ASSERT_FALSE([view_controller_ webContents]); GURL url("about:blank"); - content::WebContents* web_contents = content::WebContents::Create( + content::WebContents::CreateParams create_params( browser()->profile(), - tab_util::GetSiteInstanceForNewTab(browser()->profile(), url), - MSG_ROUTING_NONE, - NULL); + tab_util::GetSiteInstanceForNewTab(browser()->profile(), url)); + content::WebContents* web_contents = content::WebContents::Create( + create_params); EXPECT_CALL(delegate_, CreateWebContentsForInlineDisposition(testing::_, testing::_)) .WillOnce(testing::Return(web_contents)); diff --git a/chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller_browsertest.mm b/chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller_browsertest.mm index a7c15e4..995bc5e 100644 --- a/chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller_browsertest.mm +++ b/chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller_browsertest.mm @@ -153,11 +153,11 @@ IN_PROC_BROWSER_TEST_F(WebIntentPickerViewControllerTest, InlineService) { // Create a web view GURL url("about:blank"); - content::WebContents* web_contents = content::WebContents::Create( + content::WebContents::CreateParams create_params( browser()->profile(), - tab_util::GetSiteInstanceForNewTab(browser()->profile(), url), - MSG_ROUTING_NONE, - NULL); + tab_util::GetSiteInstanceForNewTab(browser()->profile(), url)); + content::WebContents* web_contents = content::WebContents::Create( + create_params); EXPECT_CALL(delegate_, CreateWebContentsForInlineDisposition(testing::_, testing::_)) .WillOnce(testing::Return(web_contents)); diff --git a/chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration_unittest.mm b/chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration_unittest.mm index 3135f23..f4a9ba7 100644 --- a/chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration_unittest.mm +++ b/chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration_unittest.mm @@ -10,7 +10,6 @@ #include "chrome/browser/ui/intents/web_intent_picker_controller.h" #include "content/public/browser/site_instance.h" #include "content/public/browser/web_intents_dispatcher.h" -#include "ipc/ipc_message.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/glue/web_intent_data.h" #include "webkit/glue/web_intent_reply_data.h" @@ -34,8 +33,9 @@ class WebIntentsButtonDecorationTest : public CocoaProfileTest { TEST_F(WebIntentsButtonDecorationTest, IdentifiesWebIntentService) { scoped_refptr<content::SiteInstance> instance = content::SiteInstance::Create(profile()); + content::WebContents::CreateParams create_params(profile(), instance.get()); scoped_ptr<content::WebContents> contents(content::WebContents::Create( - profile(), instance.get(), MSG_ROUTING_NONE, NULL)); + create_params)); WebIntentPickerController::CreateForWebContents(contents.get()); decoration_.Update(contents.get()); diff --git a/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller_browsertest.mm b/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller_browsertest.mm index 871194a..6efe2cf 100644 --- a/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller_browsertest.mm +++ b/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller_browsertest.mm @@ -12,7 +12,6 @@ #include "chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.h" #include "chrome/test/base/in_process_browser_test.h" #include "content/public/browser/web_contents.h" -#include "ipc/ipc_message.h" #import "testing/gtest_mac.h" class PreviewableContentsControllerTest : public InProcessBrowserTest { @@ -22,7 +21,7 @@ class PreviewableContentsControllerTest : public InProcessBrowserTest { virtual void SetUpOnMainThread() OVERRIDE { web_contents_.reset(content::WebContents::Create( - browser()->profile(), NULL, MSG_ROUTING_NONE, NULL)); + content::WebContents::CreateParams(browser()->profile()))); instant_model_.SetPreviewContents(web_contents_.get()); controller_.reset([[PreviewableContentsController alloc] diff --git a/chrome/browser/ui/cocoa/tabpose_window_unittest.mm b/chrome/browser/ui/cocoa/tabpose_window_unittest.mm index 3fea221..a1e51f1 100644 --- a/chrome/browser/ui/cocoa/tabpose_window_unittest.mm +++ b/chrome/browser/ui/cocoa/tabpose_window_unittest.mm @@ -11,7 +11,6 @@ #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" -#include "ipc/ipc_message.h" #include "testing/gtest/include/gtest/gtest.h" using content::SiteInstance; @@ -27,7 +26,7 @@ class TabposeWindowTest : public CocoaProfileTest { void AppendTabToStrip() { content::WebContents* web_contents = content::WebContents::Create( - profile(), site_instance_, MSG_ROUTING_NONE, NULL); + content::WebContents::CreateParams(profile(), site_instance_)); browser()->tab_strip_model()->AppendWebContents( web_contents, /*foreground=*/true); } diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm index ef22797..d92c432 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm @@ -14,7 +14,6 @@ #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" #include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" -#include "ipc/ipc_message.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" @@ -103,7 +102,7 @@ class TabStripControllerTest : public CocoaProfileTest { TabView* CreateTab() { SiteInstance* instance = SiteInstance::Create(profile()); WebContents* web_contents = WebContents::Create( - profile(), instance, MSG_ROUTING_NONE, NULL); + content::WebContents::CreateParams(profile(), instance)); model_->AppendWebContents(web_contents, true); const NSUInteger tab_count = [controller_.get() viewsCount]; return static_cast<TabView*>([controller_.get() viewAtIndex:tab_count - 1]); diff --git a/chrome/browser/ui/cocoa/web_dialog_window_controller.mm b/chrome/browser/ui/cocoa/web_dialog_window_controller.mm index 4372667..45f2c91 100644 --- a/chrome/browser/ui/cocoa/web_dialog_window_controller.mm +++ b/chrome/browser/ui/cocoa/web_dialog_window_controller.mm @@ -340,7 +340,7 @@ void WebDialogWindowDelegateBridge::HandleKeyboardEvent( - (void)loadDialogContents { webContents_.reset(WebContents::Create( - delegate_->browser_context(), NULL, MSG_ROUTING_NONE, NULL)); + WebContents::CreateParams(delegate_->browser_context()))); [[self window] setContentView:webContents_->GetNativeView()]; webContents_->SetDelegate(delegate_.get()); diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc index d076ca2..9ef76e5 100644 --- a/chrome/browser/ui/extensions/shell_window.cc +++ b/chrome/browser/ui/extensions/shell_window.cc @@ -113,9 +113,8 @@ void ShellWindow::Init(const GURL& url, const ShellWindow::CreateParams& params) { window_type_ = params.window_type; - web_contents_.reset(WebContents::Create( - profile(), SiteInstance::CreateForURL(profile(), url), MSG_ROUTING_NONE, - NULL)); + web_contents_.reset(WebContents::Create(WebContents::CreateParams( + profile(), SiteInstance::CreateForURL(profile(), url)))); ConstrainedWindowTabHelper::CreateForWebContents(web_contents_.get()); FaviconTabHelper::CreateForWebContents(web_contents_.get()); WebIntentPickerController::CreateForWebContents(web_contents_.get()); diff --git a/chrome/browser/ui/gtk/web_dialog_gtk.cc b/chrome/browser/ui/gtk/web_dialog_gtk.cc index 50b20cb..663a6e3 100644 --- a/chrome/browser/ui/gtk/web_dialog_gtk.cc +++ b/chrome/browser/ui/gtk/web_dialog_gtk.cc @@ -206,7 +206,7 @@ void WebDialogGtk::HandleKeyboardEvent(content::WebContents* source, gfx::NativeWindow WebDialogGtk::InitDialog() { web_contents_.reset(WebContents::Create( - browser_context(), NULL, MSG_ROUTING_NONE, NULL)); + WebContents::CreateParams(browser_context()))); web_contents_->SetDelegate(this); // This must be done before loading the page; see the comments in diff --git a/chrome/browser/ui/intents/web_intent_inline_disposition_delegate_unittest.cc b/chrome/browser/ui/intents/web_intent_inline_disposition_delegate_unittest.cc index 1911e76..1a03ab1 100644 --- a/chrome/browser/ui/intents/web_intent_inline_disposition_delegate_unittest.cc +++ b/chrome/browser/ui/intents/web_intent_inline_disposition_delegate_unittest.cc @@ -30,7 +30,7 @@ class WebIntentInlineDispositionBrowserTest BrowserWithTestWindowTest::SetUp(); web_contents_.reset(content::WebContents::Create( - browser()->profile(), NULL, MSG_ROUTING_NONE, NULL)); + content::WebContents::CreateParams(browser()->profile()))); delegate_.reset(new WebIntentInlineDispositionDelegate( &mock_, web_contents_.get(), browser())); } diff --git a/chrome/browser/ui/intents/web_intent_picker_controller.cc b/chrome/browser/ui/intents/web_intent_picker_controller.cc index a555ff1..8c7c253 100644 --- a/chrome/browser/ui/intents/web_intent_picker_controller.cc +++ b/chrome/browser/ui/intents/web_intent_picker_controller.cc @@ -44,7 +44,6 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_intents_dispatcher.h" -#include "ipc/ipc_message.h" #include "ui/gfx/favicon_size.h" #include "ui/gfx/image/image.h" @@ -331,9 +330,8 @@ void WebIntentPickerController::OnServiceChosen( case webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW: { content::WebContents* contents = content::WebContents::Create( - profile_, - tab_util::GetSiteInstanceForNewTab(profile_, url), - MSG_ROUTING_NONE, NULL); + content::WebContents::CreateParams( + profile_, tab_util::GetSiteInstanceForNewTab(profile_, url))); WebIntentPickerController::CreateForWebContents(contents); // Let the controller for the target WebContents know that it is hosting a @@ -374,10 +372,10 @@ void WebIntentPickerController::OnServiceChosen( content::WebContents* WebIntentPickerController::CreateWebContentsForInlineDisposition( Profile* profile, const GURL& url) { + content::WebContents::CreateParams create_params( + profile, tab_util::GetSiteInstanceForNewTab(profile, url)); content::WebContents* web_contents = content::WebContents::Create( - profile, - tab_util::GetSiteInstanceForNewTab(profile, url), - MSG_ROUTING_NONE, NULL); + create_params); intents_dispatcher_->DispatchIntent(web_contents); return web_contents; } diff --git a/chrome/browser/ui/panels/panel_host.cc b/chrome/browser/ui/panels/panel_host.cc index 429f3fe..fb13e4c5 100644 --- a/chrome/browser/ui/panels/panel_host.cc +++ b/chrome/browser/ui/panels/panel_host.cc @@ -49,9 +49,9 @@ void PanelHost::Init(const GURL& url) { if (url.is_empty()) return; - web_contents_.reset(content::WebContents::Create( - profile_, content::SiteInstance::CreateForURL(profile_, url), - MSG_ROUTING_NONE, NULL)); + content::WebContents::CreateParams create_params( + profile_, content::SiteInstance::CreateForURL(profile_, url)); + web_contents_.reset(content::WebContents::Create(create_params)); chrome::SetViewType(web_contents_.get(), chrome::VIEW_TYPE_PANEL); web_contents_->SetDelegate(this); content::WebContentsObserver::Observe(web_contents_.get()); diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc index cc7161e..2efffc5 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc @@ -95,12 +95,6 @@ #include "ui/gfx/rect.h" #include "ui/gfx/screen.h" -#if defined(USE_ASH) -#include "ash/launcher/launcher_types.h" -#include "ash/shell.h" -#include "ui/aura/window.h" -#endif - #if defined(OS_MACOSX) #include "base/mac/mac_util.h" #include "chrome/browser/ui/cocoa/keystone_infobar_delegate.h" @@ -806,20 +800,6 @@ Browser* StartupBrowserCreatorImpl::OpenTabsInBrowser(Browser* browser, #endif } -#if defined(OS_CHROMEOS) - if (ash::Shell::HasInstance()) { - // Set the browser's root window to be an active root window now so - // that that web contents can determine correct scale factor for the - // renderer. This is a short term fix for crbug.com/155201. Without - // this, the renderer may use wrong scale factor first, then - // switched to the correct scale factor, which can cause race - // condition and lead to the results rendered at wrong scale factor. - // Long term fix is tracked in crbug.com/155443. - ash::Shell::GetInstance()->set_active_root_window( - browser->window()->GetNativeWindow()->GetRootWindow()); - } -#endif - // In kiosk mode, we want to always be fullscreen, so switch to that now. if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) chrome::ToggleFullscreenMode(browser); @@ -1048,4 +1028,3 @@ bool StartupBrowserCreatorImpl::OpenStartupURLsInExistingBrowser( return false; } #endif - diff --git a/chrome/browser/ui/tabs/tab_strip_model.cc b/chrome/browser/ui/tabs/tab_strip_model.cc index 1c11ab6c..349f5ad 100644 --- a/chrome/browser/ui/tabs/tab_strip_model.cc +++ b/chrome/browser/ui/tabs/tab_strip_model.cc @@ -173,10 +173,7 @@ WebContents* TabStripModel::DiscardWebContentsAt(int index) { return NULL; WebContents* null_contents = - WebContents::Create(profile(), - NULL /* site_instance */, - MSG_ROUTING_NONE, - NULL /* base_web_contents */); + WebContents::Create(WebContents::CreateParams(profile())); WebContents* old_contents = GetWebContentsAtImpl(index); // Copy over the state from the navigation controller so we preserve the // back/forward history and continue to display the correct title/favicon. diff --git a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc index aa4828b..7b042f9 100644 --- a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc @@ -114,15 +114,13 @@ class TabStripModelTest : public ChromeRenderViewHostTestHarness { } WebContents* CreateWebContents() { - return WebContents::Create(profile(), NULL, MSG_ROUTING_NONE, NULL); + return WebContents::Create(WebContents::CreateParams(profile())); } WebContents* CreateWebContentsWithSharedRPH(WebContents* web_contents) { - WebContents* retval = WebContents::Create( - profile(), - web_contents->GetRenderViewHost()->GetSiteInstance(), - MSG_ROUTING_NONE, - NULL); + WebContents::CreateParams create_params( + profile(), web_contents->GetRenderViewHost()->GetSiteInstance()); + WebContents* retval = WebContents::Create(create_params); EXPECT_EQ(retval->GetRenderProcessHost(), web_contents->GetRenderProcessHost()); return retval; diff --git a/chrome/browser/ui/views/constrained_window_views_browsertest.cc b/chrome/browser/ui/views/constrained_window_views_browsertest.cc index 4b33fe5..110aa59 100644 --- a/chrome/browser/ui/views/constrained_window_views_browsertest.cc +++ b/chrome/browser/ui/views/constrained_window_views_browsertest.cc @@ -230,7 +230,7 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, TabSwitchTest) { // Open a new tab. The constrained window should hide itself. browser()->tab_strip_model()->AppendWebContents( content::WebContents::Create( - browser()->profile(), NULL, MSG_ROUTING_NONE, NULL), + content::WebContents::CreateParams(browser()->profile())), true); EXPECT_FALSE(window->IsVisible()); diff --git a/chrome/browser/ui/views/external_tab_container_win.cc b/chrome/browser/ui/views/external_tab_container_win.cc index 8533731..6cd4b69 100644 --- a/chrome/browser/ui/views/external_tab_container_win.cc +++ b/chrome/browser/ui/views/external_tab_container_win.cc @@ -195,8 +195,7 @@ bool ExternalTabContainerWin::Init(Profile* profile, if (existing_contents) { existing_contents->GetController().SetBrowserContext(profile); } else { - existing_contents = - WebContents::Create(profile, NULL, MSG_ROUTING_NONE, NULL); + existing_contents = WebContents::Create(WebContents::CreateParams(profile)); existing_contents->GetRenderViewHost()->AllowBindings( content::BINDINGS_POLICY_EXTERNAL_HOST); } diff --git a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc index ae5fd22..d574cba 100644 --- a/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc +++ b/chrome/browser/ui/webui/constrained_web_dialog_delegate_base.cc @@ -30,7 +30,7 @@ ConstrainedWebDialogDelegateBase::ConstrainedWebDialogDelegateBase( release_contents_on_close_(false) { CHECK(delegate); web_contents_.reset( - WebContents::Create(browser_context, NULL, MSG_ROUTING_NONE, NULL)); + WebContents::Create(WebContents::CreateParams(browser_context))); if (tab_delegate) { override_tab_delegate_.reset(tab_delegate); web_contents_->SetDelegate(tab_delegate); diff --git a/content/browser/site_instance_impl_unittest.cc b/content/browser/site_instance_impl_unittest.cc index 35b90bf..59ed0c2d 100644 --- a/content/browser/site_instance_impl_unittest.cc +++ b/content/browser/site_instance_impl_unittest.cc @@ -250,9 +250,9 @@ TEST_F(SiteInstanceTest, SiteInstanceDestructor) { &site_delete_counter, &browsing_delete_counter); { - scoped_ptr<WebContentsImpl> web_contents( - WebContentsImpl::Create(browser_context.get(), instance, - MSG_ROUTING_NONE, NULL)); + scoped_ptr<WebContentsImpl> web_contents(static_cast<WebContentsImpl*>( + WebContents::Create(WebContents::CreateParams( + browser_context.get(), instance)))); EXPECT_EQ(1, site_delete_counter); EXPECT_EQ(1, browsing_delete_counter); } diff --git a/content/browser/web_contents/navigation_controller_impl_unittest.cc b/content/browser/web_contents/navigation_controller_impl_unittest.cc index b77c650..6595d45 100644 --- a/content/browser/web_contents/navigation_controller_impl_unittest.cc +++ b/content/browser/web_contents/navigation_controller_impl_unittest.cc @@ -1926,9 +1926,8 @@ TEST_F(NavigationControllerTest, RestoreNavigate) { const base::Time timestamp = base::Time::Now(); entry->SetTimestamp(timestamp); entries.push_back(entry); - scoped_ptr<WebContentsImpl> our_contents( - WebContentsImpl::Create(browser_context(), NULL, MSG_ROUTING_NONE, - NULL)); + scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( + WebContents::Create(WebContents::CreateParams(browser_context())))); NavigationControllerImpl& our_controller = our_contents->GetController(); our_controller.Restore( 0, @@ -2004,9 +2003,8 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) { entry->SetTitle(ASCIIToUTF16("Title")); entry->SetContentState("state"); entries.push_back(entry); - scoped_ptr<WebContentsImpl> our_contents( - WebContentsImpl::Create(browser_context(), NULL, MSG_ROUTING_NONE, - NULL)); + scoped_ptr<WebContentsImpl> our_contents(static_cast<WebContentsImpl*>( + WebContents::Create(WebContents::CreateParams(browser_context())))); NavigationControllerImpl& our_controller = our_contents->GetController(); our_controller.Restore( 0, NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, &entries); diff --git a/content/browser/web_contents/test_web_contents.cc b/content/browser/web_contents/test_web_contents.cc index 41c727679..9ae1486 100644 --- a/content/browser/web_contents/test_web_contents.cc +++ b/content/browser/web_contents/test_web_contents.cc @@ -35,7 +35,7 @@ TestWebContents::TestWebContents(BrowserContext* browser_context) TestWebContents* TestWebContents::Create(BrowserContext* browser_context, SiteInstance* instance) { TestWebContents* test_web_contents = new TestWebContents(browser_context); - test_web_contents->Init(browser_context, instance, MSG_ROUTING_NONE, NULL); + test_web_contents->Init(WebContents::CreateParams(browser_context, instance)); return test_web_contents; } diff --git a/content/browser/web_contents/web_contents_delegate_unittest.cc b/content/browser/web_contents/web_contents_delegate_unittest.cc index 1ba4118..9c5e0e7 100644 --- a/content/browser/web_contents/web_contents_delegate_unittest.cc +++ b/content/browser/web_contents/web_contents_delegate_unittest.cc @@ -34,12 +34,10 @@ class WebContentsDelegateTest : public RenderViewHostImplTestHarness { }; TEST_F(WebContentsDelegateTest, UnregisterInDestructor) { - scoped_ptr<WebContentsImpl> contents_a( - WebContentsImpl::Create(browser_context_.get(), NULL, MSG_ROUTING_NONE, - NULL)); - scoped_ptr<WebContentsImpl> contents_b( - WebContentsImpl::Create(browser_context_.get(), NULL, MSG_ROUTING_NONE, - NULL)); + scoped_ptr<WebContentsImpl> contents_a(static_cast<WebContentsImpl*>( + WebContents::Create(WebContents::CreateParams(browser_context_.get())))); + scoped_ptr<WebContentsImpl> contents_b(static_cast<WebContentsImpl*>( + WebContents::Create(WebContents::CreateParams(browser_context_.get())))); EXPECT_EQ(NULL, contents_a->GetDelegate()); EXPECT_EQ(NULL, contents_b->GetDelegate()); diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 51e59bf..17fd787 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -91,6 +91,7 @@ #endif #if defined(USE_AURA) && defined(USE_X11) +#include "ui/aura/window.h" #include "ui/base/touch/touch_factory.h" #endif // defined (USE_AURA) && defined(USE_X11) @@ -263,23 +264,15 @@ int GetSwitchValueAsInt( } // namespace -WebContents* WebContents::Create( - BrowserContext* browser_context, - SiteInstance* site_instance, - int routing_id, - const WebContents* base_web_contents) { - return WebContentsImpl::Create( - browser_context, site_instance, routing_id, - static_cast<const WebContentsImpl*>(base_web_contents)); +WebContents* WebContents::Create(const WebContents::CreateParams& params) { + return WebContentsImpl::CreateWithOpener(params, NULL); } WebContents* WebContents::CreateWithSessionStorage( - BrowserContext* browser_context, - SiteInstance* site_instance, - int routing_id, - const WebContents* base_web_contents, + const WebContents::CreateParams& params, const SessionStorageNamespaceMap& session_storage_namespace_map) { - WebContentsImpl* new_contents = new WebContentsImpl(browser_context, NULL); + WebContentsImpl* new_contents = new WebContentsImpl( + params.browser_context, NULL); for (SessionStorageNamespaceMap::const_iterator it = session_storage_namespace_map.begin(); @@ -289,8 +282,7 @@ WebContents* WebContents::CreateWithSessionStorage( it->second); } - new_contents->Init(browser_context, site_instance, routing_id, - static_cast<const WebContentsImpl*>(base_web_contents)); + new_contents->Init(params); return new_contents; } @@ -385,25 +377,13 @@ WebContentsImpl::~WebContentsImpl() { SetDelegate(NULL); } -WebContentsImpl* WebContentsImpl::Create( - BrowserContext* browser_context, - SiteInstance* site_instance, - int routing_id, - const WebContentsImpl* base_web_contents) { - return CreateWithOpener(browser_context, site_instance, routing_id, - base_web_contents, NULL); -} - WebContentsImpl* WebContentsImpl::CreateWithOpener( - BrowserContext* browser_context, - SiteInstance* site_instance, - int routing_id, - const WebContentsImpl* base_web_contents, + const WebContents::CreateParams& params, WebContentsImpl* opener) { - WebContentsImpl* new_contents = new WebContentsImpl(browser_context, opener); + WebContentsImpl* new_contents = new WebContentsImpl( + params.browser_context, opener); - new_contents->Init(browser_context, site_instance, routing_id, - static_cast<const WebContentsImpl*>(base_web_contents)); + new_contents->Init(params); return new_contents; } @@ -423,7 +403,7 @@ WebContentsImpl* WebContentsImpl::CreateGuest( new_contents, params)); - new_contents->Init(browser_context, site_instance, MSG_ROUTING_NONE, NULL); + new_contents->Init(WebContents::CreateParams(browser_context, site_instance)); new_contents->browser_plugin_guest_->InstallHelper( new_contents->GetRenderViewHost()); @@ -1107,9 +1087,9 @@ WebContents* WebContentsImpl::Clone() { // We use our current SiteInstance since the cloned entry will use it anyway. // We pass |this| for the |base_web_contents| to size the view correctly, and // our own opener so that the cloned page can access it if it was before. - WebContentsImpl* tc = CreateWithOpener(GetBrowserContext(), - GetSiteInstance(), MSG_ROUTING_NONE, - this, opener_); + CreateParams create_params(GetBrowserContext(), GetSiteInstance()); + create_params.base_web_contents = this; + WebContentsImpl* tc = CreateWithOpener(create_params, opener_); tc->GetController().CopyStateFrom(controller_); FOR_EACH_OBSERVER(WebContentsObserver, observers_, @@ -1156,11 +1136,9 @@ void WebContentsImpl::Observe(int type, } } -void WebContentsImpl::Init(BrowserContext* browser_context, - SiteInstance* site_instance, - int routing_id, - const WebContents* base_web_contents) { - render_manager_.Init(browser_context, site_instance, routing_id); +void WebContentsImpl::Init(const WebContents::CreateParams& params) { + render_manager_.Init( + params.browser_context, params.site_instance, params.routing_id); view_.reset(GetContentClient()->browser()-> OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); @@ -1187,8 +1165,9 @@ void WebContentsImpl::Init(BrowserContext* browser_context, // We have the initial size of the view be based on the size of the view of // the passed in WebContents. - view_->CreateView(base_web_contents ? - base_web_contents->GetView()->GetContainerSize() : gfx::Size()); + gfx::Size initial_size = params.base_web_contents ? + params.base_web_contents->GetView()->GetContainerSize() : gfx::Size(); + view_->CreateView(initial_size, params.context); // Listen for whether our opener gets destroyed. if (opener_) { @@ -1354,7 +1333,10 @@ void WebContentsImpl::CreateNewWindow( new_contents->GetController().SetSessionStorageNamespace( partition_id, session_storage_namespace); - new_contents->Init(GetBrowserContext(), site_instance, route_id, this); + CreateParams create_params(GetBrowserContext(), site_instance); + create_params.routing_id = route_id; + create_params.base_web_contents = this; + new_contents->Init(create_params); new_contents->set_opener_web_ui_type(GetWebUITypeForCurrentState()); diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index cb4fdae..e990837 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -81,17 +81,8 @@ class CONTENT_EXPORT WebContentsImpl public: virtual ~WebContentsImpl(); - static WebContentsImpl* Create( - BrowserContext* browser_context, - SiteInstance* site_instance, - int routing_id, - const WebContentsImpl* base_web_contents); - static WebContentsImpl* CreateWithOpener( - BrowserContext* browser_context, - SiteInstance* site_instance, - int routing_id, - const WebContentsImpl* base_web_contents, + const WebContents::CreateParams& params, WebContentsImpl* opener); // Creates a WebContents to be used as a browser plugin guest. @@ -113,10 +104,7 @@ class CONTENT_EXPORT WebContentsImpl // Complex initialization here. Specifically needed to avoid having // members call back into our virtual functions in the constructor. - virtual void Init(BrowserContext* browser_context, - SiteInstance* site_instance, - int routing_id, - const WebContents* base_web_contents); + virtual void Init(const WebContents::CreateParams& params); // Returns the SavePackage which manages the page saving job. May be NULL. SavePackage* save_package() const { return save_package_.get(); } diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc index a042541..87c2458 100644 --- a/content/browser/web_contents/web_contents_view_android.cc +++ b/content/browser/web_contents/web_contents_view_android.cc @@ -54,7 +54,8 @@ void WebContentsViewAndroid::SetContentViewCore( } } -void WebContentsViewAndroid::CreateView(const gfx::Size& initial_size) { +void WebContentsViewAndroid::CreateView( + const gfx::Size& initial_size, gfx::NativeView context) { } RenderWidgetHostView* WebContentsViewAndroid::CreateViewForWidget( diff --git a/content/browser/web_contents/web_contents_view_android.h b/content/browser/web_contents/web_contents_view_android.h index 6236fe8..50c479e 100644 --- a/content/browser/web_contents/web_contents_view_android.h +++ b/content/browser/web_contents/web_contents_view_android.h @@ -30,7 +30,8 @@ class WebContentsViewAndroid : public WebContentsView, // WebContentsView implementation -------------------------------------------- - virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; + virtual void CreateView( + const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; virtual RenderWidgetHostView* CreateViewForWidget( RenderWidgetHost* render_widget_host) OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE; diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index dde8d86..fb5c928 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -512,7 +512,8 @@ gfx::Vector2d WebContentsViewAura::GetTranslationForOverscroll(int delta_x, //////////////////////////////////////////////////////////////////////////////// // WebContentsViewAura, WebContentsView implementation: -void WebContentsViewAura::CreateView(const gfx::Size& initial_size) { +void WebContentsViewAura::CreateView( + const gfx::Size& initial_size, gfx::NativeView context) { // NOTE: we ignore |initial_size| since in some cases it's wrong (such as // if the bookmark bar is not shown and you create a new tab). The right // value is set shortly after this, so its safe to ignore. @@ -522,8 +523,10 @@ void WebContentsViewAura::CreateView(const gfx::Size& initial_size) { window_->SetType(aura::client::WINDOW_TYPE_CONTROL); window_->SetTransparent(false); window_->Init(ui::LAYER_NOT_DRAWN); - // TODO(erg): Do something else here later. - window_->SetDefaultParentByRootWindow(NULL, gfx::Rect()); + // TODO(mukai, erg): Should use a non-NULL value later when the DCHECK is + // turned on in SetDefaultParentByRootWindow(). + aura::RootWindow* target_root = context ? context->GetRootWindow() : NULL; + window_->SetDefaultParentByRootWindow(target_root, gfx::Rect()); window_->layer()->SetMasksToBounds(true); window_->SetName("WebContentsViewAura"); diff --git a/content/browser/web_contents/web_contents_view_aura.h b/content/browser/web_contents/web_contents_view_aura.h index ef53fea..c674384 100644 --- a/content/browser/web_contents/web_contents_view_aura.h +++ b/content/browser/web_contents/web_contents_view_aura.h @@ -78,7 +78,8 @@ class CONTENT_EXPORT WebContentsViewAura gfx::Vector2d GetTranslationForOverscroll(int delta_x, int delta_y); // Overridden from WebContentsView: - virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; + virtual void CreateView( + const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; virtual RenderWidgetHostView* CreateViewForWidget( RenderWidgetHost* render_widget_host) OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE; diff --git a/content/browser/web_contents/web_contents_view_gtk.cc b/content/browser/web_contents/web_contents_view_gtk.cc index 59aa26a..c5c2dde 100644 --- a/content/browser/web_contents/web_contents_view_gtk.cc +++ b/content/browser/web_contents/web_contents_view_gtk.cc @@ -108,7 +108,8 @@ WebContentsViewGtk::~WebContentsViewGtk() { expanded_.Destroy(); } -void WebContentsViewGtk::CreateView(const gfx::Size& initial_size) { +void WebContentsViewGtk::CreateView( + const gfx::Size& initial_size, gfx::NativeView context) { requested_size_ = initial_size; } diff --git a/content/browser/web_contents/web_contents_view_gtk.h b/content/browser/web_contents/web_contents_view_gtk.h index 3e52372..e797c9bb 100644 --- a/content/browser/web_contents/web_contents_view_gtk.h +++ b/content/browser/web_contents/web_contents_view_gtk.h @@ -45,7 +45,8 @@ class CONTENT_EXPORT WebContentsViewGtk // WebContentsView implementation -------------------------------------------- - virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; + virtual void CreateView( + const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; virtual RenderWidgetHostView* CreateViewForWidget( RenderWidgetHost* render_widget_host) OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE; diff --git a/content/browser/web_contents/web_contents_view_guest.cc b/content/browser/web_contents/web_contents_view_guest.cc index a732014..31a6e81 100644 --- a/content/browser/web_contents/web_contents_view_guest.cc +++ b/content/browser/web_contents/web_contents_view_guest.cc @@ -32,7 +32,8 @@ WebContentsViewGuest::WebContentsViewGuest( WebContentsViewGuest::~WebContentsViewGuest() { } -void WebContentsViewGuest::CreateView(const gfx::Size& initial_size) { +void WebContentsViewGuest::CreateView(const gfx::Size& initial_size, + gfx::NativeView context) { requested_size_ = initial_size; } diff --git a/content/browser/web_contents/web_contents_view_guest.h b/content/browser/web_contents/web_contents_view_guest.h index efc1dff..aebcdf6 100644 --- a/content/browser/web_contents/web_contents_view_guest.h +++ b/content/browser/web_contents/web_contents_view_guest.h @@ -36,7 +36,8 @@ class CONTENT_EXPORT WebContentsViewGuest // WebContentsView implementation -------------------------------------------- - virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; + virtual void CreateView(const gfx::Size& initial_size, + gfx::NativeView context) OVERRIDE; virtual RenderWidgetHostView* CreateViewForWidget( RenderWidgetHost* render_widget_host) OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE; diff --git a/content/browser/web_contents/web_contents_view_mac.h b/content/browser/web_contents/web_contents_view_mac.h index 3403b287..cc3837e 100644 --- a/content/browser/web_contents/web_contents_view_mac.h +++ b/content/browser/web_contents/web_contents_view_mac.h @@ -64,7 +64,8 @@ class WebContentsViewMac : public WebContentsView, // WebContentsView implementation -------------------------------------------- - virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; + virtual void CreateView( + const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; virtual RenderWidgetHostView* CreateViewForWidget( RenderWidgetHost* render_widget_host) OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE; diff --git a/content/browser/web_contents/web_contents_view_mac.mm b/content/browser/web_contents/web_contents_view_mac.mm index a050f17..bbf983c 100644 --- a/content/browser/web_contents/web_contents_view_mac.mm +++ b/content/browser/web_contents/web_contents_view_mac.mm @@ -92,7 +92,8 @@ WebContentsViewMac::~WebContentsViewMac() { [cocoa_view_ clearWebContentsView]; } -void WebContentsViewMac::CreateView(const gfx::Size& initial_size) { +void WebContentsViewMac::CreateView( + const gfx::Size& initial_size, gfx::NativeView context) { WebContentsViewCocoa* view = [[WebContentsViewCocoa alloc] initWithWebContentsViewMac:this]; cocoa_view_.reset(view); diff --git a/content/browser/web_contents/web_contents_view_win.cc b/content/browser/web_contents/web_contents_view_win.cc index 0609285..437a8b8 100644 --- a/content/browser/web_contents/web_contents_view_win.cc +++ b/content/browser/web_contents/web_contents_view_win.cc @@ -101,7 +101,8 @@ WebContentsViewWin::~WebContentsViewWin() { DestroyWindow(hwnd()); } -void WebContentsViewWin::CreateView(const gfx::Size& initial_size) { +void WebContentsViewWin::CreateView( + const gfx::Size& initial_size, gfx::NativeView context) { initial_size_ = initial_size; set_window_style(WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); diff --git a/content/browser/web_contents/web_contents_view_win.h b/content/browser/web_contents/web_contents_view_win.h index 8da8882..056b28d 100644 --- a/content/browser/web_contents/web_contents_view_win.h +++ b/content/browser/web_contents/web_contents_view_win.h @@ -53,7 +53,8 @@ class CONTENT_EXPORT WebContentsViewWin END_MSG_MAP() // Overridden from WebContentsView: - virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; + virtual void CreateView( + const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE; virtual RenderWidgetHostView* CreateViewForWidget( RenderWidgetHost* render_widget_host) OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE; diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 344fe37..ce16dcd 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -163,6 +163,7 @@ 'public/browser/trace_subscriber.h', 'public/browser/user_metrics.h', 'public/browser/utility_process_host.h', + 'public/browser/web_contents.cc', 'public/browser/web_contents.h', 'public/browser/web_contents_delegate.cc', 'public/browser/web_contents_delegate.h', diff --git a/content/public/browser/web_contents.cc b/content/public/browser/web_contents.cc new file mode 100644 index 0000000..c6daee1 --- /dev/null +++ b/content/public/browser/web_contents.cc @@ -0,0 +1,26 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/public/browser/web_contents.h" + +#include "ipc/ipc_message.h" + +namespace content { + +WebContents::CreateParams::CreateParams(BrowserContext* context) + : browser_context(context), + site_instance(NULL), + routing_id(MSG_ROUTING_NONE), + base_web_contents(NULL), + context(NULL) {} + +WebContents::CreateParams::CreateParams( + BrowserContext* context, SiteInstance* site) + : browser_context(context), + site_instance(site), + routing_id(MSG_ROUTING_NONE), + base_web_contents(NULL), + context(NULL) {} + +} // namespace content diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h index ebb06df..ceda85d 100644 --- a/content/public/browser/web_contents.h +++ b/content/public/browser/web_contents.h @@ -50,14 +50,25 @@ class WebContents : public PageNavigator, public IPC::Sender, public base::SupportsUserData { public: - // |base_web_contents| is used if we want to size the new WebContents's view - // based on the view of an existing WebContents. This can be NULL if not - // needed. - CONTENT_EXPORT static WebContents* Create( - BrowserContext* browser_context, - SiteInstance* site_instance, - int routing_id, - const WebContents* base_web_contents); + struct CONTENT_EXPORT CreateParams { + explicit CreateParams(BrowserContext* context); + CreateParams(BrowserContext* context, SiteInstance* site); + + BrowserContext* browser_context; + SiteInstance* site_instance; + int routing_id; + + // Used if we want to size the new WebContents's view based on the view of + // an existing WebContents. This can be NULL if not needed. + const WebContents* base_web_contents; + + // Used to specify the location context which display the new view should + // belong. This can be NULL if not needed. + gfx::NativeView context; + }; + + // Creates a new WebContents. + CONTENT_EXPORT static WebContents* Create(const CreateParams& params); // Similar to Create() above but should be used when you need to prepopulate // the SessionStorageNamespaceMap of the WebContents. This can happen if @@ -70,10 +81,7 @@ class WebContents : public PageNavigator, // they should not be shared by multiple WebContents, and what bad things // can happen if you share the object. CONTENT_EXPORT static WebContents* CreateWithSessionStorage( - BrowserContext* browser_context, - SiteInstance* site_instance, - int routing_id, - const WebContents* base_web_contents, + const CreateParams& params, const SessionStorageNamespaceMap& session_storage_namespace_map); // Returns a WebContents that wraps the RenderViewHost, or NULL if the diff --git a/content/public/browser/web_contents_view.h b/content/public/browser/web_contents_view.h index 89ecdf9..781f9e8 100644 --- a/content/public/browser/web_contents_view.h +++ b/content/public/browser/web_contents_view.h @@ -29,7 +29,8 @@ class CONTENT_EXPORT WebContentsView { public: virtual ~WebContentsView() {} - virtual void CreateView(const gfx::Size& initial_size) = 0; + virtual void CreateView( + const gfx::Size& initial_size, gfx::NativeView context) = 0; // Sets up the View that holds the rendered web page, receives messages for // it and contains page plugins. The host view should be sized to the current diff --git a/content/public/test/web_contents_tester.cc b/content/public/test/web_contents_tester.cc index eed75ec..d6e2fdf 100644 --- a/content/public/test/web_contents_tester.cc +++ b/content/public/test/web_contents_tester.cc @@ -67,7 +67,7 @@ WebContents* WebContentsTester::CreateTestWebContentsCountSetFocusToLocationBar( SiteInstance* instance) { TestWebContentsCountSetFocusToLocationBar* web_contents = new TestWebContentsCountSetFocusToLocationBar(browser_context); - web_contents->Init(browser_context, instance, MSG_ROUTING_NONE, NULL); + web_contents->Init(WebContents::CreateParams(browser_context, instance)); return web_contents; } @@ -77,7 +77,7 @@ WebContents* WebContentsTester::CreateTestWebContentsCountFocus( SiteInstance* instance) { TestWebContentsCountFocus* web_contents = new TestWebContentsCountFocus(browser_context); - web_contents->Init(browser_context, instance, MSG_ROUTING_NONE, NULL); + web_contents->Init(WebContents::CreateParams(browser_context, instance)); return web_contents; } diff --git a/content/shell/shell.cc b/content/shell/shell.cc index 69bf163..fd27d15 100644 --- a/content/shell/shell.cc +++ b/content/shell/shell.cc @@ -114,11 +114,10 @@ Shell* Shell::CreateNewWindow(BrowserContext* browser_context, SiteInstance* site_instance, int routing_id, WebContents* base_web_contents) { - WebContents* web_contents = WebContents::Create( - browser_context, - site_instance, - routing_id, - base_web_contents); + WebContents::CreateParams create_params(browser_context, site_instance); + create_params.routing_id = routing_id; + create_params.base_web_contents = base_web_contents; + WebContents* web_contents = WebContents::Create(create_params); Shell* shell = CreateShell(web_contents); if (!url.is_empty()) shell->LoadURL(url); diff --git a/content/test/test_web_contents_view.cc b/content/test/test_web_contents_view.cc index 0e9febc..9066714 100644 --- a/content/test/test_web_contents_view.cc +++ b/content/test/test_web_contents_view.cc @@ -42,7 +42,8 @@ void TestWebContentsView::GotFocus() { void TestWebContentsView::TakeFocus(bool reverse) { } -void TestWebContentsView::CreateView(const gfx::Size& initial_size) { +void TestWebContentsView::CreateView(const gfx::Size& initial_size, + gfx::NativeView context) { } RenderWidgetHostView* TestWebContentsView::CreateViewForWidget( diff --git a/content/test/test_web_contents_view.h b/content/test/test_web_contents_view.h index d9e0f8e..5a39f2a 100644 --- a/content/test/test_web_contents_view.h +++ b/content/test/test_web_contents_view.h @@ -37,7 +37,8 @@ class TestWebContentsView : public WebContentsView, virtual void TakeFocus(bool reverse) OVERRIDE; // WebContentsView: - virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; + virtual void CreateView(const gfx::Size& initial_size, + gfx::NativeView context) OVERRIDE; virtual RenderWidgetHostView* CreateViewForWidget( RenderWidgetHost* render_widget_host) OVERRIDE; virtual gfx::NativeView GetNativeView() const OVERRIDE; diff --git a/ui/views/controls/webview/webview.cc b/ui/views/controls/webview/webview.cc index cf1d73e..0edd781 100644 --- a/ui/views/controls/webview/webview.cc +++ b/ui/views/controls/webview/webview.cc @@ -251,10 +251,9 @@ content::WebContents* WebView::CreateWebContents( } if (!contents) { - return content::WebContents::Create(browser_context, - site_instance, - MSG_ROUTING_NONE, - NULL); + content::WebContents::CreateParams create_params( + browser_context, site_instance); + return content::WebContents::Create(create_params); } return contents; |