OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser_main_chromeos.h" | 5 #include "chrome/browser/chromeos/browser_main_chromeos.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/chromeos/boot_times_loader.h" | 10 #include "chrome/browser/chromeos/boot_times_loader.h" |
11 #include "chrome/browser/chromeos/cros/cros_library.h" | 11 #include "chrome/browser/chromeos/cros/cros_library.h" |
12 #include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h" | 12 #include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h" |
| 13 #include "chrome/browser/defaults.h" |
13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
14 #include "content/common/main_function_params.h" | 15 #include "content/common/main_function_params.h" |
15 #include "net/base/network_change_notifier.h" | 16 #include "net/base/network_change_notifier.h" |
16 | 17 |
17 #include <gtk/gtk.h> | 18 #include <gtk/gtk.h> |
18 | 19 |
19 class MessageLoopObserver : public MessageLoopForUI::Observer { | 20 class MessageLoopObserver : public MessageLoopForUI::Observer { |
20 virtual void WillProcessEvent(GdkEvent* event) { | 21 virtual void WillProcessEvent(GdkEvent* event) { |
21 // On chromeos we want to map Alt-left click to right click. | 22 // On chromeos we want to map Alt-left click to right click. |
22 // This code only changes presses and releases. We could decide to also | 23 // This code only changes presses and releases. We could decide to also |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) | 57 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) |
57 chromeos::CrosLibrary::Shutdown(); | 58 chromeos::CrosLibrary::Shutdown(); |
58 | 59 |
59 // To be precise, logout (browser shutdown) is not yet done, but the | 60 // To be precise, logout (browser shutdown) is not yet done, but the |
60 // remaining work is negligible, hence we say LogoutDone here. | 61 // remaining work is negligible, hence we say LogoutDone here. |
61 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 62 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
62 false); | 63 false); |
63 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 64 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
64 } | 65 } |
65 | 66 |
| 67 void BrowserMainPartsChromeos::PreEarlyInitialization() { |
| 68 BrowserMainPartsGtk::PreEarlyInitialization(); |
| 69 if (parsed_command_line().HasSwitch(switches::kGuestSession)) { |
| 70 // Disable sync and extensions if we're in "browse without sign-in" mode. |
| 71 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); |
| 72 singleton_command_line->AppendSwitch(switches::kDisableSync); |
| 73 singleton_command_line->AppendSwitch(switches::kDisableExtensions); |
| 74 browser_defaults::bookmarks_enabled = false; |
| 75 } |
| 76 } |
| 77 |
66 void BrowserMainPartsChromeos::PreMainMessageLoopStart() { | 78 void BrowserMainPartsChromeos::PreMainMessageLoopStart() { |
| 79 BrowserMainPartsGtk::PreMainMessageLoopStart(); |
67 // Initialize CrosLibrary only for the browser, unless running tests | 80 // Initialize CrosLibrary only for the browser, unless running tests |
68 // (which do their own CrosLibrary setup). | 81 // (which do their own CrosLibrary setup). |
69 if (!parameters().ui_task) { | 82 if (!parameters().ui_task) { |
70 bool use_stub = parameters().command_line_.HasSwitch(switches::kStubCros); | 83 bool use_stub = parameters().command_line_.HasSwitch(switches::kStubCros); |
71 chromeos::CrosLibrary::Initialize(use_stub); | 84 chromeos::CrosLibrary::Initialize(use_stub); |
72 } | 85 } |
73 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific | 86 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific |
74 // implementation. | 87 // implementation. |
75 net::NetworkChangeNotifier::SetFactory( | 88 net::NetworkChangeNotifier::SetFactory( |
76 new chromeos::CrosNetworkChangeNotifierFactory()); | 89 new chromeos::CrosNetworkChangeNotifierFactory()); |
77 } | 90 } |
78 | 91 |
79 void BrowserMainPartsChromeos::PostMainMessageLoopStart() { | 92 void BrowserMainPartsChromeos::PostMainMessageLoopStart() { |
80 BrowserMainPartsPosix::PostMainMessageLoopStart(); | 93 BrowserMainPartsPosix::PostMainMessageLoopStart(); |
81 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 94 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
82 message_loop->AddObserver(g_message_loop_observer.Pointer()); | 95 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
83 } | 96 } |
OLD | NEW |