| 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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 installed_pending_load_id_ = kDefaultThemeID; | 266 installed_pending_load_id_ = kDefaultThemeID; |
| 267 break; | 267 break; |
| 268 } | 268 } |
| 269 case chrome::NOTIFICATION_EXTENSION_ENABLED: | 269 case chrome::NOTIFICATION_EXTENSION_ENABLED: |
| 270 { | 270 { |
| 271 const Extension* extension = Details<const Extension>(details).ptr(); | 271 const Extension* extension = Details<const Extension>(details).ptr(); |
| 272 if (extension->is_theme()) | 272 if (extension->is_theme()) |
| 273 SetTheme(extension); | 273 SetTheme(extension); |
| 274 break; | 274 break; |
| 275 } | 275 } |
| 276 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | 276 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: |
| 277 { | 277 { |
| 278 Details<const UnloadedExtensionInfo> unloaded_details(details); | 278 Details<const UnloadedExtensionInfo> unloaded_details(details); |
| 279 if (unloaded_details->reason != UnloadedExtensionInfo::REASON_UPDATE && | 279 if (unloaded_details->reason != UnloadedExtensionInfo::REASON_UPDATE && |
| 280 unloaded_details->extension->is_theme() && | 280 unloaded_details->extension->is_theme() && |
| 281 unloaded_details->extension->id() == GetThemeID()) { | 281 unloaded_details->extension->id() == GetThemeID()) { |
| 282 UseDefaultTheme(); | 282 UseDefaultTheme(); |
| 283 } | 283 } |
| 284 break; | 284 break; |
| 285 } | 285 } |
| 286 } | 286 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 410 |
| 411 // Clear our image cache. | 411 // Clear our image cache. |
| 412 FreePlatformCaches(); | 412 FreePlatformCaches(); |
| 413 | 413 |
| 414 profile_->GetPrefs()->ClearPref(prefs::kCurrentThemePackFilename); | 414 profile_->GetPrefs()->ClearPref(prefs::kCurrentThemePackFilename); |
| 415 SaveThemeID(kDefaultThemeID); | 415 SaveThemeID(kDefaultThemeID); |
| 416 | 416 |
| 417 // There should be no more infobars. This may not be the case because of | 417 // There should be no more infobars. This may not be the case because of |
| 418 // http://crbug.com/62154 | 418 // http://crbug.com/62154 |
| 419 // RemoveUnusedThemes is called on a task because ClearAllThemeData() may | 419 // RemoveUnusedThemes is called on a task because ClearAllThemeData() may |
| 420 // be called as a result of NOTIFICATION_EXTENSION_UNLOADED. | 420 // be called as a result of NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED. |
| 421 base::MessageLoop::current()->PostTask(FROM_HERE, | 421 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 422 base::Bind(&ThemeService::RemoveUnusedThemes, | 422 base::Bind(&ThemeService::RemoveUnusedThemes, |
| 423 weak_ptr_factory_.GetWeakPtr(), | 423 weak_ptr_factory_.GetWeakPtr(), |
| 424 true)); | 424 true)); |
| 425 } | 425 } |
| 426 | 426 |
| 427 void ThemeService::LoadThemePrefs() { | 427 void ThemeService::LoadThemePrefs() { |
| 428 PrefService* prefs = profile_->GetPrefs(); | 428 PrefService* prefs = profile_->GetPrefs(); |
| 429 | 429 |
| 430 std::string current_id = GetThemeID(); | 430 std::string current_id = GetThemeID(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 registrar_.Add(this, | 499 registrar_.Add(this, |
| 500 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 500 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 501 content::Source<Profile>(profile_)); | 501 content::Source<Profile>(profile_)); |
| 502 registrar_.Add(this, | 502 registrar_.Add(this, |
| 503 chrome::NOTIFICATION_EXTENSION_LOADED, | 503 chrome::NOTIFICATION_EXTENSION_LOADED, |
| 504 content::Source<Profile>(profile_)); | 504 content::Source<Profile>(profile_)); |
| 505 registrar_.Add(this, | 505 registrar_.Add(this, |
| 506 chrome::NOTIFICATION_EXTENSION_ENABLED, | 506 chrome::NOTIFICATION_EXTENSION_ENABLED, |
| 507 content::Source<Profile>(profile_)); | 507 content::Source<Profile>(profile_)); |
| 508 registrar_.Add(this, | 508 registrar_.Add(this, |
| 509 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 509 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 510 content::Source<Profile>(profile_)); | 510 content::Source<Profile>(profile_)); |
| 511 | 511 |
| 512 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, | 512 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 513 base::Bind(&ThemeService::RemoveUnusedThemes, | 513 base::Bind(&ThemeService::RemoveUnusedThemes, |
| 514 weak_ptr_factory_.GetWeakPtr(), | 514 weak_ptr_factory_.GetWeakPtr(), |
| 515 false), | 515 false), |
| 516 base::TimeDelta::FromSeconds(kRemoveUnusedThemesStartupDelay)); | 516 base::TimeDelta::FromSeconds(kRemoveUnusedThemesStartupDelay)); |
| 517 } | 517 } |
| 518 | 518 |
| 519 void ThemeService::MigrateTheme() { | 519 void ThemeService::MigrateTheme() { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 void ThemeService::OnInfobarDestroyed() { | 593 void ThemeService::OnInfobarDestroyed() { |
| 594 number_of_infobars_--; | 594 number_of_infobars_--; |
| 595 | 595 |
| 596 if (number_of_infobars_ == 0) | 596 if (number_of_infobars_ == 0) |
| 597 RemoveUnusedThemes(false); | 597 RemoveUnusedThemes(false); |
| 598 } | 598 } |
| 599 | 599 |
| 600 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { | 600 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { |
| 601 return theme_syncable_service_.get(); | 601 return theme_syncable_service_.get(); |
| 602 } | 602 } |
| OLD | NEW |