| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/sync/profile_signin_confirmation_helper.h" | 5 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "extensions/common/extension_set.h" | 31 #include "extensions/common/extension_set.h" |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 const int kHistoryEntriesBeforeNewProfilePrompt = 10; | 36 const int kHistoryEntriesBeforeNewProfilePrompt = 10; |
| 37 | 37 |
| 38 // Determines whether a profile has any typed URLs in its history. | 38 // Determines whether a profile has any typed URLs in its history. |
| 39 class HasTypedURLsTask : public history::HistoryDBTask { | 39 class HasTypedURLsTask : public history::HistoryDBTask { |
| 40 public: | 40 public: |
| 41 HasTypedURLsTask(const base::Callback<void(bool)>& cb) | 41 explicit HasTypedURLsTask(const base::Callback<void(bool)>& cb) |
| 42 : has_typed_urls_(false), cb_(cb) { | 42 : has_typed_urls_(false), cb_(cb) { |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 45 virtual bool RunOnDBThread(history::HistoryBackend* backend, |
| 46 history::HistoryDatabase* db) OVERRIDE { | 46 history::HistoryDatabase* db) OVERRIDE { |
| 47 history::URLRows rows; | 47 history::URLRows rows; |
| 48 backend->GetAllTypedURLs(&rows); | 48 backend->GetAllTypedURLs(&rows); |
| 49 if (!rows.empty()) { | 49 if (!rows.empty()) { |
| 50 DVLOG(1) << "ProfileSigninConfirmationHelper: profile contains " | 50 DVLOG(1) << "ProfileSigninConfirmationHelper: profile contains " |
| 51 << rows.size() << " typed URLs"; | 51 << rows.size() << " typed URLs"; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 namespace ui { | 182 namespace ui { |
| 183 | 183 |
| 184 SkColor GetSigninConfirmationPromptBarColor(SkAlpha alpha) { | 184 SkColor GetSigninConfirmationPromptBarColor(SkAlpha alpha) { |
| 185 static const SkColor kBackgroundColor = | 185 static const SkColor kBackgroundColor = |
| 186 ui::NativeTheme::instance()->GetSystemColor( | 186 ui::NativeTheme::instance()->GetSystemColor( |
| 187 ui::NativeTheme::kColorId_DialogBackground); | 187 ui::NativeTheme::kColorId_DialogBackground); |
| 188 return color_utils::BlendTowardOppositeLuminance(kBackgroundColor, alpha); | 188 return color_utils::BlendTowardOppositeLuminance(kBackgroundColor, alpha); |
| 189 } | 189 } |
| 190 | 190 |
| 191 bool HasBeenShutdown(Profile* profile) { | 191 bool HasBeenShutdown(Profile* profile) { |
| 192 #if defined(OS_IOS) |
| 193 // This check is not useful on iOS: the browser can be shut down without |
| 194 // explicit user action (for example, in response to memory pressure), and |
| 195 // this should be invisible to the user. The desktop assumption that the |
| 196 // profile going through a restart indicates something about user intention |
| 197 // does not hold. We rely on the other profile dirtiness checks. |
| 198 return false; |
| 199 #else |
| 192 bool has_been_shutdown = !profile->IsNewProfile(); | 200 bool has_been_shutdown = !profile->IsNewProfile(); |
| 193 if (has_been_shutdown) | 201 if (has_been_shutdown) |
| 194 DVLOG(1) << "ProfileSigninConfirmationHelper: profile is not new"; | 202 DVLOG(1) << "ProfileSigninConfirmationHelper: profile is not new"; |
| 195 return has_been_shutdown; | 203 return has_been_shutdown; |
| 204 #endif |
| 196 } | 205 } |
| 197 | 206 |
| 198 bool HasSyncedExtensions(Profile* profile) { | 207 bool HasSyncedExtensions(Profile* profile) { |
| 199 #if defined(ENABLE_EXTENSIONS) | 208 #if defined(ENABLE_EXTENSIONS) |
| 200 extensions::ExtensionSystem* system = | 209 extensions::ExtensionSystem* system = |
| 201 extensions::ExtensionSystem::Get(profile); | 210 extensions::ExtensionSystem::Get(profile); |
| 202 if (system && system->extension_service()) { | 211 if (system && system->extension_service()) { |
| 203 const extensions::ExtensionSet* extensions = | 212 const extensions::ExtensionSet* extensions = |
| 204 system->extension_service()->extensions(); | 213 system->extension_service()->extensions(); |
| 205 for (extensions::ExtensionSet::const_iterator iter = extensions->begin(); | 214 for (extensions::ExtensionSet::const_iterator iter = extensions->begin(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 232 return; | 241 return; |
| 233 } | 242 } |
| 234 // Fire asynchronous queries for profile data. | 243 // Fire asynchronous queries for profile data. |
| 235 ProfileSigninConfirmationHelper* helper = | 244 ProfileSigninConfirmationHelper* helper = |
| 236 new ProfileSigninConfirmationHelper(profile, return_result); | 245 new ProfileSigninConfirmationHelper(profile, return_result); |
| 237 helper->CheckHasHistory(kHistoryEntriesBeforeNewProfilePrompt); | 246 helper->CheckHasHistory(kHistoryEntriesBeforeNewProfilePrompt); |
| 238 helper->CheckHasTypedURLs(); | 247 helper->CheckHasTypedURLs(); |
| 239 } | 248 } |
| 240 | 249 |
| 241 } // namespace ui | 250 } // namespace ui |
| OLD | NEW |