diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-16 21:15:46 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-16 21:15:46 +0000 |
commit | 7b35be2ef7cdf7f52805f70464a269d8ac995385 (patch) | |
tree | 5c41c66579f72c6ec79dd78e3ab2ce1a31f8239f /chrome | |
parent | 3727e08519cb1d6329378d94307eec23ae506471 (diff) | |
download | chromium_src-7b35be2ef7cdf7f52805f70464a269d8ac995385.zip chromium_src-7b35be2ef7cdf7f52805f70464a269d8ac995385.tar.gz chromium_src-7b35be2ef7cdf7f52805f70464a269d8ac995385.tar.bz2 |
Revert 110327 - Add ChromeBrowserParts for non main parts.
This reverts the code back to a single instance of BrowserMainParts, with auxillary parts (Gtk, Views, Aura, Touch) implemented from a new base class, ChromeBrowserParts, which has a Chrome specific interface, allowing initialization to be better subdivided.
This should fix the notifications auto tests.
BUG=103821
TEST=Make sure all tests and autotests run
Review URL: http://codereview.chromium.org/8539038
TBR=stevenjb@google.com
Review URL: http://codereview.chromium.org/8488015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110350 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
24 files changed, 292 insertions, 308 deletions
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index aebeca3..85bd493 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -32,7 +32,6 @@ #include "chrome/browser/background/background_mode_manager.h" #include "chrome/browser/browser_process_impl.h" #include "chrome/browser/browser_shutdown.h" -#include "chrome/browser/chrome_browser_main_extra_parts.h" #include "chrome/browser/defaults.h" #include "chrome/browser/extensions/default_apps_trial.h" #include "chrome/browser/extensions/extension_protocols.h" @@ -559,6 +558,13 @@ void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line, } } +#else + +void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line, + Profile* profile) { + // Dummy empty function for non-ChromeOS builds to avoid extra ifdefs below. +} + #endif // defined(OS_CHROMEOS) #if defined(OS_MACOSX) @@ -1160,38 +1166,23 @@ DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() { } #endif -// content::BrowserMainParts implementation ------------------------------------ - void ChromeBrowserMainParts::PreEarlyInitialization() { - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) - chrome_extra_parts_[i]->PreEarlyInitialization(); } void ChromeBrowserMainParts::PostEarlyInitialization() { - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) - chrome_extra_parts_[i]->PostEarlyInitialization(); } void ChromeBrowserMainParts::ToolkitInitialized() { - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) - chrome_extra_parts_[i]->ToolkitInitialized(); } void ChromeBrowserMainParts::PreMainMessageLoopStart() { - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) - chrome_extra_parts_[i]->PreMainMessageLoopStart(); } void ChromeBrowserMainParts::PostMainMessageLoopStart() { - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) - chrome_extra_parts_[i]->PostMainMessageLoopStart(); } void ChromeBrowserMainParts::PreMainMessageLoopRun() { result_code_ = PreMainMessageLoopRunImpl(); - - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) - chrome_extra_parts_[i]->PreMainMessageLoopRun(); } int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { @@ -1514,10 +1505,6 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { SetBrowserX11ErrorHandlers(); #endif - // Desktop construction occurs here, (required before profile creation). - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) - chrome_extra_parts_[i]->PostBrowserProcessInit(); - // Profile creation ---------------------------------------------------------- #if defined(OS_CHROMEOS) @@ -1583,11 +1570,6 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { g_browser_process->browser_policy_connector()->SetUserPolicyTokenService( profile_->GetTokenService()); } - - // Tests should be able to tune login manager before showing it. - // Thus only show login manager in normal (non-testing) mode. - if (!parameters().ui_task) - OptionallyRunChromeOSLoginManager(parsed_command_line(), profile_); #endif #if !defined(OS_MACOSX) @@ -1636,11 +1618,6 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { } #endif - // TODO(stevenjb): Move ChromeOS login code into PostProfileInitialized(). - // (Requires making ChromeBrowserMainPartsChromeos a non "main" Parts). - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) - chrome_extra_parts_[i]->PostProfileInitialized(); - // Show the First Run UI if this is the first time Chrome has been run on // this computer, or we're being compelled to do so by a command line flag. // Note that this be done _after_ the PrefService is initialized and all @@ -1866,6 +1843,25 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { NaClProcessHost::EarlyStartup(); #endif + run_message_loop_ = true; + return content::RESULT_CODE_NORMAL_EXIT; +} + +// Called from MainMessageLoopRun(). +void ChromeBrowserMainParts::StartBrowserOrUITask() { + // Still initializing, so need to allow IO. + base::ThreadRestrictions::ScopedAllowIO allow_io; + + // Set the notification UI manager after any desktop initialization in + // PreMainMessageLoopRun() is complete, and before starting the browser. + DesktopNotificationServiceFactory::GetForProfile(profile_)->SetUIManager( + g_browser_process->notification_ui_manager()); + + // Tests should be able to tune login manager before showing it. + // Thus only show login manager in normal (non-testing) mode. + if (!parameters().ui_task) + OptionallyRunChromeOSLoginManager(parsed_command_line(), profile_); + if (parameters().ui_task) { // We are in test mode. Run one task and enter the main message loop. #if defined(OS_MACOSX) @@ -1935,13 +1931,18 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { } } browser_init_.reset(); - return result_code_; } bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { // Set the result code set in PreMainMessageLoopRun or set above. *result_code = result_code_; + // TODO(stevenjb): Move this to another phase, and/or clean up + // PreMainMessageLoopRun() so that this can happen after desktop + // initilaization and before running the main loop. + if (run_message_loop_) + StartBrowserOrUITask(); + if (!run_message_loop_) return true; // Don't run the default message loop. @@ -2063,19 +2064,8 @@ void ChromeBrowserMainParts::PostMainMessageLoopRun() { // to bypass this code. Perhaps we need a *final* hook that is called on all // paths from content/browser/browser_main. CHECK(MetricsService::UmaMetricsProperlyShutdown()); - - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) - chrome_extra_parts_[i]->PostMainMessageLoopRun(); } -// Public members: - -void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { - chrome_extra_parts_.push_back(parts); -} - -// Misc ------------------------------------------------------------------------ - // This code is specific to the Windows-only PreReadExperiment field-trial. void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { DCHECK(name != NULL); diff --git a/chrome/browser/chrome_browser_main.h b/chrome/browser/chrome_browser_main.h index b2be37f..867b14c 100644 --- a/chrome/browser/chrome_browser_main.h +++ b/chrome/browser/chrome_browser_main.h @@ -9,7 +9,6 @@ #include "base/basictypes.h" #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" -#include "base/memory/scoped_vector.h" #include "base/metrics/field_trial.h" #include "base/tracked_objects.h" #include "chrome/browser/first_run/first_run.h" @@ -18,7 +17,6 @@ class BrowserInit; class BrowserProcessImpl; -class ChromeBrowserMainExtraParts; class FieldTrialSynchronizer; class HistogramSynchronizer; class MetricsService; @@ -45,14 +43,23 @@ class ChromeBrowserMainParts : public content::BrowserMainParts { public: virtual ~ChromeBrowserMainParts(); - // Add additional ChromeBrowserMainExtraParts. - virtual void AddParts(ChromeBrowserMainExtraParts* parts); + // Constructs metrics service and does related initialization, including + // creation of field trials. Call only after labs have been converted to + // switches. + MetricsService* SetupMetricsAndFieldTrials(PrefService* local_state); + + const content::MainFunctionParams& parameters() const { + return parameters_; + } + const CommandLine& parsed_command_line() const { + return parsed_command_line_; + } protected: explicit ChromeBrowserMainParts( const content::MainFunctionParams& parameters); - // content::BrowserMainParts overrides. + // content::BrowserParts overrides virtual void PreEarlyInitialization() OVERRIDE; virtual void PostEarlyInitialization() OVERRIDE; virtual void ToolkitInitialized() OVERRIDE; @@ -65,15 +72,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts { // Displays a warning message that we can't find any locale data files. virtual void ShowMissingLocaleMessageBox() = 0; - const content::MainFunctionParams& parameters() const { - return parameters_; - } - const CommandLine& parsed_command_line() const { - return parsed_command_line_; - } - - Profile* profile() { return profile_; } - private: // Methods for |EarlyInitialization()| --------------------------------------- @@ -106,11 +104,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts { // Methods for |SetupMetricsAndFieldTrials()| -------------------------------- - // Constructs metrics service and does related initialization, including - // creation of field trials. Call only after labs have been converted to - // switches. - MetricsService* SetupMetricsAndFieldTrials(PrefService* local_state); - static MetricsService* InitializeMetrics( const CommandLine& parsed_command_line, const PrefService* local_state); @@ -122,6 +115,7 @@ class ChromeBrowserMainParts : public content::BrowserMainParts { // Methods for Main Message Loop ------------------------------------------- int PreMainMessageLoopRunImpl(); + void StartBrowserOrUITask(); // Members initialized on construction --------------------------------------- @@ -143,9 +137,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts { // SetupMetricsAndFieldTrials is called. scoped_ptr<base::FieldTrialList> field_trial_list_; - // Vector of additional ChromeBrowserMainExtraParts. - ScopedVector<ChromeBrowserMainExtraParts> chrome_extra_parts_; - // Members initialized after / released before main_message_loop_ ------------ scoped_ptr<BrowserInit> browser_init_; diff --git a/chrome/browser/chrome_browser_main_extra_parts.cc b/chrome/browser/chrome_browser_main_extra_parts.cc deleted file mode 100644 index 3188931..0000000 --- a/chrome/browser/chrome_browser_main_extra_parts.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2011 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 "chrome/browser/chrome_browser_main_extra_parts.h" - -ChromeBrowserMainExtraParts::ChromeBrowserMainExtraParts() { -} - -ChromeBrowserMainExtraParts::~ChromeBrowserMainExtraParts() { -} - -void ChromeBrowserMainExtraParts::PreEarlyInitialization() { -} - -void ChromeBrowserMainExtraParts::PostEarlyInitialization() { -} - -void ChromeBrowserMainExtraParts::PreMainMessageLoopStart() { -} - -void ChromeBrowserMainExtraParts::PostMainMessageLoopStart() { -} - -void ChromeBrowserMainExtraParts::ToolkitInitialized() { -} - -void ChromeBrowserMainExtraParts::PostBrowserProcessInit() { -} - -void ChromeBrowserMainExtraParts::PostProfileInitialized() { -} - -void ChromeBrowserMainExtraParts::PreMainMessageLoopRun() { -} - -void ChromeBrowserMainExtraParts::PostMainMessageLoopRun() { -} diff --git a/chrome/browser/chrome_browser_main_extra_parts.h b/chrome/browser/chrome_browser_main_extra_parts.h deleted file mode 100644 index a839d44..0000000 --- a/chrome/browser/chrome_browser_main_extra_parts.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_H_ -#define CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" - -// Interface class for Parts owned by ChromeBrowserMainParts. -// The default implementation for all methods is empty. - -// Most of these map to content::BrowserMainParts methods. This interface is -// separate to allow stages to be further subdivided for Chrome specific -// initialization stages (e.g. browser process init, profile init). - -class ChromeBrowserMainExtraParts { - public: - ChromeBrowserMainExtraParts(); - virtual ~ChromeBrowserMainExtraParts(); - - // EarlyInitialization methods. - virtual void PreEarlyInitialization(); - virtual void PostEarlyInitialization(); - - // PreMainMessageLoopStart methods. - virtual void PreMainMessageLoopStart(); - virtual void PostMainMessageLoopStart(); - - // ToolkitInitialized methods. - virtual void ToolkitInitialized(); - - // MainMessageLoopRun methods. - virtual void PostBrowserProcessInit(); - virtual void PostProfileInitialized(); - virtual void PreMainMessageLoopRun(); - virtual void PostMainMessageLoopRun(); - - private: - DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraParts); -}; - -#endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_H_ diff --git a/chrome/browser/chrome_browser_main_extra_parts_aura.h b/chrome/browser/chrome_browser_main_extra_parts_aura.h deleted file mode 100644 index 2af4a18..0000000 --- a/chrome/browser/chrome_browser_main_extra_parts_aura.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_AURA_H_ -#define CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_AURA_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "chrome/browser/chrome_browser_main_extra_parts.h" - -class ChromeBrowserMainExtraPartsAura : public ChromeBrowserMainExtraParts { - public: - ChromeBrowserMainExtraPartsAura(); - - virtual void PostBrowserProcessInit() OVERRIDE; - - private: - DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsAura); -}; - -#endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_AURA_H_ diff --git a/chrome/browser/chrome_browser_main_extra_parts_gtk.h b/chrome/browser/chrome_browser_main_extra_parts_gtk.h deleted file mode 100644 index 34b596f..0000000 --- a/chrome/browser/chrome_browser_main_extra_parts_gtk.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2011 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. - -// Contains functions used by BrowserMain() that are gtk-specific. - -#ifndef CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_GTK_H_ -#define CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_GTK_H_ -#pragma once - -#include "base/compiler_specific.h" -#include "chrome/browser/chrome_browser_main_extra_parts.h" - -class ChromeBrowserMainExtraPartsGtk : public ChromeBrowserMainExtraParts { - public: - ChromeBrowserMainExtraPartsGtk(); - - virtual void PreEarlyInitialization() OVERRIDE; - - static void ShowMessageBox(const char* message); - - private: - void DetectRunningAsRoot(); -}; - -#endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_GTK_H_ diff --git a/chrome/browser/chrome_browser_main_extra_parts_touch.h b/chrome/browser/chrome_browser_main_extra_parts_touch.h deleted file mode 100644 index 603a750..0000000 --- a/chrome/browser/chrome_browser_main_extra_parts_touch.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_TOUCH_H_ -#define CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_TOUCH_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "chrome/browser/chrome_browser_main_extra_parts.h" - -class ChromeBrowserMainExtraPartsTouch : public ChromeBrowserMainExtraParts { - public: - ChromeBrowserMainExtraPartsTouch(); - - virtual void PreMainMessageLoopRun() OVERRIDE; - - private: - DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsTouch); -}; - -#endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_TOUCH_H_ diff --git a/chrome/browser/chrome_browser_main_extra_parts_views.h b/chrome/browser/chrome_browser_main_extra_parts_views.h deleted file mode 100644 index 764d605..0000000 --- a/chrome/browser/chrome_browser_main_extra_parts_views.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2011 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. - -// Contains functions used by BrowserMain() that are views-specific. - -#ifndef CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_VIEWS_H_ -#define CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_VIEWS_H_ -#pragma once - -#include "base/compiler_specific.h" -#include "chrome/browser/chrome_browser_main_extra_parts.h" - -class ChromeBrowserMainExtraPartsViews : public ChromeBrowserMainExtraParts { - public: - ChromeBrowserMainExtraPartsViews(); - - virtual void ToolkitInitialized() OVERRIDE; - virtual void PostBrowserProcessInit() OVERRIDE; -}; - -#endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_VIEWS_H_ diff --git a/chrome/browser/chrome_browser_main_linux.cc b/chrome/browser/chrome_browser_main_linux.cc index 4900de6..9abc2ca 100644 --- a/chrome/browser/chrome_browser_main_linux.cc +++ b/chrome/browser/chrome_browser_main_linux.cc @@ -5,7 +5,7 @@ #include "chrome/browser/chrome_browser_main_linux.h" #if defined(TOOLKIT_USES_GTK) -#include "chrome/browser/chrome_browser_main_extra_parts_gtk.h" +#include "chrome/browser/chrome_browser_parts_gtk.h" #endif ChromeBrowserMainPartsLinux::ChromeBrowserMainPartsLinux( @@ -18,7 +18,7 @@ void ChromeBrowserMainPartsLinux::ShowMissingLocaleMessageBox() { // This should never happen on Aura. NOTREACHED() << chrome_browser::kMissingLocaleDataMessage; #elif defined(TOOLKIT_USES_GTK) - ChromeBrowserMainExtraPartsGtk::ShowMessageBox( + ChromeBrowserPartsGtk::ShowMessageBox( chrome_browser::kMissingLocaleDataMessage); #else #error "Need MessageBox implementation for linux without Aura or Gtk" diff --git a/chrome/browser/chrome_browser_main_unittest.cc b/chrome/browser/chrome_browser_main_unittest.cc index f5c549b..4a2f265 100644 --- a/chrome/browser/chrome_browser_main_unittest.cc +++ b/chrome/browser/chrome_browser_main_unittest.cc @@ -30,9 +30,12 @@ TEST_F(BrowserMainTest, WarmConnectionFieldTrial_WarmestSocket) { scoped_ptr<content::MainFunctionParams> params( new content::MainFunctionParams(command_line_)); - scoped_ptr<content::BrowserMainParts> bw( - content::GetContentClient()->browser()->CreateBrowserMainParts(*params)); - ChromeBrowserMainParts* cbw = static_cast<ChromeBrowserMainParts*>(bw.get()); + ScopedVector<content::BrowserMainParts> bwv; + content::GetContentClient()->browser()->CreateBrowserMainParts( + *params, &(bwv.get())); + ChromeBrowserMainParts* cbw = NULL; + if (bwv.size() >= 1) + cbw = static_cast<ChromeBrowserMainParts*>(bwv[0]); EXPECT_TRUE(cbw); if (cbw) { cbw->WarmConnectionFieldTrial(); @@ -43,9 +46,12 @@ TEST_F(BrowserMainTest, WarmConnectionFieldTrial_WarmestSocket) { TEST_F(BrowserMainTest, WarmConnectionFieldTrial_Random) { scoped_ptr<content::MainFunctionParams> params( new content::MainFunctionParams(command_line_)); - scoped_ptr<content::BrowserMainParts> bw( - content::GetContentClient()->browser()->CreateBrowserMainParts(*params)); - ChromeBrowserMainParts* cbw = static_cast<ChromeBrowserMainParts*>(bw.get()); + ScopedVector<content::BrowserMainParts> bwv; + content::GetContentClient()->browser()->CreateBrowserMainParts( + *params, &(bwv.get())); + ChromeBrowserMainParts* cbw = NULL; + if (bwv.size() >= 1) + cbw = static_cast<ChromeBrowserMainParts*>(bwv[0]); EXPECT_TRUE(cbw); if (cbw) { const int kNumRuns = 1000; @@ -65,15 +71,17 @@ TEST_F(BrowserMainTest, WarmConnectionFieldTrial_Invalid) { new content::MainFunctionParams(command_line_)); // This test ends up launching a new process, and that doesn't initialize the // ContentClient interfaces. - scoped_ptr<content::BrowserMainParts> bw; + ScopedVector<content::BrowserMainParts> bwv; if (content::GetContentClient()) { - bw.reset(content::GetContentClient()->browser()->CreateBrowserMainParts( - *params)); + content::GetContentClient()->browser()->CreateBrowserMainParts( + *params, &(bwv.get())); } else { chrome::ChromeContentBrowserClient ccbc; - bw.reset(ccbc.CreateBrowserMainParts(*params)); + ccbc.CreateBrowserMainParts(*params, &(bwv.get())); } - ChromeBrowserMainParts* cbw = static_cast<ChromeBrowserMainParts*>(bw.get()); + ChromeBrowserMainParts* cbw = NULL; + if (bwv.size() >= 1) + cbw = static_cast<ChromeBrowserMainParts*>(bwv[0]); EXPECT_TRUE(cbw); if (cbw) { #if defined(NDEBUG) && defined(DCHECK_ALWAYS_ON) diff --git a/chrome/browser/chrome_browser_main_extra_parts_aura.cc b/chrome/browser/chrome_browser_parts_aura.cc index ea5214f..a2907e1 100644 --- a/chrome/browser/chrome_browser_main_extra_parts_aura.cc +++ b/chrome/browser/chrome_browser_parts_aura.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chrome_browser_main_extra_parts_aura.h" +#include "chrome/browser/chrome_browser_parts_aura.h" #include "chrome/browser/ui/views/aura/chrome_shell_delegate.h" #include "ui/aura/desktop.h" #include "ui/aura_shell/shell.h" @@ -11,11 +11,26 @@ #include "chrome/browser/chromeos/system/runtime_environment.h" #endif -ChromeBrowserMainExtraPartsAura::ChromeBrowserMainExtraPartsAura() - : ChromeBrowserMainExtraParts() { +ChromeBrowserPartsAura::ChromeBrowserPartsAura() + : content::BrowserMainParts() { } -void ChromeBrowserMainExtraPartsAura::PostBrowserProcessInit() { +void ChromeBrowserPartsAura::PreEarlyInitialization() { +} + +void ChromeBrowserPartsAura::PostEarlyInitialization() { +} + +void ChromeBrowserPartsAura::ToolkitInitialized() { +} + +void ChromeBrowserPartsAura::PreMainMessageLoopStart() { +} + +void ChromeBrowserPartsAura::PostMainMessageLoopStart() { +} + +void ChromeBrowserPartsAura::PreMainMessageLoopRun() { #if defined(OS_CHROMEOS) if (chromeos::system::runtime_environment::IsRunningOnChromeOS()) aura::Desktop::set_use_fullscreen_host_window(true); @@ -24,3 +39,10 @@ void ChromeBrowserMainExtraPartsAura::PostBrowserProcessInit() { // Shell takes ownership of ChromeShellDelegate. aura_shell::Shell::CreateInstance(new ChromeShellDelegate); } + +bool ChromeBrowserPartsAura::MainMessageLoopRun(int* result_code) { + return false; +} + +void ChromeBrowserPartsAura::PostMainMessageLoopRun() { +} diff --git a/chrome/browser/chrome_browser_parts_aura.h b/chrome/browser/chrome_browser_parts_aura.h new file mode 100644 index 0000000..dbc9d76 --- /dev/null +++ b/chrome/browser/chrome_browser_parts_aura.h @@ -0,0 +1,29 @@ +// Copyright (c) 2011 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. + +#ifndef CHROME_BROWSER_CHROME_BROWSER_PARTS_AURA_H_ +#define CHROME_BROWSER_CHROME_BROWSER_PARTS_AURA_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "content/public/browser/browser_main_parts.h" + +class ChromeBrowserPartsAura : public content::BrowserMainParts { + public: + ChromeBrowserPartsAura(); + + virtual void PreEarlyInitialization() OVERRIDE; + virtual void PostEarlyInitialization() OVERRIDE; + virtual void ToolkitInitialized() OVERRIDE; + virtual void PreMainMessageLoopStart() OVERRIDE; + virtual void PostMainMessageLoopStart() OVERRIDE; + virtual void PreMainMessageLoopRun() OVERRIDE; + virtual bool MainMessageLoopRun(int* result_code) OVERRIDE; + virtual void PostMainMessageLoopRun() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(ChromeBrowserPartsAura); +}; + +#endif // CHROME_BROWSER_CHROME_BROWSER_PARTS_AURA_H_ diff --git a/chrome/browser/chrome_browser_main_extra_parts_gtk.cc b/chrome/browser/chrome_browser_parts_gtk.cc index 406d3ec..3d1a5aa 100644 --- a/chrome/browser/chrome_browser_main_extra_parts_gtk.cc +++ b/chrome/browser/chrome_browser_parts_gtk.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chrome_browser_main_extra_parts_gtk.h" +#include "chrome/browser/chrome_browser_parts_gtk.h" #include <gtk/gtk.h> @@ -14,16 +14,37 @@ #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/gtk_util.h" -ChromeBrowserMainExtraPartsGtk::ChromeBrowserMainExtraPartsGtk() - : ChromeBrowserMainExtraParts() { +ChromeBrowserPartsGtk::ChromeBrowserPartsGtk() + : content::BrowserMainParts() { } -void ChromeBrowserMainExtraPartsGtk::PreEarlyInitialization() { +void ChromeBrowserPartsGtk::PreEarlyInitialization() { DetectRunningAsRoot(); } +void ChromeBrowserPartsGtk::PostEarlyInitialization() { +} + +void ChromeBrowserPartsGtk::ToolkitInitialized() { +} + +void ChromeBrowserPartsGtk::PreMainMessageLoopStart() { +} + +void ChromeBrowserPartsGtk::PostMainMessageLoopStart() { +} + +void ChromeBrowserPartsGtk::PreMainMessageLoopRun() { +} + +bool ChromeBrowserPartsGtk::MainMessageLoopRun(int* result_code) { + return false; +} + +void ChromeBrowserPartsGtk::PostMainMessageLoopRun() { +} -void ChromeBrowserMainExtraPartsGtk::DetectRunningAsRoot() { +void ChromeBrowserPartsGtk::DetectRunningAsRoot() { if (geteuid() == 0) { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); if (command_line.HasSwitch(switches::kUserDataDir)) @@ -65,7 +86,7 @@ void ChromeBrowserMainExtraPartsGtk::DetectRunningAsRoot() { } // static -void ChromeBrowserMainExtraPartsGtk::ShowMessageBox(const char* message) { +void ChromeBrowserPartsGtk::ShowMessageBox(const char* message) { GtkWidget* dialog = gtk_message_dialog_new( NULL, static_cast<GtkDialogFlags>(0), diff --git a/chrome/browser/chrome_browser_parts_gtk.h b/chrome/browser/chrome_browser_parts_gtk.h new file mode 100644 index 0000000..e824f3c --- /dev/null +++ b/chrome/browser/chrome_browser_parts_gtk.h @@ -0,0 +1,33 @@ +// Copyright (c) 2011 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. + +// Contains functions used by BrowserMain() that are gtk-specific. + +#ifndef CHROME_BROWSER_CHROME_BROWSER_PARTS_GTK_H_ +#define CHROME_BROWSER_CHROME_BROWSER_PARTS_GTK_H_ +#pragma once + +#include "base/compiler_specific.h" +#include "content/public/browser/browser_main_parts.h" + +class ChromeBrowserPartsGtk : public content::BrowserMainParts { + public: + ChromeBrowserPartsGtk(); + + virtual void PreEarlyInitialization() OVERRIDE; + virtual void PostEarlyInitialization() OVERRIDE; + virtual void ToolkitInitialized() OVERRIDE; + virtual void PreMainMessageLoopStart() OVERRIDE; + virtual void PostMainMessageLoopStart() OVERRIDE; + virtual void PreMainMessageLoopRun() OVERRIDE; + virtual bool MainMessageLoopRun(int* result_code) OVERRIDE; + virtual void PostMainMessageLoopRun() OVERRIDE; + + static void ShowMessageBox(const char* message); + + private: + void DetectRunningAsRoot(); +}; + +#endif // CHROME_BROWSER_CHROME_BROWSER_PARTS_GTK_H_ diff --git a/chrome/browser/chrome_browser_main_extra_parts_touch.cc b/chrome/browser/chrome_browser_parts_touch.cc index bfaa919..506cf1d 100644 --- a/chrome/browser/chrome_browser_main_extra_parts_touch.cc +++ b/chrome/browser/chrome_browser_parts_touch.cc @@ -2,15 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chrome_browser_main_extra_parts_touch.h" +#include "chrome/browser/chrome_browser_parts_touch.h" #include "chrome/browser/ui/touch/sensors/screen_orientation_listener.h" -ChromeBrowserMainExtraPartsTouch::ChromeBrowserMainExtraPartsTouch() - : ChromeBrowserMainExtraParts() { +ChromeBrowserPartsTouch::ChromeBrowserPartsTouch() + : content::BrowserMainParts() { } -void ChromeBrowserMainExtraPartsTouch::PreMainMessageLoopRun() { +void ChromeBrowserPartsTouch::PreMainMessageLoopRun() { // Make sure the singleton ScreenOrientationListener object is created. ScreenOrientationListener::GetInstance(); } + +bool ChromeBrowserPartsTouch::MainMessageLoopRun(int* result_code) { + return false; +} diff --git a/chrome/browser/chrome_browser_parts_touch.h b/chrome/browser/chrome_browser_parts_touch.h new file mode 100644 index 0000000..0cd9502 --- /dev/null +++ b/chrome/browser/chrome_browser_parts_touch.h @@ -0,0 +1,29 @@ +// Copyright (c) 2011 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. + +#ifndef CHROME_BROWSER_CHROME_BROWSER_PARTS_TOUCH_H_ +#define CHROME_BROWSER_CHROME_BROWSER_PARTS_TOUCH_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "content/public/browser/browser_main_parts.h" + +class ChromeBrowserPartsTouch : public content::BrowserMainParts { + public: + ChromeBrowserPartsTouch(); + + virtual void PreEarlyInitialization() OVERRIDE {} + virtual void PostEarlyInitialization() OVERRIDE {} + virtual void PreMainMessageLoopStart() OVERRIDE {} + virtual void ToolkitInitialized() OVERRIDE {} + virtual void PostMainMessageLoopStart() OVERRIDE {} + virtual void PreMainMessageLoopRun() OVERRIDE; + virtual bool MainMessageLoopRun(int* result_code) OVERRIDE; + virtual void PostMainMessageLoopRun() OVERRIDE {} + + private: + DISALLOW_COPY_AND_ASSIGN(ChromeBrowserPartsTouch); +}; + +#endif // CHROME_BROWSER_CHROME_BROWSER_PARTS_TOUCH_H_ diff --git a/chrome/browser/chrome_browser_main_extra_parts_views.cc b/chrome/browser/chrome_browser_parts_views.cc index 78087d1..3191108 100644 --- a/chrome/browser/chrome_browser_main_extra_parts_views.cc +++ b/chrome/browser/chrome_browser_parts_views.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chrome_browser_main_extra_parts_views.h" +#include "chrome/browser/chrome_browser_parts_views.h" #include <string> @@ -12,11 +12,11 @@ #include "ui/views/desktop/desktop_window_view.h" #include "views/widget/widget.h" -ChromeBrowserMainExtraPartsViews::ChromeBrowserMainExtraPartsViews() - : ChromeBrowserMainExtraParts() { +ChromeBrowserPartsViews::ChromeBrowserPartsViews() + : content::BrowserMainParts() { } -void ChromeBrowserMainExtraPartsViews::ToolkitInitialized() { +void ChromeBrowserPartsViews::ToolkitInitialized() { // The delegate needs to be set before any UI is created so that windows // display the correct icon. if (!views::ViewsDelegate::views_delegate) @@ -27,7 +27,7 @@ void ChromeBrowserMainExtraPartsViews::ToolkitInitialized() { views::Widget::SetDebugPaintEnabled(true); } -void ChromeBrowserMainExtraPartsViews::PostBrowserProcessInit() { +void ChromeBrowserPartsViews::PreMainMessageLoopRun() { #if !defined(USE_AURA) views::Widget::SetPureViews( CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePureViews)); @@ -54,3 +54,7 @@ void ChromeBrowserMainExtraPartsViews::PostBrowserProcessInit() { } #endif } + +bool ChromeBrowserPartsViews::MainMessageLoopRun(int* result_code) { + return false; +} diff --git a/chrome/browser/chrome_browser_parts_views.h b/chrome/browser/chrome_browser_parts_views.h new file mode 100644 index 0000000..e3805dc --- /dev/null +++ b/chrome/browser/chrome_browser_parts_views.h @@ -0,0 +1,28 @@ +// Copyright (c) 2011 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. + +// Contains functions used by BrowserMain() that are views-specific. + +#ifndef CHROME_BROWSER_CHROME_BROWSER_PARTS_VIEWS_H_ +#define CHROME_BROWSER_CHROME_BROWSER_PARTS_VIEWS_H_ +#pragma once + +#include "base/compiler_specific.h" +#include "content/public/browser/browser_main_parts.h" + +class ChromeBrowserPartsViews : public content::BrowserMainParts { + public: + ChromeBrowserPartsViews(); + + virtual void PreEarlyInitialization() OVERRIDE {} + virtual void PostEarlyInitialization() OVERRIDE {} + virtual void PreMainMessageLoopStart() OVERRIDE {} + virtual void ToolkitInitialized() OVERRIDE; + virtual void PostMainMessageLoopStart() OVERRIDE {} + virtual void PreMainMessageLoopRun() OVERRIDE; + virtual bool MainMessageLoopRun(int* result_code) OVERRIDE; + virtual void PostMainMessageLoopRun() OVERRIDE {} +}; + +#endif // CHROME_BROWSER_CHROME_BROWSER_PARTS_VIEWS_H_ diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 398958b..d5dd276 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -93,19 +93,15 @@ #endif #if defined(TOOLKIT_USES_GTK) -#include "chrome/browser/chrome_browser_main_extra_parts_gtk.h" +#include "chrome/browser/chrome_browser_parts_gtk.h" #endif #if defined(TOOLKIT_VIEWS) -#include "chrome/browser/chrome_browser_main_extra_parts_views.h" +#include "chrome/browser/chrome_browser_parts_views.h" #endif #if defined(USE_AURA) -#include "chrome/browser/chrome_browser_main_extra_parts_aura.h" -#endif - -#if defined(TOUCH_UI) -#include "chrome/browser/chrome_browser_main_extra_parts_touch.h" +#include "chrome/browser/chrome_browser_parts_aura.h" #endif #if defined(OS_LINUX) || defined(OS_OPENBSD) @@ -113,6 +109,10 @@ #include "chrome/browser/crash_handler_host_linux.h" #endif +#if defined(TOUCH_UI) +#include "chrome/browser/chrome_browser_parts_touch.h" +#endif + #if defined(TOOLKIT_VIEWS) #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" #elif defined(TOOLKIT_USES_GTK) @@ -219,44 +219,43 @@ RenderProcessHostPrivilege GetProcessPrivilege( namespace chrome { -content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts( - const content::MainFunctionParams& parameters) { - ChromeBrowserMainParts* main_parts; +void ChromeContentBrowserClient::CreateBrowserMainParts( + const content::MainFunctionParams& parameters, + std::vector<content::BrowserMainParts*>* parts_list) { // Construct the Main browser parts based on the OS type. #if defined(OS_WIN) - main_parts = new ChromeBrowserMainPartsWin(parameters); + parts_list->push_back(new ChromeBrowserMainPartsWin(parameters)); #elif defined(OS_MACOSX) - main_parts = new ChromeBrowserMainPartsMac(parameters); + parts_list->push_back(new ChromeBrowserMainPartsMac(parameters)); #elif defined(OS_CHROMEOS) - main_parts = new ChromeBrowserMainPartsChromeos(parameters); + parts_list->push_back(new ChromeBrowserMainPartsChromeos(parameters)); #elif defined(OS_LINUX) || defined(OS_OPENBSD) - main_parts = new ChromeBrowserMainPartsLinux(parameters); + parts_list->push_back(new ChromeBrowserMainPartsLinux(parameters)); #elif defined(OS_POSIX) - main_parts = new ChromeBrowserMainPartsPosix(parameters); + parts_list->push_back(new ChromeBrowserMainPartsPosix(parameters)); #else NOTREACHED(); - main_parts = new ChromeBrowserMainParts(parameters); + parts_list->push_back(new ChromeBrowserMainParts(parameters)); #endif // Construct additional browser parts. Stages are called in the order in // which they are added. #if defined(TOOLKIT_USES_GTK) - main_parts->AddParts(new ChromeBrowserMainExtraPartsGtk()); + parts_list->push_back(new ChromeBrowserPartsGtk()); #endif #if defined(TOOLKIT_VIEWS) - main_parts->AddParts(new ChromeBrowserMainExtraPartsViews()); + parts_list->push_back(new ChromeBrowserPartsViews()); #endif #if defined(USE_AURA) - main_parts->AddParts(new ChromeBrowserMainExtraPartsAura()); + parts_list->push_back(new ChromeBrowserPartsAura()); #endif #if defined(TOUCH_UI) - main_parts->AddParts(new ChromeBrowserMainExtraPartsTouch()); + parts_list->push_back(new ChromeBrowserPartsTouch()); #endif - return main_parts; } RenderWidgetHostView* ChromeContentBrowserClient::CreateViewForWidget( diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h index 2aff69a..50aed5d 100644 --- a/chrome/browser/chrome_content_browser_client.h +++ b/chrome/browser/chrome_content_browser_client.h @@ -15,8 +15,9 @@ namespace chrome { class ChromeContentBrowserClient : public content::ContentBrowserClient { public: - virtual content::BrowserMainParts* CreateBrowserMainParts( - const content::MainFunctionParams& parameters) OVERRIDE; + virtual void CreateBrowserMainParts( + const content::MainFunctionParams& parameters, + std::vector<content::BrowserMainParts*>* parts_list) OVERRIDE; virtual RenderWidgetHostView* CreateViewForWidget( RenderWidgetHost* widget) OVERRIDE; virtual TabContentsView* CreateTabContentsView( diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.h b/chrome/browser/chromeos/chrome_browser_main_chromeos.h index dc3ef21..5190db1 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.h +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.h @@ -19,11 +19,10 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux { const content::MainFunctionParams& parameters); virtual ~ChromeBrowserMainPartsChromeos(); - // content::BrowserMainParts overrides. virtual void PreEarlyInitialization() OVERRIDE; virtual void PreMainMessageLoopStart() OVERRIDE; - virtual void PostMainMessageLoopStart() OVERRIDE; virtual void PreMainMessageLoopRun() OVERRIDE; + virtual void PostMainMessageLoopStart() OVERRIDE; private: scoped_ptr<chromeos::BrightnessObserver> brightness_observer_; diff --git a/chrome/browser/notifications/desktop_notification_service_factory.cc b/chrome/browser/notifications/desktop_notification_service_factory.cc index ec8543a..f4402ab 100644 --- a/chrome/browser/notifications/desktop_notification_service_factory.cc +++ b/chrome/browser/notifications/desktop_notification_service_factory.cc @@ -35,9 +35,8 @@ DesktopNotificationServiceFactory::~DesktopNotificationServiceFactory() { ProfileKeyedService* DesktopNotificationServiceFactory::BuildServiceInstanceFor( Profile* profile) const { - DesktopNotificationService* service = new DesktopNotificationService(profile, - g_browser_process->notification_ui_manager()); - + DesktopNotificationService* service = + new DesktopNotificationService(profile, NULL); return service; } diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 6b01b48..95a8196 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -354,16 +354,14 @@ 'browser/chrome_browser_main_win.h', 'browser/chrome_browser_main_x11.cc', 'browser/chrome_browser_main_x11.h', - 'browser/chrome_browser_main_extra_parts.cc', - 'browser/chrome_browser_main_extra_parts.h', - 'browser/chrome_browser_main_extra_parts_aura.cc', - 'browser/chrome_browser_main_extra_parts_aura.h', - 'browser/chrome_browser_main_extra_parts_gtk.cc', - 'browser/chrome_browser_main_extra_parts_gtk.h', - 'browser/chrome_browser_main_extra_parts_touch.cc', - 'browser/chrome_browser_main_extra_parts_touch.h', - 'browser/chrome_browser_main_extra_parts_views.cc', - 'browser/chrome_browser_main_extra_parts_views.h', + 'browser/chrome_browser_parts_aura.cc', + 'browser/chrome_browser_parts_aura.h', + 'browser/chrome_browser_parts_gtk.cc', + 'browser/chrome_browser_parts_gtk.h', + 'browser/chrome_browser_parts_touch.cc', + 'browser/chrome_browser_parts_touch.h', + 'browser/chrome_browser_parts_views.cc', + 'browser/chrome_browser_parts_views.h', 'browser/chrome_content_browser_client.cc', 'browser/chrome_content_browser_client.h', 'browser/chrome_plugin_message_filter.cc', diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS index 5e7e29b..d25579d 100644 --- a/chrome/test/functional/PYAUTO_TESTS +++ b/chrome/test/functional/PYAUTO_TESTS @@ -94,6 +94,9 @@ '-indexeddb.IndexedDBTest.testVersionChangeCrashResilience', # crbug.com/99506 '-notifications.NotificationsTest.testSpecialURLNotification', + # Cause browser crash. crbug.com/103427 + '-notifications.NotificationsTest.testIncognitoNotification', + '-notifications.NotificationsTest.testOriginPrefsNotSavedInIncognito', # crbug.com/71715 '-omnibox.OmniboxTest.testHistoryResult', # crbug.com/97140 |