| 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 real ChromeOS hardware (or under VM), and are not |
| 249 // showing the login manager or attempting a command line login, login with a |
| 250 // stub user. |
| 251 if (!base::chromeos::IsRunningOnChromeOS() && |
| 252 !parsed_command_line().HasSwitch(switches::kLoginManager) && |
| 253 !parsed_command_line().HasSwitch(switches::kLoginUser) && |
| 254 !parsed_command_line().HasSwitch(switches::kGuestSession)) { |
| 255 singleton_command_line->AppendSwitchASCII(switches::kLoginUser, |
| 256 kStubUsername); |
| 257 if (!parsed_command_line().HasSwitch(switches::kLoginProfile)) { |
| 258 singleton_command_line->AppendSwitchASCII( |
| 259 switches::kLoginProfile, ProfileManager::kTestUserProfile); |
| 260 } |
| 261 LOG(INFO) << "Running as stub user with profile dir: " |
| 262 << singleton_command_line->GetSwitchValuePath( |
| 263 switches::kLoginProfile).value(); |
| 264 } |
| 265 |
| 240 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); | 266 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); |
| 241 } | 267 } |
| 242 | 268 |
| 243 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { | 269 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { |
| 244 // Initialize CrosLibrary only for the browser, unless running tests | 270 // Initialize CrosLibrary only for the browser, unless running tests |
| 245 // (which do their own CrosLibrary setup). | 271 // (which do their own CrosLibrary setup). |
| 246 if (!parameters().ui_task) { | 272 if (!parameters().ui_task) { |
| 247 const bool use_stub = !base::chromeos::IsRunningOnChromeOS(); | 273 const bool use_stub = !base::chromeos::IsRunningOnChromeOS(); |
| 248 chromeos::CrosLibrary::Initialize(use_stub); | 274 chromeos::CrosLibrary::Initialize(use_stub); |
| 249 } | 275 } |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 LOG(WARNING) << "low_mem: Part of '100MB' experiment"; | 582 LOG(WARNING) << "low_mem: Part of '100MB' experiment"; |
| 557 chromeos::LowMemoryObserver::SetLowMemoryMargin(100); | 583 chromeos::LowMemoryObserver::SetLowMemoryMargin(100); |
| 558 } else if (trial->group() == margin_200mb) { | 584 } else if (trial->group() == margin_200mb) { |
| 559 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; | 585 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; |
| 560 chromeos::LowMemoryObserver::SetLowMemoryMargin(200); | 586 chromeos::LowMemoryObserver::SetLowMemoryMargin(200); |
| 561 } else { | 587 } else { |
| 562 LOG(WARNING) << "low_mem: Part of 'default' experiment"; | 588 LOG(WARNING) << "low_mem: Part of 'default' experiment"; |
| 563 } | 589 } |
| 564 } | 590 } |
| 565 } | 591 } |
| OLD | NEW |