| 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/ui/ash/app_sync_ui_state.h" | 5 #include "chrome/browser/ui/ash/app_sync_ui_state.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/pending_extension_manager.h" | 9 #include "chrome/browser/extensions/pending_extension_manager.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/sync/profile_sync_service_factory.h" | 11 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 12 #include "chrome/browser/ui/ash/app_sync_ui_state_factory.h" | 12 #include "chrome/browser/ui/ash/app_sync_ui_state_factory.h" |
| 13 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h" | 13 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h" |
| 14 #include "components/browser_sync/browser/profile_sync_service.h" | 14 #include "components/browser_sync/browser/profile_sync_service.h" |
| 15 #include "components/prefs/pref_service.h" | 15 #include "components/prefs/pref_service.h" |
| 16 #include "components/user_manager/user_manager.h" |
| 16 #include "extensions/browser/extension_registry.h" | 17 #include "extensions/browser/extension_registry.h" |
| 17 #include "extensions/browser/extension_system.h" | 18 #include "extensions/browser/extension_system.h" |
| 18 | 19 |
| 19 #if defined(OS_CHROMEOS) | |
| 20 #include "components/user_manager/user_manager.h" | |
| 21 #endif | |
| 22 | |
| 23 namespace { | 20 namespace { |
| 24 | 21 |
| 25 // Max loading animation time in milliseconds. | 22 // Max loading animation time in milliseconds. |
| 26 const int kMaxSyncingTimeMs = 60 * 1000; | 23 const int kMaxSyncingTimeMs = 60 * 1000; |
| 27 | 24 |
| 28 } // namespace | 25 } // namespace |
| 29 | 26 |
| 30 // static | 27 // static |
| 31 AppSyncUIState* AppSyncUIState::Get(Profile* profile) { | 28 AppSyncUIState* AppSyncUIState::Get(Profile* profile) { |
| 32 return AppSyncUIStateFactory::GetForProfile(profile); | 29 return AppSyncUIStateFactory::GetForProfile(profile); |
| 33 } | 30 } |
| 34 | 31 |
| 35 // static | 32 // static |
| 36 bool AppSyncUIState::ShouldObserveAppSyncForProfile(Profile* profile) { | 33 bool AppSyncUIState::ShouldObserveAppSyncForProfile(Profile* profile) { |
| 37 #if defined(OS_CHROMEOS) | |
| 38 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) | 34 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) |
| 39 return false; | 35 return false; |
| 40 | 36 |
| 41 if (!profile || profile->IsOffTheRecord()) | 37 if (!profile || profile->IsOffTheRecord()) |
| 42 return false; | 38 return false; |
| 43 | 39 |
| 44 if (!ProfileSyncServiceFactory::HasProfileSyncService(profile)) | 40 if (!ProfileSyncServiceFactory::HasProfileSyncService(profile)) |
| 45 return false; | 41 return false; |
| 46 | 42 |
| 47 return profile->IsNewProfile(); | 43 return profile->IsNewProfile(); |
| 48 #else | |
| 49 return false; | |
| 50 #endif | |
| 51 } | 44 } |
| 52 | 45 |
| 53 AppSyncUIState::AppSyncUIState(Profile* profile) | 46 AppSyncUIState::AppSyncUIState(Profile* profile) |
| 54 : profile_(profile), | 47 : profile_(profile), |
| 55 sync_service_(NULL), | 48 sync_service_(NULL), |
| 56 status_(STATUS_NORMAL), | 49 status_(STATUS_NORMAL), |
| 57 extension_registry_(NULL) { | 50 extension_registry_(NULL) { |
| 58 StartObserving(); | 51 StartObserving(); |
| 59 } | 52 } |
| 60 | 53 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 135 |
| 143 void AppSyncUIState::OnStateChanged() { | 136 void AppSyncUIState::OnStateChanged() { |
| 144 DCHECK(sync_service_); | 137 DCHECK(sync_service_); |
| 145 CheckAppSync(); | 138 CheckAppSync(); |
| 146 } | 139 } |
| 147 | 140 |
| 148 void AppSyncUIState::OnExtensionLoaded(content::BrowserContext* browser_context, | 141 void AppSyncUIState::OnExtensionLoaded(content::BrowserContext* browser_context, |
| 149 const extensions::Extension* extension) { | 142 const extensions::Extension* extension) { |
| 150 CheckAppSync(); | 143 CheckAppSync(); |
| 151 } | 144 } |
| OLD | NEW |