| 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/themes/browser_theme_provider.h" | 5 #include "chrome/browser/themes/browser_theme_provider.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/string_split.h" | 8 #include "base/string_split.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/extensions/extensions_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/metrics/user_metrics.h" | 12 #include "chrome/browser/metrics/user_metrics.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/themes/browser_theme_pack.h" | 14 #include "chrome/browser/themes/browser_theme_pack.h" |
| 15 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
| 16 #include "chrome/common/notification_service.h" | 16 #include "chrome/common/notification_service.h" |
| 17 #include "chrome/common/notification_type.h" | 17 #include "chrome/common/notification_type.h" |
| 18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 19 #include "grit/app_resources.h" | 19 #include "grit/app_resources.h" |
| 20 #include "grit/theme_resources.h" | 20 #include "grit/theme_resources.h" |
| 21 | 21 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 BuildFromExtension(extension); | 297 BuildFromExtension(extension); |
| 298 SaveThemeID(extension->id()); | 298 SaveThemeID(extension->id()); |
| 299 | 299 |
| 300 NotifyThemeChanged(extension); | 300 NotifyThemeChanged(extension); |
| 301 UserMetrics::RecordAction(UserMetricsAction("Themes_Installed"), profile_); | 301 UserMetrics::RecordAction(UserMetricsAction("Themes_Installed"), profile_); |
| 302 } | 302 } |
| 303 | 303 |
| 304 void BrowserThemeProvider::RemoveUnusedThemes() { | 304 void BrowserThemeProvider::RemoveUnusedThemes() { |
| 305 if (!profile_) | 305 if (!profile_) |
| 306 return; | 306 return; |
| 307 ExtensionsService* service = profile_->GetExtensionsService(); | 307 ExtensionService* service = profile_->GetExtensionService(); |
| 308 if (!service) | 308 if (!service) |
| 309 return; | 309 return; |
| 310 std::string current_theme = GetThemeID(); | 310 std::string current_theme = GetThemeID(); |
| 311 std::vector<std::string> remove_list; | 311 std::vector<std::string> remove_list; |
| 312 const ExtensionList* extensions = service->extensions(); | 312 const ExtensionList* extensions = service->extensions(); |
| 313 for (ExtensionList::const_iterator it = extensions->begin(); | 313 for (ExtensionList::const_iterator it = extensions->begin(); |
| 314 it != extensions->end(); ++it) { | 314 it != extensions->end(); ++it) { |
| 315 if ((*it)->is_theme() && (*it)->id() != current_theme) { | 315 if ((*it)->is_theme() && (*it)->id() != current_theme) { |
| 316 remove_list.push_back((*it)->id()); | 316 remove_list.push_back((*it)->id()); |
| 317 } | 317 } |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 if (path != FilePath()) { | 551 if (path != FilePath()) { |
| 552 theme_pack_ = BrowserThemePack::BuildFromDataPack(path, current_id); | 552 theme_pack_ = BrowserThemePack::BuildFromDataPack(path, current_id); |
| 553 loaded_pack = theme_pack_.get() != NULL; | 553 loaded_pack = theme_pack_.get() != NULL; |
| 554 } | 554 } |
| 555 | 555 |
| 556 if (loaded_pack) { | 556 if (loaded_pack) { |
| 557 UserMetrics::RecordAction(UserMetricsAction("Themes.Loaded"), profile_); | 557 UserMetrics::RecordAction(UserMetricsAction("Themes.Loaded"), profile_); |
| 558 } else { | 558 } else { |
| 559 // TODO(erg): We need to pop up a dialog informing the user that their | 559 // TODO(erg): We need to pop up a dialog informing the user that their |
| 560 // theme is being migrated. | 560 // theme is being migrated. |
| 561 ExtensionsService* service = profile_->GetExtensionsService(); | 561 ExtensionService* service = profile_->GetExtensionService(); |
| 562 if (service) { | 562 if (service) { |
| 563 const Extension* extension = | 563 const Extension* extension = |
| 564 service->GetExtensionById(current_id, false); | 564 service->GetExtensionById(current_id, false); |
| 565 if (extension) { | 565 if (extension) { |
| 566 DLOG(ERROR) << "Migrating theme"; | 566 DLOG(ERROR) << "Migrating theme"; |
| 567 BuildFromExtension(extension); | 567 BuildFromExtension(extension); |
| 568 UserMetrics::RecordAction(UserMetricsAction("Themes.Migrated"), | 568 UserMetrics::RecordAction(UserMetricsAction("Themes.Migrated"), |
| 569 profile_); | 569 profile_); |
| 570 } else { | 570 } else { |
| 571 DLOG(ERROR) << "Theme is mysteriously gone."; | 571 DLOG(ERROR) << "Theme is mysteriously gone."; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 void BrowserThemeProvider::OnInfobarDisplayed() { | 626 void BrowserThemeProvider::OnInfobarDisplayed() { |
| 627 number_of_infobars_++; | 627 number_of_infobars_++; |
| 628 } | 628 } |
| 629 | 629 |
| 630 void BrowserThemeProvider::OnInfobarDestroyed() { | 630 void BrowserThemeProvider::OnInfobarDestroyed() { |
| 631 number_of_infobars_--; | 631 number_of_infobars_--; |
| 632 | 632 |
| 633 if (number_of_infobars_ == 0) | 633 if (number_of_infobars_ == 0) |
| 634 RemoveUnusedThemes(); | 634 RemoveUnusedThemes(); |
| 635 } | 635 } |
| OLD | NEW |