Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: chrome/browser/chromeos/system/ash_system_tray_delegate.cc

Issue 15695010: Add ProfileManager::AllowGetDefaultProfile() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/system/ash_system_tray_delegate.h" 5 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 search_key_mapped_to_(input_method::kSearchKey), 243 search_key_mapped_to_(input_method::kSearchKey),
244 screen_locked_(false), 244 screen_locked_(false),
245 have_session_start_time_(false), 245 have_session_start_time_(false),
246 have_session_length_limit_(false), 246 have_session_length_limit_(false),
247 data_promo_notification_(new DataPromoNotification()), 247 data_promo_notification_(new DataPromoNotification()),
248 cellular_activating_(false), 248 cellular_activating_(false),
249 cellular_out_of_credits_(false), 249 cellular_out_of_credits_(false),
250 volume_control_delegate_(new VolumeController()) { 250 volume_control_delegate_(new VolumeController()) {
251 // Register notifications on construction so that events such as 251 // Register notifications on construction so that events such as
252 // PROFILE_CREATED do not get missed if they happen before Initialize(). 252 // PROFILE_CREATED do not get missed if they happen before Initialize().
253 registrar_.Add(this, 253 registrar_.reset(new content::NotificationRegistrar);
254 registrar_->Add(this,
254 chrome::NOTIFICATION_UPGRADE_RECOMMENDED, 255 chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
255 content::NotificationService::AllSources()); 256 content::NotificationService::AllSources());
256 registrar_.Add(this, 257 registrar_->Add(this,
257 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 258 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
258 content::NotificationService::AllSources()); 259 content::NotificationService::AllSources());
259 if (GetUserLoginStatus() == ash::user::LOGGED_IN_NONE) { 260 if (GetUserLoginStatus() == ash::user::LOGGED_IN_NONE) {
260 registrar_.Add(this, 261 registrar_->Add(this,
261 chrome::NOTIFICATION_SESSION_STARTED, 262 chrome::NOTIFICATION_SESSION_STARTED,
262 content::NotificationService::AllSources()); 263 content::NotificationService::AllSources());
263 } 264 }
264 registrar_.Add(this, 265 registrar_->Add(this,
265 chrome::NOTIFICATION_PROFILE_CREATED, 266 chrome::NOTIFICATION_PROFILE_CREATED,
266 content::NotificationService::AllSources()); 267 content::NotificationService::AllSources());
267 registrar_.Add(this, 268 registrar_->Add(this,
268 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 269 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
269 content::NotificationService::AllSources()); 270 content::NotificationService::AllSources());
270 registrar_.Add( 271 registrar_->Add(
271 this, 272 this,
272 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER, 273 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER,
273 content::NotificationService::AllSources()); 274 content::NotificationService::AllSources());
274 registrar_.Add( 275 registrar_->Add(
275 this, 276 this,
276 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, 277 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK,
277 content::NotificationService::AllSources()); 278 content::NotificationService::AllSources());
278 registrar_.Add( 279 registrar_->Add(
279 this, 280 this,
280 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, 281 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE,
281 content::NotificationService::AllSources()); 282 content::NotificationService::AllSources());
282 } 283 }
283 284
284 virtual void Initialize() OVERRIDE { 285 virtual void Initialize() OVERRIDE {
285 if (!ash::switches::UseNewAudioHandler()) { 286 if (!ash::switches::UseNewAudioHandler()) {
286 AudioHandler::GetInstance()->AddVolumeObserver(this); 287 AudioHandler::GetInstance()->AddVolumeObserver(this);
287 } 288 }
288 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); 289 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 policy::BrowserPolicyConnector* policy_connector = 333 policy::BrowserPolicyConnector* policy_connector =
333 g_browser_process->browser_policy_connector(); 334 g_browser_process->browser_policy_connector();
334 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 335 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
335 policy_connector->GetDeviceCloudPolicyManager(); 336 policy_connector->GetDeviceCloudPolicyManager();
336 if (policy_manager) 337 if (policy_manager)
337 policy_manager->core()->store()->AddObserver(this); 338 policy_manager->core()->store()->AddObserver(this);
338 UpdateEnterpriseDomain(); 339 UpdateEnterpriseDomain();
339 } 340 }
340 341
341 virtual ~SystemTrayDelegate() { 342 virtual ~SystemTrayDelegate() {
343 // Unregister content notifications befure destroying any components.
344 registrar_.reset();
345
342 if (!ash::switches::UseNewAudioHandler() && AudioHandler::GetInstance()) { 346 if (!ash::switches::UseNewAudioHandler() && AudioHandler::GetInstance()) {
343 AudioHandler::GetInstance()->RemoveVolumeObserver(this); 347 AudioHandler::GetInstance()->RemoveVolumeObserver(this);
344 } 348 }
345 349
346 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); 350 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this);
347 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); 351 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this);
348 DBusThreadManager::Get()->GetSystemClockClient()->RemoveObserver(this); 352 DBusThreadManager::Get()->GetSystemClockClient()->RemoveObserver(this);
349 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); 353 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
350 if (crosnet) 354 if (crosnet)
351 crosnet->RemoveNetworkManagerObserver(this); 355 crosnet->RemoveNetworkManagerObserver(this);
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 } 1069 }
1066 break; 1070 break;
1067 } 1071 }
1068 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: { 1072 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: {
1069 // GData system service exists by the time if enabled. 1073 // GData system service exists by the time if enabled.
1070 ObserveGDataUpdates(); 1074 ObserveGDataUpdates();
1071 break; 1075 break;
1072 } 1076 }
1073 case chrome::NOTIFICATION_PROFILE_CREATED: { 1077 case chrome::NOTIFICATION_PROFILE_CREATED: {
1074 SetProfile(content::Source<Profile>(source).ptr()); 1078 SetProfile(content::Source<Profile>(source).ptr());
1075 registrar_.Remove(this, 1079 registrar_->Remove(this,
1076 chrome::NOTIFICATION_PROFILE_CREATED, 1080 chrome::NOTIFICATION_PROFILE_CREATED,
1077 content::NotificationService::AllSources()); 1081 content::NotificationService::AllSources());
1078 break; 1082 break;
1079 } 1083 }
1080 case chrome::NOTIFICATION_SESSION_STARTED: { 1084 case chrome::NOTIFICATION_SESSION_STARTED: {
1081 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( 1085 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(
1082 GetUserLoginStatus()); 1086 GetUserLoginStatus());
1083 SetProfile(ProfileManager::GetDefaultProfile()); 1087 SetProfile(ProfileManager::GetDefaultProfile());
1084 break; 1088 break;
1085 } 1089 }
1086 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK: 1090 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK:
1087 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE: 1091 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE:
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 ash::NetworkObserver::MESSAGE_DATA_PROMO, 1280 ash::NetworkObserver::MESSAGE_DATA_PROMO,
1277 type, 1281 type,
1278 l10n_util::GetStringUTF16(IDS_NETWORK_CELLULAR_ACTIVATED_TITLE), 1282 l10n_util::GetStringUTF16(IDS_NETWORK_CELLULAR_ACTIVATED_TITLE),
1279 l10n_util::GetStringFUTF16(IDS_NETWORK_CELLULAR_ACTIVATED, 1283 l10n_util::GetStringFUTF16(IDS_NETWORK_CELLULAR_ACTIVATED,
1280 UTF8ToUTF16((cellular->name()))), 1284 UTF8ToUTF16((cellular->name()))),
1281 std::vector<string16>()); 1285 std::vector<string16>());
1282 } 1286 }
1283 } 1287 }
1284 1288
1285 scoped_ptr<base::WeakPtrFactory<SystemTrayDelegate> > ui_weak_ptr_factory_; 1289 scoped_ptr<base::WeakPtrFactory<SystemTrayDelegate> > ui_weak_ptr_factory_;
1286 content::NotificationRegistrar registrar_; 1290 scoped_ptr<content::NotificationRegistrar> registrar_;
1287 PrefChangeRegistrar local_state_registrar_; 1291 PrefChangeRegistrar local_state_registrar_;
1288 scoped_ptr<PrefChangeRegistrar> user_pref_registrar_; 1292 scoped_ptr<PrefChangeRegistrar> user_pref_registrar_;
1289 std::string active_network_path_; 1293 std::string active_network_path_;
1290 base::HourClockType clock_type_; 1294 base::HourClockType clock_type_;
1291 int search_key_mapped_to_; 1295 int search_key_mapped_to_;
1292 bool screen_locked_; 1296 bool screen_locked_;
1293 bool have_session_start_time_; 1297 bool have_session_start_time_;
1294 base::TimeTicks session_start_time_; 1298 base::TimeTicks session_start_time_;
1295 bool have_session_length_limit_; 1299 bool have_session_length_limit_;
1296 base::TimeDelta session_length_limit_; 1300 base::TimeDelta session_length_limit_;
(...skipping 10 matching lines...) Expand all
1307 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); 1311 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate);
1308 }; 1312 };
1309 1313
1310 } // namespace 1314 } // namespace
1311 1315
1312 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1316 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1313 return new chromeos::SystemTrayDelegate(); 1317 return new chromeos::SystemTrayDelegate();
1314 } 1318 }
1315 1319
1316 } // namespace chromeos 1320 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698