OLD | NEW |
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/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/themes/theme_service.h" | 10 #include "chrome/browser/themes/theme_service.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // auto-update cycle. | 236 // auto-update cycle. |
237 const bool kInstallSilently = true; | 237 const bool kInstallSilently = true; |
238 if (!extensions_service->pending_extension_manager()->AddFromSync( | 238 if (!extensions_service->pending_extension_manager()->AddFromSync( |
239 id, update_url, &IsTheme, kInstallSilently)) { | 239 id, update_url, &IsTheme, kInstallSilently)) { |
240 LOG(WARNING) << "Could not add pending extension for " << id; | 240 LOG(WARNING) << "Could not add pending extension for " << id; |
241 return; | 241 return; |
242 } | 242 } |
243 extensions_service->CheckForUpdatesSoon(); | 243 extensions_service->CheckForUpdatesSoon(); |
244 } | 244 } |
245 } else if (theme_specifics.use_system_theme_by_default()) { | 245 } else if (theme_specifics.use_system_theme_by_default()) { |
246 DVLOG(1) << "Switch to use native theme"; | 246 DVLOG(1) << "Switch to use system theme"; |
247 theme_service_->SetNativeTheme(); | 247 theme_service_->UseSystemTheme(); |
248 } else { | 248 } else { |
249 DVLOG(1) << "Switch to use default theme"; | 249 DVLOG(1) << "Switch to use default theme"; |
250 theme_service_->UseDefaultTheme(); | 250 theme_service_->UseDefaultTheme(); |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 bool ThemeSyncableService::GetThemeSpecificsFromCurrentTheme( | 254 bool ThemeSyncableService::GetThemeSpecificsFromCurrentTheme( |
255 sync_pb::ThemeSpecifics* theme_specifics) const { | 255 sync_pb::ThemeSpecifics* theme_specifics) const { |
256 const extensions::Extension* current_theme = | 256 const extensions::Extension* current_theme = |
257 theme_service_->UsingDefaultTheme() ? | 257 theme_service_->UsingDefaultTheme() ? |
258 NULL : | 258 NULL : |
259 extensions::ExtensionSystem::Get(profile_)->extension_service()-> | 259 extensions::ExtensionSystem::Get(profile_)->extension_service()-> |
260 GetExtensionById(theme_service_->GetThemeID(), false); | 260 GetExtensionById(theme_service_->GetThemeID(), false); |
261 if (current_theme && !extensions::sync_helper::IsSyncable(current_theme)) { | 261 if (current_theme && !extensions::sync_helper::IsSyncable(current_theme)) { |
262 DVLOG(1) << "Ignoring extension from external source: " << | 262 DVLOG(1) << "Ignoring extension from external source: " << |
263 current_theme->location(); | 263 current_theme->location(); |
264 return false; | 264 return false; |
265 } | 265 } |
266 bool use_custom_theme = (current_theme != NULL); | 266 bool use_custom_theme = (current_theme != NULL); |
267 theme_specifics->set_use_custom_theme(use_custom_theme); | 267 theme_specifics->set_use_custom_theme(use_custom_theme); |
268 if (IsSystemThemeDistinctFromDefaultTheme()) { | 268 if (IsSystemThemeDistinctFromDefaultTheme()) { |
269 // On platform where system theme is different from default theme, set | 269 // On platform where system theme is different from default theme, set |
270 // use_system_theme_by_default to true if system theme is used, false | 270 // use_system_theme_by_default to true if system theme is used, false |
271 // if default system theme is used. Otherwise restore it to value in sync. | 271 // if default system theme is used. Otherwise restore it to value in sync. |
272 if (theme_service_->UsingNativeTheme()) { | 272 if (theme_service_->UsingSystemTheme()) { |
273 theme_specifics->set_use_system_theme_by_default(true); | 273 theme_specifics->set_use_system_theme_by_default(true); |
274 } else if (theme_service_->UsingDefaultTheme()) { | 274 } else if (theme_service_->UsingDefaultTheme()) { |
275 theme_specifics->set_use_system_theme_by_default(false); | 275 theme_specifics->set_use_system_theme_by_default(false); |
276 } else { | 276 } else { |
277 theme_specifics->set_use_system_theme_by_default( | 277 theme_specifics->set_use_system_theme_by_default( |
278 use_system_theme_by_default_); | 278 use_system_theme_by_default_); |
279 } | 279 } |
280 } else { | 280 } else { |
281 // Restore use_system_theme_by_default when platform doesn't distinguish | 281 // Restore use_system_theme_by_default when platform doesn't distinguish |
282 // between default theme and system theme. | 282 // between default theme and system theme. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 syncer::SyncChange(FROM_HERE, change_type, | 335 syncer::SyncChange(FROM_HERE, change_type, |
336 syncer::SyncData::CreateLocalData( | 336 syncer::SyncData::CreateLocalData( |
337 kCurrentThemeClientTag, kCurrentThemeNodeTitle, | 337 kCurrentThemeClientTag, kCurrentThemeNodeTitle, |
338 entity_specifics))); | 338 entity_specifics))); |
339 | 339 |
340 DVLOG(1) << "Update theme specifics from current theme: " | 340 DVLOG(1) << "Update theme specifics from current theme: " |
341 << changes.back().ToString(); | 341 << changes.back().ToString(); |
342 | 342 |
343 return sync_processor_->ProcessSyncChanges(FROM_HERE, changes); | 343 return sync_processor_->ProcessSyncChanges(FROM_HERE, changes); |
344 } | 344 } |
OLD | NEW |