Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: chrome/browser/ui/sync/profile_signin_confirmation_helper.cc

Issue 420033002: ifdef a few pieces of extensions code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/task/cancelable_task_tracker.h" 11 #include "base/task/cancelable_task_tracker.h"
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/history/history_backend.h" 13 #include "chrome/browser/history/history_backend.h"
15 #include "chrome/browser/history/history_db_task.h" 14 #include "chrome/browser/history/history_db_task.h"
16 #include "chrome/browser/history/history_service.h" 15 #include "chrome/browser/history/history_service.h"
17 #include "chrome/browser/history/history_service_factory.h" 16 #include "chrome/browser/history/history_service_factory.h"
18 #include "chrome/browser/history/history_types.h" 17 #include "chrome/browser/history/history_types.h"
19 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "components/bookmarks/browser/bookmark_model.h"
20 #include "content/public/browser/browser_thread.h"
21 #include "ui/gfx/color_utils.h"
22 #include "ui/native_theme/native_theme.h"
23
24 #if defined(ENABLE_EXTENSIONS)
25 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/common/extensions/extension_constants.h" 26 #include "chrome/common/extensions/extension_constants.h"
21 #include "chrome/common/extensions/sync_helper.h" 27 #include "chrome/common/extensions/sync_helper.h"
22 #include "components/bookmarks/browser/bookmark_model.h"
23 #include "content/public/browser/browser_thread.h"
24 #include "extensions/browser/extension_system.h" 28 #include "extensions/browser/extension_system.h"
25 #include "extensions/common/extension.h" 29 #include "extensions/common/extension.h"
26 #include "extensions/common/extension_set.h" 30 #include "extensions/common/extension_set.h"
27 #include "ui/gfx/color_utils.h" 31 #endif
28 #include "ui/native_theme/native_theme.h"
29 32
30 namespace { 33 namespace {
31 34
32 const int kHistoryEntriesBeforeNewProfilePrompt = 10; 35 const int kHistoryEntriesBeforeNewProfilePrompt = 10;
33 36
34 // Determines whether a profile has any typed URLs in its history. 37 // Determines whether a profile has any typed URLs in its history.
35 class HasTypedURLsTask : public history::HistoryDBTask { 38 class HasTypedURLsTask : public history::HistoryDBTask {
36 public: 39 public:
37 HasTypedURLsTask(const base::Callback<void(bool)>& cb) 40 HasTypedURLsTask(const base::Callback<void(bool)>& cb)
38 : has_typed_urls_(false), cb_(cb) { 41 : has_typed_urls_(false), cb_(cb) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 188 }
186 189
187 bool HasBeenShutdown(Profile* profile) { 190 bool HasBeenShutdown(Profile* profile) {
188 bool has_been_shutdown = !profile->IsNewProfile(); 191 bool has_been_shutdown = !profile->IsNewProfile();
189 if (has_been_shutdown) 192 if (has_been_shutdown)
190 DVLOG(1) << "ProfileSigninConfirmationHelper: profile is not new"; 193 DVLOG(1) << "ProfileSigninConfirmationHelper: profile is not new";
191 return has_been_shutdown; 194 return has_been_shutdown;
192 } 195 }
193 196
194 bool HasSyncedExtensions(Profile* profile) { 197 bool HasSyncedExtensions(Profile* profile) {
198 #if defined(ENABLE_EXTENSIONS)
195 extensions::ExtensionSystem* system = 199 extensions::ExtensionSystem* system =
196 extensions::ExtensionSystem::Get(profile); 200 extensions::ExtensionSystem::Get(profile);
197 if (system && system->extension_service()) { 201 if (system && system->extension_service()) {
198 const extensions::ExtensionSet* extensions = 202 const extensions::ExtensionSet* extensions =
199 system->extension_service()->extensions(); 203 system->extension_service()->extensions();
200 for (extensions::ExtensionSet::const_iterator iter = extensions->begin(); 204 for (extensions::ExtensionSet::const_iterator iter = extensions->begin();
201 iter != extensions->end(); ++iter) { 205 iter != extensions->end(); ++iter) {
202 // The webstore is synced so that it stays put on the new tab 206 // The webstore is synced so that it stays put on the new tab
203 // page, but since it's installed by default we don't want to 207 // page, but since it's installed by default we don't want to
204 // consider it when determining if the profile is dirty. 208 // consider it when determining if the profile is dirty.
205 if (extensions::sync_helper::IsSyncable(iter->get()) && 209 if (extensions::sync_helper::IsSyncable(iter->get()) &&
206 (*iter)->id() != extension_misc::kWebStoreAppId && 210 (*iter)->id() != extension_misc::kWebStoreAppId &&
207 (*iter)->id() != extension_misc::kChromeAppId) { 211 (*iter)->id() != extension_misc::kChromeAppId) {
208 DVLOG(1) << "ProfileSigninConfirmationHelper: " 212 DVLOG(1) << "ProfileSigninConfirmationHelper: "
209 << "profile contains a synced extension: " << (*iter)->id(); 213 << "profile contains a synced extension: " << (*iter)->id();
210 return true; 214 return true;
211 } 215 }
212 } 216 }
213 } 217 }
218 #endif
214 return false; 219 return false;
215 } 220 }
216 221
217 void CheckShouldPromptForNewProfile( 222 void CheckShouldPromptForNewProfile(
218 Profile* profile, 223 Profile* profile,
219 const base::Callback<void(bool)>& return_result) { 224 const base::Callback<void(bool)>& return_result) {
220 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 225 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
221 226
222 if (HasBeenShutdown(profile) || 227 if (HasBeenShutdown(profile) ||
223 HasBookmarks(profile) || 228 HasBookmarks(profile) ||
224 HasSyncedExtensions(profile)) { 229 HasSyncedExtensions(profile)) {
225 return_result.Run(true); 230 return_result.Run(true);
226 return; 231 return;
227 } 232 }
228 // Fire asynchronous queries for profile data. 233 // Fire asynchronous queries for profile data.
229 ProfileSigninConfirmationHelper* helper = 234 ProfileSigninConfirmationHelper* helper =
230 new ProfileSigninConfirmationHelper(profile, return_result); 235 new ProfileSigninConfirmationHelper(profile, return_result);
231 helper->CheckHasHistory(kHistoryEntriesBeforeNewProfilePrompt); 236 helper->CheckHasHistory(kHistoryEntriesBeforeNewProfilePrompt);
232 helper->CheckHasTypedURLs(); 237 helper->CheckHasTypedURLs();
233 } 238 }
234 239
235 } // namespace ui 240 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698