| 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 #ifndef CHROME_BROWSER_UI_ASH_APP_SYNC_UI_STATE_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_APP_SYNC_UI_STATE_H_ |
| 6 #define CHROME_BROWSER_UI_ASH_APP_SYNC_UI_STATE_H_ | 6 #define CHROME_BROWSER_UI_ASH_APP_SYNC_UI_STATE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 // Returns the instance for the given |profile|. It's a convenience wrapper | 40 // Returns the instance for the given |profile|. It's a convenience wrapper |
| 41 // of AppSyncUIStateFactory::GetForProfile. Note this function returns | 41 // of AppSyncUIStateFactory::GetForProfile. Note this function returns |
| 42 // NULL if ShouldObserveAppSyncForProfile returns false for |profile|. | 42 // NULL if ShouldObserveAppSyncForProfile returns false for |profile|. |
| 43 static AppSyncUIState* Get(Profile* profile); | 43 static AppSyncUIState* Get(Profile* profile); |
| 44 | 44 |
| 45 // Returns true if |profile| should be watched for app syncing. | 45 // Returns true if |profile| should be watched for app syncing. |
| 46 static bool ShouldObserveAppSyncForProfile(Profile* profile); | 46 static bool ShouldObserveAppSyncForProfile(Profile* profile); |
| 47 | 47 |
| 48 explicit AppSyncUIState(Profile* profile); | 48 explicit AppSyncUIState(Profile* profile); |
| 49 virtual ~AppSyncUIState(); | 49 ~AppSyncUIState() override; |
| 50 | 50 |
| 51 void AddObserver(AppSyncUIStateObserver* observer); | 51 void AddObserver(AppSyncUIStateObserver* observer); |
| 52 void RemoveObserver(AppSyncUIStateObserver* observer); | 52 void RemoveObserver(AppSyncUIStateObserver* observer); |
| 53 | 53 |
| 54 Status status() const { return status_; } | 54 Status status() const { return status_; } |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 void StartObserving(); | 57 void StartObserving(); |
| 58 void StopObserving(); | 58 void StopObserving(); |
| 59 | 59 |
| 60 void SetStatus(Status status); | 60 void SetStatus(Status status); |
| 61 | 61 |
| 62 // Checks and sets app sync status. If sync has not setup, do nothing. If sync | 62 // Checks and sets app sync status. If sync has not setup, do nothing. If sync |
| 63 // is completed and there is no pending synced extension install, sets | 63 // is completed and there is no pending synced extension install, sets |
| 64 // STATUS_SYNCING. Otherwise, sets STATUS_NORMAL. | 64 // STATUS_SYNCING. Otherwise, sets STATUS_NORMAL. |
| 65 void CheckAppSync(); | 65 void CheckAppSync(); |
| 66 | 66 |
| 67 // Invoked when |max_syncing_status_timer_| fires. | 67 // Invoked when |max_syncing_status_timer_| fires. |
| 68 void OnMaxSyncingTimer(); | 68 void OnMaxSyncingTimer(); |
| 69 | 69 |
| 70 // ProfileSyncServiceObserver overrides: | 70 // ProfileSyncServiceObserver overrides: |
| 71 virtual void OnStateChanged() override; | 71 void OnStateChanged() override; |
| 72 | 72 |
| 73 // extensions::ExtensionRegistryObserver overrides: | 73 // extensions::ExtensionRegistryObserver overrides: |
| 74 virtual void OnExtensionLoaded( | 74 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 75 content::BrowserContext* browser_context, | 75 const extensions::Extension* extension) override; |
| 76 const extensions::Extension* extension) override; | |
| 77 | 76 |
| 78 Profile* profile_; | 77 Profile* profile_; |
| 79 ProfileSyncService* sync_service_; | 78 ProfileSyncService* sync_service_; |
| 80 | 79 |
| 81 // Timer to limit how much time STATUS_SYNCING is allowed. | 80 // Timer to limit how much time STATUS_SYNCING is allowed. |
| 82 base::OneShotTimer<AppSyncUIState> max_syncing_status_timer_; | 81 base::OneShotTimer<AppSyncUIState> max_syncing_status_timer_; |
| 83 | 82 |
| 84 Status status_; | 83 Status status_; |
| 85 ObserverList<AppSyncUIStateObserver> observers_; | 84 ObserverList<AppSyncUIStateObserver> observers_; |
| 86 | 85 |
| 87 extensions::ExtensionRegistry* extension_registry_; | 86 extensions::ExtensionRegistry* extension_registry_; |
| 88 | 87 |
| 89 DISALLOW_COPY_AND_ASSIGN(AppSyncUIState); | 88 DISALLOW_COPY_AND_ASSIGN(AppSyncUIState); |
| 90 }; | 89 }; |
| 91 | 90 |
| 92 #endif // CHROME_BROWSER_UI_ASH_APP_SYNC_UI_STATE_H_ | 91 #endif // CHROME_BROWSER_UI_ASH_APP_SYNC_UI_STATE_H_ |
| OLD | NEW |