| 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/profile_startup.h" | 5 #include "chrome/browser/chromeos/profile_startup.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | |
| 8 #include "base/command_line.h" | |
| 9 #include "chrome/browser/chromeos/cros/cros_library.h" | 7 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 10 #include "chrome/browser/chromeos/cros/network_library.h" | 8 #include "chrome/browser/chromeos/cros/network_library.h" |
| 11 #include "chrome/browser/chromeos/customization_document.h" | 9 #include "chrome/browser/chromeos/customization_document.h" |
| 12 #include "chrome/browser/chromeos/enterprise_extension_observer.h" | 10 #include "chrome/browser/chromeos/enterprise_extension_observer.h" |
| 13 #include "chrome/browser/chromeos/gview_request_interceptor.h" | 11 #include "chrome/browser/chromeos/gview_request_interceptor.h" |
| 14 #include "chrome/browser/chromeos/network_message_observer.h" | 12 #include "chrome/browser/chromeos/network_message_observer.h" |
| 15 #include "chrome/browser/chromeos/power/low_battery_observer.h" | |
| 16 #include "chrome/browser/chromeos/sms_observer.h" | 13 #include "chrome/browser/chromeos/sms_observer.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
| 19 | 16 |
| 20 namespace chromeos { | 17 namespace chromeos { |
| 21 | 18 |
| 22 // TODO(beng): It is very fishy that any of these services need to be tied to | 19 // TODO(beng): It is very fishy that any of these services need to be tied to |
| 23 // a browser profile. This dependency should be severed and this | 20 // a browser profile. This dependency should be severed and this |
| 24 // init moved earlier in startup. | 21 // init moved earlier in startup. |
| 25 void ProfileStartup(Profile* profile, bool process_startup) { | 22 void ProfileStartup(Profile* profile, bool process_startup) { |
| 26 // Initialize Chrome OS preferences like touch pad sensitivity. For the | 23 // Initialize Chrome OS preferences like touch pad sensitivity. For the |
| 27 // preferences to work in the guest mode, the initialization has to be | 24 // preferences to work in the guest mode, the initialization has to be |
| 28 // done after |profile| is switched to the incognito profile (which | 25 // done after |profile| is switched to the incognito profile (which |
| 29 // is actually GuestSessionProfile in the guest mode). See the | 26 // is actually GuestSessionProfile in the guest mode). See the |
| 30 // GetOffTheRecordProfile() call above. | 27 // GetOffTheRecordProfile() call above. |
| 31 profile->InitChromeOSPreferences(); | 28 profile->InitChromeOSPreferences(); |
| 32 | 29 |
| 33 if (process_startup) { | 30 if (process_startup) { |
| 34 // These observers are singletons. They are never deleted but the pointers | 31 // These observers are singletons. They are never deleted but the pointers |
| 35 // are kept in a statics so that they are not reported as leaks. | 32 // are kept in a statics so that they are not reported as leaks. |
| 36 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 37 ash::switches::kAshNotifyDisabled)) { | |
| 38 static chromeos::LowBatteryObserver* low_battery_observer = | |
| 39 new chromeos::LowBatteryObserver(profile); | |
| 40 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( | |
| 41 low_battery_observer); | |
| 42 } | |
| 43 | |
| 44 static chromeos::NetworkMessageObserver* network_message_observer = | 33 static chromeos::NetworkMessageObserver* network_message_observer = |
| 45 new chromeos::NetworkMessageObserver(profile); | 34 new chromeos::NetworkMessageObserver(profile); |
| 46 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> | 35 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> |
| 47 AddNetworkManagerObserver(network_message_observer); | 36 AddNetworkManagerObserver(network_message_observer); |
| 48 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> | 37 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> |
| 49 AddCellularDataPlanObserver(network_message_observer); | 38 AddCellularDataPlanObserver(network_message_observer); |
| 50 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> | 39 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> |
| 51 AddUserActionObserver(network_message_observer); | 40 AddUserActionObserver(network_message_observer); |
| 52 | 41 |
| 53 static chromeos::SmsObserver* sms_observer = | 42 static chromeos::SmsObserver* sms_observer = |
| 54 new chromeos::SmsObserver(profile); | 43 new chromeos::SmsObserver(profile); |
| 55 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> | 44 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> |
| 56 AddNetworkManagerObserver(sms_observer); | 45 AddNetworkManagerObserver(sms_observer); |
| 57 | 46 |
| 58 profile->SetupChromeOSEnterpriseExtensionObserver(); | 47 profile->SetupChromeOSEnterpriseExtensionObserver(); |
| 59 } | 48 } |
| 60 } | 49 } |
| 61 | 50 |
| 62 } // namespace chromeos | 51 } // namespace chromeos |
| OLD | NEW |