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

Unified Diff: chrome/browser/chromeos/system/ash_system_tray_delegate.cc

Issue 10854160: Fixing gdata updates in the system tray. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/system/ash_system_tray_delegate.cc
diff --git a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
index a64b24f0548bf4c90bf306525a798e29a4066693..ef9bca901279bce16c86aa11d681538cd466581a 100644
--- a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
+++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
@@ -208,6 +208,9 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
registrar_.Add(this,
chrome::NOTIFICATION_PROFILE_CREATED,
content::NotificationService::AllSources());
+ registrar_.Add(this,
+ chrome::NOTIFICATION_LOGIN_USER_CHANGED,
+ content::NotificationService::AllSources());
accessibility_enabled_.Init(prefs::kSpokenFeedbackEnabled,
g_browser_process->local_state(), this);
@@ -237,14 +240,10 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
bluetooth_adapter_->RemoveObserver(this);
// Stop observing gdata operations.
- Profile* profile = ProfileManager::GetDefaultProfile();
- if (gdata::util::IsGDataAvailable(profile)) {
- GDataSystemService* system_service =
- GDataSystemServiceFactory::FindForProfile(profile);
- if (system_service) {
- system_service->docs_service()->operation_registry()->
- RemoveObserver(this);
- }
+ GDataSystemService* system_service = FindGDataSystemService();
+ if (system_service) {
+ system_service->docs_service()->operation_registry()->
+ RemoveObserver(this);
}
}
@@ -451,12 +450,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
}
virtual void CancelDriveOperation(const FilePath& file_path) OVERRIDE {
- Profile* profile = ProfileManager::GetDefaultProfile();
- if (!gdata::util::IsGDataAvailable(profile))
- return;
-
- GDataSystemService* system_service =
- GDataSystemServiceFactory::FindForProfile(profile);
+ GDataSystemService* system_service = FindGDataSystemService();
if (!system_service)
return;
@@ -466,12 +460,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
virtual void GetDriveOperationStatusList(
ash::DriveOperationStatusList* list) OVERRIDE {
- Profile* profile = ProfileManager::GetDefaultProfile();
- if (!gdata::util::IsGDataAvailable(profile))
- return;
-
- GDataSystemService* system_service =
- GDataSystemServiceFactory::FindForProfile(profile);
+ GDataSystemService* system_service = FindGDataSystemService();
if (!system_service)
return;
@@ -734,15 +723,14 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
UpdateClockType(profile->GetPrefs());
search_key_mapped_to_ =
profile->GetPrefs()->GetInteger(prefs::kLanguageXkbRemapSearchKeyTo);
+ }
- if (gdata::util::IsGDataAvailable(profile)) {
- GDataSystemService* system_service =
- GDataSystemServiceFactory::FindForProfile(profile);
- if (!system_service)
- return;
+ void ObserveGDataUpdates() {
+ GDataSystemService* system_service = FindGDataSystemService();
+ if (!system_service)
+ return;
- system_service->docs_service()->operation_registry()->AddObserver(this);
- }
+ system_service->docs_service()->operation_registry()->AddObserver(this);
}
void UpdateClockType(PrefService* service) {
@@ -1037,6 +1025,11 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
}
break;
}
+ case chrome::NOTIFICATION_LOGIN_USER_CHANGED: {
+ // GData system service exists by the time if enabled.
+ ObserveGDataUpdates();
+ break;
+ }
case chrome::NOTIFICATION_PREF_CHANGED: {
std::string pref = *content::Details<std::string>(details).ptr();
PrefService* service = content::Source<PrefService>(source).ptr();
@@ -1128,12 +1121,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
// status in UI in cases when there are no new changes coming (i.e. when the
// last set of transfer operations completed).
void RecheckGDataOperations() {
- Profile* profile = ProfileManager::GetDefaultProfile();
- if (!gdata::util::IsGDataAvailable(profile))
- return;
-
- GDataSystemService* system_service =
- GDataSystemServiceFactory::FindForProfile(profile);
+ GDataSystemService* system_service = FindGDataSystemService();
if (!system_service)
return;
@@ -1141,6 +1129,13 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
GetProgressStatusList());
}
+ GDataSystemService* FindGDataSystemService() {
+ Profile* profile = ProfileManager::GetDefaultProfile();
+ if (!gdata::util::IsGDataAvailable(profile))
+ return NULL;
+ return GDataSystemServiceFactory::FindForProfile(profile);
+ }
+
// Overridden from system::TimezoneSettings::Observer.
virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE {
NotifyRefreshClock();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698