| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 106 |
| 107 ProfileSigninConfirmationHelper::ProfileSigninConfirmationHelper( | 107 ProfileSigninConfirmationHelper::ProfileSigninConfirmationHelper( |
| 108 Profile* profile, | 108 Profile* profile, |
| 109 const base::Callback<void(bool)>& return_result) | 109 const base::Callback<void(bool)>& return_result) |
| 110 : profile_(profile), | 110 : profile_(profile), |
| 111 pending_requests_(0), | 111 pending_requests_(0), |
| 112 return_result_(return_result) { | 112 return_result_(return_result) { |
| 113 } | 113 } |
| 114 | 114 |
| 115 ProfileSigninConfirmationHelper::~ProfileSigninConfirmationHelper() { | 115 ProfileSigninConfirmationHelper::~ProfileSigninConfirmationHelper() { |
| 116 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 116 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void ProfileSigninConfirmationHelper::OnHistoryQueryResults( | 119 void ProfileSigninConfirmationHelper::OnHistoryQueryResults( |
| 120 size_t max_entries, | 120 size_t max_entries, |
| 121 history::QueryResults* results) { | 121 history::QueryResults* results) { |
| 122 history::QueryResults owned_results; | 122 history::QueryResults owned_results; |
| 123 results->Swap(&owned_results); | 123 results->Swap(&owned_results); |
| 124 bool too_much_history = owned_results.size() >= max_entries; | 124 bool too_much_history = owned_results.size() >= max_entries; |
| 125 if (too_much_history) { | 125 if (too_much_history) { |
| 126 DVLOG(1) << "ProfileSigninConfirmationHelper: profile contains " | 126 DVLOG(1) << "ProfileSigninConfirmationHelper: profile contains " |
| (...skipping 30 matching lines...) Expand all Loading... |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 service->ScheduleDBTask( | 159 service->ScheduleDBTask( |
| 160 scoped_ptr<history::HistoryDBTask>(new HasTypedURLsTask( | 160 scoped_ptr<history::HistoryDBTask>(new HasTypedURLsTask( |
| 161 base::Bind(&ProfileSigninConfirmationHelper::ReturnResult, | 161 base::Bind(&ProfileSigninConfirmationHelper::ReturnResult, |
| 162 base::Unretained(this)))), | 162 base::Unretained(this)))), |
| 163 &task_tracker_); | 163 &task_tracker_); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void ProfileSigninConfirmationHelper::ReturnResult(bool result) { | 166 void ProfileSigninConfirmationHelper::ReturnResult(bool result) { |
| 167 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 167 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 168 // Pass |true| into the callback as soon as one of the tasks passes a | 168 // Pass |true| into the callback as soon as one of the tasks passes a |
| 169 // result of |true|, otherwise pass the last returned result. | 169 // result of |true|, otherwise pass the last returned result. |
| 170 if (--pending_requests_ == 0 || result) { | 170 if (--pending_requests_ == 0 || result) { |
| 171 return_result_.Run(result); | 171 return_result_.Run(result); |
| 172 | 172 |
| 173 // This leaks at shutdown if the HistoryService is destroyed, but | 173 // This leaks at shutdown if the HistoryService is destroyed, but |
| 174 // the process is going to die anyway. | 174 // the process is going to die anyway. |
| 175 delete this; | 175 delete this; |
| 176 } | 176 } |
| 177 } | 177 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 #endif | 225 #endif |
| 226 return false; | 226 return false; |
| 227 } | 227 } |
| 228 | 228 |
| 229 void CheckShouldPromptForNewProfile( | 229 void CheckShouldPromptForNewProfile( |
| 230 Profile* profile, | 230 Profile* profile, |
| 231 const base::Callback<void(bool)>& return_result) { | 231 const base::Callback<void(bool)>& return_result) { |
| 232 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 232 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 233 | 233 |
| 234 if (HasBeenShutdown(profile) || | 234 if (HasBeenShutdown(profile) || |
| 235 HasBookmarks(profile) || | 235 HasBookmarks(profile) || |
| 236 HasSyncedExtensions(profile)) { | 236 HasSyncedExtensions(profile)) { |
| 237 return_result.Run(true); | 237 return_result.Run(true); |
| 238 return; | 238 return; |
| 239 } | 239 } |
| 240 // Fire asynchronous queries for profile data. | 240 // Fire asynchronous queries for profile data. |
| 241 ProfileSigninConfirmationHelper* helper = | 241 ProfileSigninConfirmationHelper* helper = |
| 242 new ProfileSigninConfirmationHelper(profile, return_result); | 242 new ProfileSigninConfirmationHelper(profile, return_result); |
| 243 helper->CheckHasHistory(kHistoryEntriesBeforeNewProfilePrompt); | 243 helper->CheckHasHistory(kHistoryEntriesBeforeNewProfilePrompt); |
| 244 helper->CheckHasTypedURLs(); | 244 helper->CheckHasTypedURLs(); |
| 245 } | 245 } |
| 246 | 246 |
| 247 } // namespace ui | 247 } // namespace ui |
| OLD | NEW |