| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" | 5 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 virtual void DidProcessEvent(GdkEvent* event) { | 64 virtual void DidProcessEvent(GdkEvent* event) { |
| 65 } | 65 } |
| 66 #endif | 66 #endif |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer( | 69 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer( |
| 70 base::LINKER_INITIALIZED); | 70 base::LINKER_INITIALIZED); |
| 71 | 71 |
| 72 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( | 72 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( |
| 73 const MainFunctionParams& parameters) | 73 const MainFunctionParams& parameters) |
| 74 : ChromeBrowserMainPartsBase(parameters) { | 74 : ChromeBrowserMainPartsLinux(parameters) { |
| 75 } | 75 } |
| 76 | 76 |
| 77 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { | 77 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { |
| 78 // We should remove observers attached to D-Bus clients before | 78 // We should remove observers attached to D-Bus clients before |
| 79 // DBusThreadManager is shut down. | 79 // DBusThreadManager is shut down. |
| 80 if (session_manager_observer_.get()) { | 80 if (session_manager_observer_.get()) { |
| 81 chromeos::DBusThreadManager::Get()->session_manager_client()-> | 81 chromeos::DBusThreadManager::Get()->session_manager_client()-> |
| 82 RemoveObserver(session_manager_observer_.get()); | 82 RemoveObserver(session_manager_observer_.get()); |
| 83 } | 83 } |
| 84 if (brightness_observer_.get()) { | 84 if (brightness_observer_.get()) { |
| 85 chromeos::DBusThreadManager::Get()->power_manager_client()->RemoveObserver( | 85 chromeos::DBusThreadManager::Get()->power_manager_client()->RemoveObserver( |
| 86 brightness_observer_.get()); | 86 brightness_observer_.get()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 chromeos::DBusThreadManager::Shutdown(); | 89 chromeos::DBusThreadManager::Shutdown(); |
| 90 | 90 |
| 91 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) | 91 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) |
| 92 chromeos::CrosLibrary::Shutdown(); | 92 chromeos::CrosLibrary::Shutdown(); |
| 93 | 93 |
| 94 // To be precise, logout (browser shutdown) is not yet done, but the | 94 // To be precise, logout (browser shutdown) is not yet done, but the |
| 95 // remaining work is negligible, hence we say LogoutDone here. | 95 // remaining work is negligible, hence we say LogoutDone here. |
| 96 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 96 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
| 97 false); | 97 false); |
| 98 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 98 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() { | 101 void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() { |
| 102 ChromeBrowserMainPartsBase::PreEarlyInitialization(); | 102 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); |
| 103 if (parsed_command_line().HasSwitch(switches::kGuestSession)) { | 103 if (parsed_command_line().HasSwitch(switches::kGuestSession)) { |
| 104 // Disable sync and extensions if we're in "browse without sign-in" mode. | 104 // Disable sync and extensions if we're in "browse without sign-in" mode. |
| 105 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); | 105 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); |
| 106 singleton_command_line->AppendSwitch(switches::kDisableSync); | 106 singleton_command_line->AppendSwitch(switches::kDisableSync); |
| 107 singleton_command_line->AppendSwitch(switches::kDisableExtensions); | 107 singleton_command_line->AppendSwitch(switches::kDisableExtensions); |
| 108 browser_defaults::bookmarks_enabled = false; | 108 browser_defaults::bookmarks_enabled = false; |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { | 112 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { |
| 113 ChromeBrowserMainPartsBase::PreMainMessageLoopStart(); | 113 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); |
| 114 // Initialize CrosLibrary only for the browser, unless running tests | 114 // Initialize CrosLibrary only for the browser, unless running tests |
| 115 // (which do their own CrosLibrary setup). | 115 // (which do their own CrosLibrary setup). |
| 116 if (!parameters().ui_task) { | 116 if (!parameters().ui_task) { |
| 117 bool use_stub = parameters().command_line_.HasSwitch(switches::kStubCros); | 117 bool use_stub = parameters().command_line_.HasSwitch(switches::kStubCros); |
| 118 chromeos::CrosLibrary::Initialize(use_stub); | 118 chromeos::CrosLibrary::Initialize(use_stub); |
| 119 } | 119 } |
| 120 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific | 120 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific |
| 121 // implementation. | 121 // implementation. |
| 122 net::NetworkChangeNotifier::SetFactory( | 122 net::NetworkChangeNotifier::SetFactory( |
| 123 new chromeos::CrosNetworkChangeNotifierFactory()); | 123 new chromeos::CrosNetworkChangeNotifierFactory()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { | 126 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { |
| 127 // FILE thread is created in ChromeBrowserMainParts::PreMainMessageLoopRun(). | 127 // FILE thread is created in ChromeBrowserMainParts::PreMainMessageLoopRun(). |
| 128 ChromeBrowserMainPartsBase::PreMainMessageLoopRun(); | 128 ChromeBrowserMainPartsLinux::PreMainMessageLoopRun(); |
| 129 // Get the statistics provider instance here to start loading statistcs | 129 // Get the statistics provider instance here to start loading statistcs |
| 130 // on the background FILE thread. | 130 // on the background FILE thread. |
| 131 chromeos::system::StatisticsProvider::GetInstance(); | 131 chromeos::system::StatisticsProvider::GetInstance(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { | 134 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { |
| 135 ChromeBrowserMainPartsPosix::PostMainMessageLoopStart(); | 135 ChromeBrowserMainPartsPosix::PostMainMessageLoopStart(); |
| 136 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 136 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
| 137 message_loop->AddObserver(g_message_loop_observer.Pointer()); | 137 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
| 138 | 138 |
| 139 // Initialize DBusThreadManager for the browser. This must be done after | 139 // Initialize DBusThreadManager for the browser. This must be done after |
| 140 // the main message loop is started, as it uses the message loop. | 140 // the main message loop is started, as it uses the message loop. |
| 141 chromeos::DBusThreadManager::Initialize(); | 141 chromeos::DBusThreadManager::Initialize(); |
| 142 | 142 |
| 143 // Initialize the brightness observer so that we'll display an onscreen | 143 // Initialize the brightness observer so that we'll display an onscreen |
| 144 // indication of brightness changes during login. | 144 // indication of brightness changes during login. |
| 145 brightness_observer_.reset(new chromeos::BrightnessObserver()); | 145 brightness_observer_.reset(new chromeos::BrightnessObserver()); |
| 146 chromeos::DBusThreadManager::Get()->power_manager_client()->AddObserver( | 146 chromeos::DBusThreadManager::Get()->power_manager_client()->AddObserver( |
| 147 brightness_observer_.get()); | 147 brightness_observer_.get()); |
| 148 // Initialize the session manager observer so that we'll take actions | 148 // Initialize the session manager observer so that we'll take actions |
| 149 // per signals sent from the session manager. | 149 // per signals sent from the session manager. |
| 150 session_manager_observer_.reset(new chromeos::SessionManagerObserver); | 150 session_manager_observer_.reset(new chromeos::SessionManagerObserver); |
| 151 chromeos::DBusThreadManager::Get()->session_manager_client()-> | 151 chromeos::DBusThreadManager::Get()->session_manager_client()-> |
| 152 AddObserver(session_manager_observer_.get()); | 152 AddObserver(session_manager_observer_.get()); |
| 153 } | 153 } |
| OLD | NEW |