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_service.h" | 5 #include "chrome/browser/themes/theme_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
9 #include "base/sequenced_task_runner.h" | 9 #include "base/sequenced_task_runner.h" |
10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 | 386 |
387 // static | 387 // static |
388 void ThemeService::SaveThemeIDForProfile( | 388 void ThemeService::SaveThemeIDForProfile( |
389 Profile* profile, | 389 Profile* profile, |
390 const std::string& id) { | 390 const std::string& id) { |
391 profile->GetPrefs()->SetString(prefs::kCurrentThemeID, id); | 391 profile->GetPrefs()->SetString(prefs::kCurrentThemeID, id); |
392 } | 392 } |
393 | 393 |
394 // static | 394 // static |
395 void ThemeService::RemoveUnusedThemesForProfile(Profile* profile) { | 395 void ThemeService::RemoveUnusedThemesForProfile(Profile* profile) { |
396 ExtensionService* extension_service = profile->GetExtensionService(); | 396 ExtensionService* extension_service = |
| 397 extensions::ExtensionSystem::Get(profile)->extension_service(); |
397 if (!extension_service) | 398 if (!extension_service) |
398 return; | 399 return; |
399 std::string current_theme = GetThemeIDForProfile(profile); | 400 std::string current_theme = GetThemeIDForProfile(profile); |
400 std::vector<std::string> remove_list; | 401 std::vector<std::string> remove_list; |
401 const ExtensionSet* extensions = extension_service->extensions(); | 402 const ExtensionSet* extensions = extension_service->extensions(); |
402 for (ExtensionSet::const_iterator it = extensions->begin(); | 403 for (ExtensionSet::const_iterator it = extensions->begin(); |
403 it != extensions->end(); ++it) { | 404 it != extensions->end(); ++it) { |
404 if ((*it)->is_theme() && (*it)->id() != current_theme) { | 405 if ((*it)->is_theme() && (*it)->id() != current_theme) { |
405 remove_list.push_back((*it)->id()); | 406 remove_list.push_back((*it)->id()); |
406 } | 407 } |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 if (path != FilePath()) { | 621 if (path != FilePath()) { |
621 theme_pack_ = BrowserThemePack::BuildFromDataPack(path, current_id); | 622 theme_pack_ = BrowserThemePack::BuildFromDataPack(path, current_id); |
622 loaded_pack = theme_pack_.get() != NULL; | 623 loaded_pack = theme_pack_.get() != NULL; |
623 } | 624 } |
624 | 625 |
625 if (loaded_pack) { | 626 if (loaded_pack) { |
626 content::RecordAction(UserMetricsAction("Themes.Loaded")); | 627 content::RecordAction(UserMetricsAction("Themes.Loaded")); |
627 } else { | 628 } else { |
628 // TODO(erg): We need to pop up a dialog informing the user that their | 629 // TODO(erg): We need to pop up a dialog informing the user that their |
629 // theme is being migrated. | 630 // theme is being migrated. |
630 ExtensionService* service = profile_->GetExtensionService(); | 631 ExtensionService* service = |
| 632 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
631 if (service) { | 633 if (service) { |
632 const Extension* extension = | 634 const Extension* extension = |
633 service->GetExtensionById(current_id, false); | 635 service->GetExtensionById(current_id, false); |
634 if (extension) { | 636 if (extension) { |
635 DLOG(ERROR) << "Migrating theme"; | 637 DLOG(ERROR) << "Migrating theme"; |
636 BuildFromExtension(extension); | 638 BuildFromExtension(extension); |
637 content::RecordAction(UserMetricsAction("Themes.Migrated")); | 639 content::RecordAction(UserMetricsAction("Themes.Migrated")); |
638 } else { | 640 } else { |
639 DLOG(ERROR) << "Theme is mysteriously gone."; | 641 DLOG(ERROR) << "Theme is mysteriously gone."; |
640 ClearAllThemeData(); | 642 ClearAllThemeData(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 FROM_HERE, | 697 FROM_HERE, |
696 base::Bind(&WritePackToDiskCallback, pack, pack_path)); | 698 base::Bind(&WritePackToDiskCallback, pack, pack_path)); |
697 | 699 |
698 SavePackName(pack_path); | 700 SavePackName(pack_path); |
699 theme_pack_ = pack; | 701 theme_pack_ = pack; |
700 } | 702 } |
701 | 703 |
702 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { | 704 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { |
703 return theme_syncable_service_.get(); | 705 return theme_syncable_service_.get(); |
704 } | 706 } |
OLD | NEW |