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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 virtual void DidProcessEvent(GdkEvent* event) { | 62 virtual void DidProcessEvent(GdkEvent* event) { |
63 } | 63 } |
64 #endif | 64 #endif |
65 }; | 65 }; |
66 | 66 |
67 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer( | 67 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer( |
68 base::LINKER_INITIALIZED); | 68 base::LINKER_INITIALIZED); |
69 | 69 |
70 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( | 70 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( |
71 const MainFunctionParams& parameters) | 71 const MainFunctionParams& parameters) |
72 : ChromeBrowserMainPartsBase(parameters) { | 72 : ChromeBrowserMainPartsLinux(parameters) { |
73 } | 73 } |
74 | 74 |
75 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { | 75 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { |
76 // We should remove observers attached to D-Bus clients before | 76 // We should remove observers attached to D-Bus clients before |
77 // DBusThreadManager is shut down. | 77 // DBusThreadManager is shut down. |
78 if (brightness_observer_.get()) { | 78 if (brightness_observer_.get()) { |
79 chromeos::DBusThreadManager::Get()->power_manager_client()->RemoveObserver( | 79 chromeos::DBusThreadManager::Get()->power_manager_client()->RemoveObserver( |
80 brightness_observer_.get()); | 80 brightness_observer_.get()); |
81 } | 81 } |
82 | 82 |
83 chromeos::DBusThreadManager::Shutdown(); | 83 chromeos::DBusThreadManager::Shutdown(); |
84 | 84 |
85 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) | 85 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) |
86 chromeos::CrosLibrary::Shutdown(); | 86 chromeos::CrosLibrary::Shutdown(); |
87 | 87 |
88 // To be precise, logout (browser shutdown) is not yet done, but the | 88 // To be precise, logout (browser shutdown) is not yet done, but the |
89 // remaining work is negligible, hence we say LogoutDone here. | 89 // remaining work is negligible, hence we say LogoutDone here. |
90 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 90 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
91 false); | 91 false); |
92 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 92 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
93 } | 93 } |
94 | 94 |
95 void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() { | 95 void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() { |
96 ChromeBrowserMainPartsBase::PreEarlyInitialization(); | 96 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); |
97 if (parsed_command_line().HasSwitch(switches::kGuestSession)) { | 97 if (parsed_command_line().HasSwitch(switches::kGuestSession)) { |
98 // Disable sync and extensions if we're in "browse without sign-in" mode. | 98 // Disable sync and extensions if we're in "browse without sign-in" mode. |
99 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); | 99 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); |
100 singleton_command_line->AppendSwitch(switches::kDisableSync); | 100 singleton_command_line->AppendSwitch(switches::kDisableSync); |
101 singleton_command_line->AppendSwitch(switches::kDisableExtensions); | 101 singleton_command_line->AppendSwitch(switches::kDisableExtensions); |
102 browser_defaults::bookmarks_enabled = false; | 102 browser_defaults::bookmarks_enabled = false; |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { | 106 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { |
107 ChromeBrowserMainPartsBase::PreMainMessageLoopStart(); | 107 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); |
108 // Initialize CrosLibrary only for the browser, unless running tests | 108 // Initialize CrosLibrary only for the browser, unless running tests |
109 // (which do their own CrosLibrary setup). | 109 // (which do their own CrosLibrary setup). |
110 if (!parameters().ui_task) { | 110 if (!parameters().ui_task) { |
111 bool use_stub = parameters().command_line_.HasSwitch(switches::kStubCros); | 111 bool use_stub = parameters().command_line_.HasSwitch(switches::kStubCros); |
112 chromeos::CrosLibrary::Initialize(use_stub); | 112 chromeos::CrosLibrary::Initialize(use_stub); |
113 } | 113 } |
114 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific | 114 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific |
115 // implementation. | 115 // implementation. |
116 net::NetworkChangeNotifier::SetFactory( | 116 net::NetworkChangeNotifier::SetFactory( |
117 new chromeos::CrosNetworkChangeNotifierFactory()); | 117 new chromeos::CrosNetworkChangeNotifierFactory()); |
118 } | 118 } |
119 | 119 |
120 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { | 120 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { |
121 // FILE thread is created in ChromeBrowserMainParts::PreMainMessageLoopRun(). | 121 // FILE thread is created in ChromeBrowserMainParts::PreMainMessageLoopRun(). |
122 ChromeBrowserMainPartsBase::PreMainMessageLoopRun(); | 122 ChromeBrowserMainPartsLinux::PreMainMessageLoopRun(); |
123 // Get the statistics provider instance here to start loading statistcs | 123 // Get the statistics provider instance here to start loading statistcs |
124 // on the background FILE thread. | 124 // on the background FILE thread. |
125 chromeos::system::StatisticsProvider::GetInstance(); | 125 chromeos::system::StatisticsProvider::GetInstance(); |
126 } | 126 } |
127 | 127 |
128 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { | 128 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { |
129 ChromeBrowserMainPartsPosix::PostMainMessageLoopStart(); | 129 ChromeBrowserMainPartsPosix::PostMainMessageLoopStart(); |
130 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 130 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
131 message_loop->AddObserver(g_message_loop_observer.Pointer()); | 131 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
132 | 132 |
133 // Initialize DBusThreadManager for the browser. This must be done after | 133 // Initialize DBusThreadManager for the browser. This must be done after |
134 // the main message loop is started, as it uses the message loop. | 134 // the main message loop is started, as it uses the message loop. |
135 chromeos::DBusThreadManager::Initialize(); | 135 chromeos::DBusThreadManager::Initialize(); |
136 | 136 |
137 // Initialize the brightness observer so that we'll display an onscreen | 137 // Initialize the brightness observer so that we'll display an onscreen |
138 // indication of brightness changes during login. | 138 // indication of brightness changes during login. |
139 brightness_observer_.reset(new chromeos::BrightnessObserver()); | 139 brightness_observer_.reset(new chromeos::BrightnessObserver()); |
140 chromeos::DBusThreadManager::Get()->power_manager_client()->AddObserver( | 140 chromeos::DBusThreadManager::Get()->power_manager_client()->AddObserver( |
141 brightness_observer_.get()); | 141 brightness_observer_.get()); |
142 } | 142 } |
OLD | NEW |