Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 #include "chrome/common/pref_names.h" | 71 #include "chrome/common/pref_names.h" |
| 72 #include "chromeos/dbus/dbus_thread_manager.h" | 72 #include "chromeos/dbus/dbus_thread_manager.h" |
| 73 #include "chromeos/dbus/power_manager_client.h" | 73 #include "chromeos/dbus/power_manager_client.h" |
| 74 #include "chromeos/dbus/session_manager_client.h" | 74 #include "chromeos/dbus/session_manager_client.h" |
| 75 #include "content/public/browser/notification_service.h" | 75 #include "content/public/browser/notification_service.h" |
| 76 #include "content/public/common/main_function_params.h" | 76 #include "content/public/common/main_function_params.h" |
| 77 #include "grit/platform_locale_settings.h" | 77 #include "grit/platform_locale_settings.h" |
| 78 #include "net/base/network_change_notifier.h" | 78 #include "net/base/network_change_notifier.h" |
| 79 #include "net/url_request/url_request.h" | 79 #include "net/url_request/url_request.h" |
| 80 | 80 |
| 81 namespace { | |
| 82 | |
| 83 // Username for stub login when not running on ChromeOS. | |
| 84 const char kStubUsername[] = "stub-user@example.com"; | |
| 85 | |
| 86 } | |
| 87 | |
| 81 class MessageLoopObserver : public MessageLoopForUI::Observer { | 88 class MessageLoopObserver : public MessageLoopForUI::Observer { |
| 82 virtual base::EventStatus WillProcessEvent( | 89 virtual base::EventStatus WillProcessEvent( |
| 83 const base::NativeEvent& event) OVERRIDE { | 90 const base::NativeEvent& event) OVERRIDE { |
| 84 return base::EVENT_CONTINUE; | 91 return base::EVENT_CONTINUE; |
| 85 } | 92 } |
| 86 | 93 |
| 87 virtual void DidProcessEvent( | 94 virtual void DidProcessEvent( |
| 88 const base::NativeEvent& event) OVERRIDE { | 95 const base::NativeEvent& event) OVERRIDE { |
| 89 } | 96 } |
| 90 }; | 97 }; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 // To be precise, logout (browser shutdown) is not yet done, but the | 229 // To be precise, logout (browser shutdown) is not yet done, but the |
| 223 // remaining work is negligible, hence we say LogoutDone here. | 230 // remaining work is negligible, hence we say LogoutDone here. |
| 224 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 231 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
| 225 false); | 232 false); |
| 226 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 233 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
| 227 } | 234 } |
| 228 | 235 |
| 229 // content::BrowserMainParts and ChromeBrowserMainExtraParts overrides --------- | 236 // content::BrowserMainParts and ChromeBrowserMainExtraParts overrides --------- |
| 230 | 237 |
| 231 void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() { | 238 void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() { |
| 239 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); | |
| 240 | |
| 232 if (parsed_command_line().HasSwitch(switches::kGuestSession)) { | 241 if (parsed_command_line().HasSwitch(switches::kGuestSession)) { |
| 233 // Disable sync and extensions if we're in "browse without sign-in" mode. | 242 // Disable sync and extensions if we're in "browse without sign-in" mode. |
| 234 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); | |
| 235 singleton_command_line->AppendSwitch(switches::kDisableSync); | 243 singleton_command_line->AppendSwitch(switches::kDisableSync); |
| 236 singleton_command_line->AppendSwitch(switches::kDisableExtensions); | 244 singleton_command_line->AppendSwitch(switches::kDisableExtensions); |
| 237 browser_defaults::bookmarks_enabled = false; | 245 browser_defaults::bookmarks_enabled = false; |
| 238 } | 246 } |
| 239 | 247 |
| 248 // If we're not running on ChromeOS, and are not showing the login manager | |
|
Nikita (slow)
2012/06/20 13:28:32
nit: Should be "If we're not running on real Chrom
Ivan Korotkov
2012/06/21 12:25:12
Done.
| |
| 249 // or attempting a command line login, login with a stub user. | |
| 250 if (!base::chromeos::IsRunningOnChromeOS() && | |
| 251 !parsed_command_line().HasSwitch(switches::kLoginManager) && | |
| 252 !parsed_command_line().HasSwitch(switches::kLoginUser) && | |
| 253 !parsed_command_line().HasSwitch(switches::kGuestSession)) { | |
| 254 singleton_command_line->AppendSwitchASCII(switches::kLoginUser, | |
| 255 kStubUsername); | |
| 256 if (!parsed_command_line().HasSwitch(switches::kLoginProfile)) { | |
| 257 singleton_command_line->AppendSwitchASCII( | |
| 258 switches::kLoginProfile, ProfileManager::kTestUserProfile); | |
| 259 } | |
| 260 LOG(INFO) << "Running as stub user with profile dir: " | |
| 261 << singleton_command_line->GetSwitchValuePath( | |
| 262 switches::kLoginProfile).value(); | |
| 263 } | |
| 264 | |
| 240 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); | 265 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); |
| 241 } | 266 } |
| 242 | 267 |
| 243 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { | 268 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { |
| 244 // Initialize CrosLibrary only for the browser, unless running tests | 269 // Initialize CrosLibrary only for the browser, unless running tests |
| 245 // (which do their own CrosLibrary setup). | 270 // (which do their own CrosLibrary setup). |
| 246 if (!parameters().ui_task) { | 271 if (!parameters().ui_task) { |
| 247 bool use_stub = parameters().command_line.HasSwitch(switches::kStubCros); | 272 bool use_stub = parameters().command_line.HasSwitch(switches::kStubCros); |
| 248 chromeos::CrosLibrary::Initialize(use_stub); | 273 chromeos::CrosLibrary::Initialize(use_stub); |
| 249 } | 274 } |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 LOG(WARNING) << "low_mem: Part of '100MB' experiment"; | 581 LOG(WARNING) << "low_mem: Part of '100MB' experiment"; |
| 557 chromeos::LowMemoryObserver::SetLowMemoryMargin(100); | 582 chromeos::LowMemoryObserver::SetLowMemoryMargin(100); |
| 558 } else if (trial->group() == margin_200mb) { | 583 } else if (trial->group() == margin_200mb) { |
| 559 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; | 584 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; |
| 560 chromeos::LowMemoryObserver::SetLowMemoryMargin(200); | 585 chromeos::LowMemoryObserver::SetLowMemoryMargin(200); |
| 561 } else { | 586 } else { |
| 562 LOG(WARNING) << "low_mem: Part of 'default' experiment"; | 587 LOG(WARNING) << "low_mem: Part of 'default' experiment"; |
| 563 } | 588 } |
| 564 } | 589 } |
| 565 } | 590 } |
| OLD | NEW |