OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/string_split.h" | 7 #include "base/string_split.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 } | 309 } |
310 | 310 |
311 void BrowserThemeProvider::RemoveUnusedThemes() { | 311 void BrowserThemeProvider::RemoveUnusedThemes() { |
312 if (!profile_) | 312 if (!profile_) |
313 return; | 313 return; |
314 ExtensionService* service = profile_->GetExtensionService(); | 314 ExtensionService* service = profile_->GetExtensionService(); |
315 if (!service) | 315 if (!service) |
316 return; | 316 return; |
317 std::string current_theme = GetThemeID(); | 317 std::string current_theme = GetThemeID(); |
318 std::vector<std::string> remove_list; | 318 std::vector<std::string> remove_list; |
319 const ExtensionList* extensions = service->extensions(); | 319 const ExtensionList* enabled = service->extensions(); |
320 for (ExtensionList::const_iterator it = extensions->begin(); | 320 const ExtensionList* disabled = service->disabled_extensions(); |
321 it != extensions->end(); ++it) { | 321 ExtensionList extensions; |
| 322 extensions.insert(extensions.end(), enabled->begin(), enabled->end()); |
| 323 extensions.insert(extensions.end(), disabled->begin(), disabled->end()); |
| 324 |
| 325 for (ExtensionList::const_iterator it = extensions.begin(); |
| 326 it != extensions.end(); ++it) { |
322 if ((*it)->is_theme() && (*it)->id() != current_theme) { | 327 if ((*it)->is_theme() && (*it)->id() != current_theme) { |
323 remove_list.push_back((*it)->id()); | 328 remove_list.push_back((*it)->id()); |
324 } | 329 } |
325 } | 330 } |
326 for (size_t i = 0; i < remove_list.size(); ++i) | 331 for (size_t i = 0; i < remove_list.size(); ++i) |
327 service->UninstallExtension(remove_list[i], false); | 332 service->UninstallExtension(remove_list[i], false); |
328 } | 333 } |
329 | 334 |
330 void BrowserThemeProvider::UseDefaultTheme() { | 335 void BrowserThemeProvider::UseDefaultTheme() { |
331 ClearAllThemeData(); | 336 ClearAllThemeData(); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 DLOG(ERROR) << "Theme is mysteriously gone."; | 585 DLOG(ERROR) << "Theme is mysteriously gone."; |
581 ClearAllThemeData(); | 586 ClearAllThemeData(); |
582 UserMetrics::RecordAction(UserMetricsAction("Themes.Gone"), profile_); | 587 UserMetrics::RecordAction(UserMetricsAction("Themes.Gone"), profile_); |
583 } | 588 } |
584 } | 589 } |
585 } | 590 } |
586 } | 591 } |
587 } | 592 } |
588 | 593 |
589 void BrowserThemeProvider::NotifyThemeChanged(const Extension* extension) { | 594 void BrowserThemeProvider::NotifyThemeChanged(const Extension* extension) { |
| 595 FilePath profile_basename = profile_->GetPath().BaseName(); |
| 596 |
| 597 LOG(INFO) << profile_basename.value() << " theme changed to: " |
| 598 << (extension ? extension->id() : "null"); |
| 599 |
590 VLOG(1) << "Sending BROWSER_THEME_CHANGED"; | 600 VLOG(1) << "Sending BROWSER_THEME_CHANGED"; |
591 // Redraw! | 601 // Redraw! |
592 NotificationService* service = NotificationService::current(); | 602 NotificationService* service = NotificationService::current(); |
593 service->Notify(NotificationType::BROWSER_THEME_CHANGED, | 603 service->Notify(NotificationType::BROWSER_THEME_CHANGED, |
594 Source<BrowserThemeProvider>(this), | 604 Source<BrowserThemeProvider>(this), |
595 Details<const Extension>(extension)); | 605 Details<const Extension>(extension)); |
596 #if defined(OS_MACOSX) | 606 #if defined(OS_MACOSX) |
597 NotifyPlatformThemeChanged(); | 607 NotifyPlatformThemeChanged(); |
598 #endif // OS_MACOSX | 608 #endif // OS_MACOSX |
599 } | 609 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 void BrowserThemeProvider::OnInfobarDisplayed() { | 645 void BrowserThemeProvider::OnInfobarDisplayed() { |
636 number_of_infobars_++; | 646 number_of_infobars_++; |
637 } | 647 } |
638 | 648 |
639 void BrowserThemeProvider::OnInfobarDestroyed() { | 649 void BrowserThemeProvider::OnInfobarDestroyed() { |
640 number_of_infobars_--; | 650 number_of_infobars_--; |
641 | 651 |
642 if (number_of_infobars_ == 0) | 652 if (number_of_infobars_ == 0) |
643 RemoveUnusedThemes(); | 653 RemoveUnusedThemes(); |
644 } | 654 } |
OLD | NEW |