| 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 25 matching lines...) Expand all Loading... |
| 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 explicit 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"; |
| 52 has_typed_urls_ = true; | 52 has_typed_urls_ = true; |
| 53 } | 53 } |
| 54 return true; | 54 return true; |
| 55 } | 55 } |
| 56 | 56 |
| 57 virtual void DoneRunOnMainThread() OVERRIDE { | 57 virtual void DoneRunOnMainThread() override { |
| 58 cb_.Run(has_typed_urls_); | 58 cb_.Run(has_typed_urls_); |
| 59 } | 59 } |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 virtual ~HasTypedURLsTask() {} | 62 virtual ~HasTypedURLsTask() {} |
| 63 | 63 |
| 64 bool has_typed_urls_; | 64 bool has_typed_urls_; |
| 65 base::Callback<void(bool)> cb_; | 65 base::Callback<void(bool)> cb_; |
| 66 }; | 66 }; |
| 67 | 67 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 return; | 241 return; |
| 242 } | 242 } |
| 243 // Fire asynchronous queries for profile data. | 243 // Fire asynchronous queries for profile data. |
| 244 ProfileSigninConfirmationHelper* helper = | 244 ProfileSigninConfirmationHelper* helper = |
| 245 new ProfileSigninConfirmationHelper(profile, return_result); | 245 new ProfileSigninConfirmationHelper(profile, return_result); |
| 246 helper->CheckHasHistory(kHistoryEntriesBeforeNewProfilePrompt); | 246 helper->CheckHasHistory(kHistoryEntriesBeforeNewProfilePrompt); |
| 247 helper->CheckHasTypedURLs(); | 247 helper->CheckHasTypedURLs(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 } // namespace ui | 250 } // namespace ui |
| OLD | NEW |