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

Side by Side Diff: chrome/browser/themes/theme_syncable_service.cc

Issue 22755003: Reland: Chrome side work for allowing a user to revert to their previous theme without closing ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 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 (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/themes/theme_syncable_service.h" 5 #include "chrome/browser/themes/theme_syncable_service.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 202
203 void ThemeSyncableService::SetCurrentThemeFromThemeSpecifics( 203 void ThemeSyncableService::SetCurrentThemeFromThemeSpecifics(
204 const sync_pb::ThemeSpecifics& theme_specifics) { 204 const sync_pb::ThemeSpecifics& theme_specifics) {
205 if (theme_specifics.use_custom_theme()) { 205 if (theme_specifics.use_custom_theme()) {
206 // TODO(akalin): Figure out what to do about third-party themes 206 // TODO(akalin): Figure out what to do about third-party themes
207 // (i.e., those not on either Google gallery). 207 // (i.e., those not on either Google gallery).
208 string id(theme_specifics.custom_theme_id()); 208 string id(theme_specifics.custom_theme_id());
209 GURL update_url(theme_specifics.custom_theme_update_url()); 209 GURL update_url(theme_specifics.custom_theme_update_url());
210 DVLOG(1) << "Applying theme " << id << " with update_url " << update_url; 210 DVLOG(1) << "Applying theme " << id << " with update_url " << update_url;
211 ExtensionServiceInterface* extensions_service = 211 ExtensionService* extensions_service =
212 extensions::ExtensionSystem::Get(profile_)->extension_service(); 212 extensions::ExtensionSystem::Get(profile_)->extension_service();
213 CHECK(extensions_service); 213 CHECK(extensions_service);
214 const extensions::Extension* extension = 214 const extensions::Extension* extension =
215 extensions_service->GetExtensionById(id, true); 215 extensions_service->GetExtensionById(id, true);
216 if (extension) { 216 if (extension) {
217 if (!extension->is_theme()) { 217 if (!extension->is_theme()) {
218 DVLOG(1) << "Extension " << id << " is not a theme; aborting"; 218 DVLOG(1) << "Extension " << id << " is not a theme; aborting";
219 return; 219 return;
220 } 220 }
221 if (!extensions_service->IsExtensionEnabled(id)) { 221 int disabled_reasons =
222 DVLOG(1) << "Theme " << id << " is not enabled; aborting"; 222 extensions_service->extension_prefs()->GetDisableReasons(id);
223 if (!extensions_service->IsExtensionEnabled(id) &&
224 disabled_reasons != extensions::Extension::DISABLE_USER_ACTION) {
225 DVLOG(1) << "Theme " << id << " is disabled with reason "
226 << disabled_reasons << "; aborting";
223 return; 227 return;
224 } 228 }
225 // An enabled theme extension with the given id was found, so 229 // An enabled theme extension with the given id was found, so
226 // just set the current theme to it. 230 // just set the current theme to it.
227 theme_service_->SetTheme(extension); 231 theme_service_->SetTheme(extension);
228 } else { 232 } else {
229 // No extension with this id exists -- we must install it; we do 233 // No extension with this id exists -- we must install it; we do
230 // so by adding it as a pending extension and then triggering an 234 // so by adding it as a pending extension and then triggering an
231 // auto-update cycle. 235 // auto-update cycle.
232 const bool kInstallSilently = true; 236 const bool kInstallSilently = true;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 syncer::SyncChange(FROM_HERE, change_type, 334 syncer::SyncChange(FROM_HERE, change_type,
331 syncer::SyncData::CreateLocalData( 335 syncer::SyncData::CreateLocalData(
332 kCurrentThemeClientTag, kCurrentThemeNodeTitle, 336 kCurrentThemeClientTag, kCurrentThemeNodeTitle,
333 entity_specifics))); 337 entity_specifics)));
334 338
335 DVLOG(1) << "Update theme specifics from current theme: " 339 DVLOG(1) << "Update theme specifics from current theme: "
336 << changes.back().ToString(); 340 << changes.back().ToString();
337 341
338 return sync_processor_->ProcessSyncChanges(FROM_HERE, changes); 342 return sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
339 } 343 }
OLDNEW
« no previous file with comments | « chrome/browser/themes/theme_service_unittest.cc ('k') | chrome/browser/ui/search/instant_extended_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698