OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/sync/glue/theme_util.h" | 5 #include "chrome/browser/sync/glue/theme_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
11 #include "chrome/browser/extensions/extension_install_ui.h" | 11 #include "chrome/browser/extensions/extension_install_ui.h" |
12 #include "chrome/browser/extensions/extension_updater.h" | 12 #include "chrome/browser/extensions/extension_updater.h" |
13 #include "chrome/browser/extensions/extensions_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
14 #if defined(TOOLKIT_USES_GTK) | 14 #if defined(TOOLKIT_USES_GTK) |
15 #include "chrome/browser/gtk/gtk_theme_provider.h" | 15 #include "chrome/browser/gtk/gtk_theme_provider.h" |
16 #endif | 16 #endif |
17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" | 19 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" |
20 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
21 #include "chrome/common/extensions/extension_constants.h" | 21 #include "chrome/common/extensions/extension_constants.h" |
22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
23 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
(...skipping 54 matching lines...) Loading... |
78 void SetCurrentThemeFromThemeSpecifics( | 78 void SetCurrentThemeFromThemeSpecifics( |
79 const sync_pb::ThemeSpecifics& theme_specifics, | 79 const sync_pb::ThemeSpecifics& theme_specifics, |
80 Profile* profile) { | 80 Profile* profile) { |
81 DCHECK(profile); | 81 DCHECK(profile); |
82 if (theme_specifics.use_custom_theme()) { | 82 if (theme_specifics.use_custom_theme()) { |
83 // TODO(akalin): Figure out what to do about third-party themes | 83 // TODO(akalin): Figure out what to do about third-party themes |
84 // (i.e., those not on either Google gallery). | 84 // (i.e., those not on either Google gallery). |
85 std::string id(theme_specifics.custom_theme_id()); | 85 std::string id(theme_specifics.custom_theme_id()); |
86 GURL update_url(theme_specifics.custom_theme_update_url()); | 86 GURL update_url(theme_specifics.custom_theme_update_url()); |
87 VLOG(1) << "Applying theme " << id << " with update_url " << update_url; | 87 VLOG(1) << "Applying theme " << id << " with update_url " << update_url; |
88 ExtensionsService* extensions_service = profile->GetExtensionsService(); | 88 ExtensionService* extensions_service = profile->GetExtensionService(); |
89 CHECK(extensions_service); | 89 CHECK(extensions_service); |
90 const Extension* extension = extensions_service->GetExtensionById(id, true); | 90 const Extension* extension = extensions_service->GetExtensionById(id, true); |
91 if (extension) { | 91 if (extension) { |
92 if (!extension->is_theme()) { | 92 if (!extension->is_theme()) { |
93 VLOG(1) << "Extension " << id << " is not a theme; aborting"; | 93 VLOG(1) << "Extension " << id << " is not a theme; aborting"; |
94 return; | 94 return; |
95 } | 95 } |
96 ExtensionPrefs* extension_prefs = extensions_service->extension_prefs(); | 96 ExtensionPrefs* extension_prefs = extensions_service->extension_prefs(); |
97 CHECK(extension_prefs); | 97 CHECK(extension_prefs); |
98 // TODO(akalin): GetExtensionState() isn't very safe as it | 98 // TODO(akalin): GetExtensionState() isn't very safe as it |
(...skipping 32 matching lines...) Loading... |
131 // informational dialog after installation instead of a | 131 // informational dialog after installation instead of a |
132 // confirmation dialog. | 132 // confirmation dialog. |
133 const bool kInstallSilently = false; | 133 const bool kInstallSilently = false; |
134 const bool kEnableOnInstall = true; | 134 const bool kEnableOnInstall = true; |
135 const bool kEnableIncognitoOnInstall = false; | 135 const bool kEnableIncognitoOnInstall = false; |
136 extensions_service->AddPendingExtensionFromSync( | 136 extensions_service->AddPendingExtensionFromSync( |
137 id, update_url, kExpectedCrxType, | 137 id, update_url, kExpectedCrxType, |
138 kInstallSilently, kEnableOnInstall, kEnableIncognitoOnInstall); | 138 kInstallSilently, kEnableOnInstall, kEnableIncognitoOnInstall); |
139 ExtensionUpdater* extension_updater = extensions_service->updater(); | 139 ExtensionUpdater* extension_updater = extensions_service->updater(); |
140 // Auto-updates should now be on always (see the construction of | 140 // Auto-updates should now be on always (see the construction of |
141 // the ExtensionsService in ProfileImpl::InitExtensions()). | 141 // the ExtensionService in ProfileImpl::InitExtensions()). |
142 if (!extension_updater) { | 142 if (!extension_updater) { |
143 LOG(DFATAL) << "Extension updater unexpectedly NULL; " | 143 LOG(DFATAL) << "Extension updater unexpectedly NULL; " |
144 << "auto-updates may be turned off"; | 144 << "auto-updates may be turned off"; |
145 return; | 145 return; |
146 } | 146 } |
147 extension_updater->CheckNow(); | 147 extension_updater->CheckNow(); |
148 } | 148 } |
149 } else if (theme_specifics.use_system_theme_by_default()) { | 149 } else if (theme_specifics.use_system_theme_by_default()) { |
150 profile->SetNativeTheme(); | 150 profile->SetNativeTheme(); |
151 } else { | 151 } else { |
(...skipping 61 matching lines...) Loading... |
213 const sync_pb::ThemeSpecifics& theme_specifics, Profile* profile) { | 213 const sync_pb::ThemeSpecifics& theme_specifics, Profile* profile) { |
214 DCHECK(profile); | 214 DCHECK(profile); |
215 sync_pb::ThemeSpecifics old_theme_specifics; | 215 sync_pb::ThemeSpecifics old_theme_specifics; |
216 GetThemeSpecificsFromCurrentTheme(profile, &old_theme_specifics); | 216 GetThemeSpecificsFromCurrentTheme(profile, &old_theme_specifics); |
217 if (!AreThemeSpecificsEqual(old_theme_specifics, theme_specifics)) { | 217 if (!AreThemeSpecificsEqual(old_theme_specifics, theme_specifics)) { |
218 SetCurrentThemeFromThemeSpecifics(theme_specifics, profile); | 218 SetCurrentThemeFromThemeSpecifics(theme_specifics, profile); |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 } // namespace browser_sync | 222 } // namespace browser_sync |
OLD | NEW |