Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Side by Side Diff: chrome/browser/browser_theme_provider.cc

Issue 159705: Implement kCurrentThemeID so we can know what the last theme to be installed ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_theme_provider.h ('k') | chrome/browser/profile.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/browser_theme_provider.h" 5 #include "chrome/browser/browser_theme_provider.h"
6 6
7 #include "base/gfx/png_decoder.h" 7 #include "base/gfx/png_decoder.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/browser_list.h" 10 #include "chrome/browser/browser_list.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 const skia::HSL BrowserThemeProvider::kDefaultTintFrame = { -1, -1, -1 }; 119 const skia::HSL BrowserThemeProvider::kDefaultTintFrame = { -1, -1, -1 };
120 const skia::HSL BrowserThemeProvider::kDefaultTintFrameInactive = 120 const skia::HSL BrowserThemeProvider::kDefaultTintFrameInactive =
121 { -1, -1, 0.75f }; 121 { -1, -1, 0.75f };
122 const skia::HSL BrowserThemeProvider::kDefaultTintFrameIncognito = 122 const skia::HSL BrowserThemeProvider::kDefaultTintFrameIncognito =
123 { -1, 0.2f, 0.35f }; 123 { -1, 0.2f, 0.35f };
124 const skia::HSL BrowserThemeProvider::kDefaultTintFrameIncognitoInactive = 124 const skia::HSL BrowserThemeProvider::kDefaultTintFrameIncognitoInactive =
125 { -1, 0.3f, 0.6f }; 125 { -1, 0.3f, 0.6f };
126 const skia::HSL BrowserThemeProvider::kDefaultTintBackgroundTab = 126 const skia::HSL BrowserThemeProvider::kDefaultTintBackgroundTab =
127 { -1, 0.5, 0.75 }; 127 { -1, 0.5, 0.75 };
128 128
129 // Saved default values.
130 const char* BrowserThemeProvider::kDefaultThemeID = "";
131
129 // Default display properties. 132 // Default display properties.
130 static const int kDefaultDisplayPropertyNTPAlignment = 133 static const int kDefaultDisplayPropertyNTPAlignment =
131 BrowserThemeProvider::ALIGN_BOTTOM; 134 BrowserThemeProvider::ALIGN_BOTTOM;
132 static const int kDefaultDisplayPropertyNTPTiling = 135 static const int kDefaultDisplayPropertyNTPTiling =
133 BrowserThemeProvider::NO_REPEAT; 136 BrowserThemeProvider::NO_REPEAT;
134 static const int kDefaultDisplayPropertyNTPInverseLogo = 0; 137 static const int kDefaultDisplayPropertyNTPInverseLogo = 0;
135 138
136 // The image resources that will be tinted by the 'button' tint value. 139 // The image resources that will be tinted by the 'button' tint value.
137 static const int kToolbarButtonIDs[] = { 140 static const int kToolbarButtonIDs[] = {
138 IDR_BACK, IDR_BACK_D, IDR_BACK_H, IDR_BACK_P, 141 IDR_BACK, IDR_BACK_D, IDR_BACK_H, IDR_BACK_P,
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 SetTintData(extension->GetThemeTints()); 365 SetTintData(extension->GetThemeTints());
363 SetDisplayPropertyData(extension->GetThemeDisplayProperties()); 366 SetDisplayPropertyData(extension->GetThemeDisplayProperties());
364 GenerateFrameColors(); 367 GenerateFrameColors();
365 GenerateFrameImages(); 368 GenerateFrameImages();
366 GenerateTabImages(); 369 GenerateTabImages();
367 370
368 SaveImageData(extension->GetThemeImages()); 371 SaveImageData(extension->GetThemeImages());
369 SaveColorData(); 372 SaveColorData();
370 SaveTintData(); 373 SaveTintData();
371 SaveDisplayPropertyData(); 374 SaveDisplayPropertyData();
375 SaveThemeID(extension->id());
372 376
373 NotifyThemeChanged(); 377 NotifyThemeChanged();
374 UserMetrics::RecordAction(L"Themes_Installed", profile_); 378 UserMetrics::RecordAction(L"Themes_Installed", profile_);
375 } 379 }
376 380
377 void BrowserThemeProvider::UseDefaultTheme() { 381 void BrowserThemeProvider::UseDefaultTheme() {
378 ClearAllThemeData(); 382 ClearAllThemeData();
379 NotifyThemeChanged(); 383 NotifyThemeChanged();
380 UserMetrics::RecordAction(L"Themes_Reset", profile_); 384 UserMetrics::RecordAction(L"Themes_Reset", profile_);
381 } 385 }
382 386
387 std::string BrowserThemeProvider::GetThemeID() {
388 std::wstring id = profile_->GetPrefs()->GetString(prefs::kCurrentThemeID);
389 return WideToUTF8(id);
390 }
391
383 bool BrowserThemeProvider::ReadThemeFileData( 392 bool BrowserThemeProvider::ReadThemeFileData(
384 int id, std::vector<unsigned char>* raw_data) { 393 int id, std::vector<unsigned char>* raw_data) {
385 if (images_.count(id)) { 394 if (images_.count(id)) {
386 // First check to see if we have a registered theme extension and whether 395 // First check to see if we have a registered theme extension and whether
387 // it can handle this resource. 396 // it can handle this resource.
388 #if defined(OS_WIN) 397 #if defined(OS_WIN)
389 FilePath path = FilePath(UTF8ToWide(images_[id])); 398 FilePath path = FilePath(UTF8ToWide(images_[id]));
390 #else 399 #else
391 FilePath path = FilePath(images_[id]); 400 FilePath path = FilePath(images_[id]);
392 #endif 401 #endif
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 778
770 images_.clear(); 779 images_.clear();
771 colors_.clear(); 780 colors_.clear();
772 tints_.clear(); 781 tints_.clear();
773 display_properties_.clear(); 782 display_properties_.clear();
774 783
775 SaveImageData(NULL); 784 SaveImageData(NULL);
776 SaveColorData(); 785 SaveColorData();
777 SaveTintData(); 786 SaveTintData();
778 SaveDisplayPropertyData(); 787 SaveDisplayPropertyData();
788 SaveThemeID(kDefaultThemeID);
779 } 789 }
780 790
781 SkBitmap* BrowserThemeProvider::GenerateBitmap(int id) { 791 SkBitmap* BrowserThemeProvider::GenerateBitmap(int id) {
782 if (id == IDR_THEME_TAB_BACKGROUND || 792 if (id == IDR_THEME_TAB_BACKGROUND ||
783 id == IDR_THEME_TAB_BACKGROUND_INCOGNITO) { 793 id == IDR_THEME_TAB_BACKGROUND_INCOGNITO) {
784 // The requested image is a background tab. Get a frame to create the 794 // The requested image is a background tab. Get a frame to create the
785 // tab against. As themes don't use the glass frame, we don't have to 795 // tab against. As themes don't use the glass frame, we don't have to
786 // worry about compositing them together, as our default theme provides 796 // worry about compositing them together, as our default theme provides
787 // the necessary bitmaps. 797 // the necessary bitmaps.
788 int base_id = (id == IDR_THEME_TAB_BACKGROUND) ? 798 int base_id = (id == IDR_THEME_TAB_BACKGROUND) ?
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 if (base::strcasecmp((*iter).first.c_str(), 908 if (base::strcasecmp((*iter).first.c_str(),
899 kDisplayPropertyNTPInverseLogo) == 0) { 909 kDisplayPropertyNTPInverseLogo) == 0) {
900 pref_display_properties-> 910 pref_display_properties->
901 SetInteger(UTF8ToWide((*iter).first), (*iter).second); 911 SetInteger(UTF8ToWide((*iter).first), (*iter).second);
902 } 912 }
903 ++iter; 913 ++iter;
904 } 914 }
905 } 915 }
906 } 916 }
907 917
918 void BrowserThemeProvider::SaveThemeID(const std::string& id) {
919 profile_->GetPrefs()->SetString(prefs::kCurrentThemeID, UTF8ToWide(id));
920 }
921
908 void BrowserThemeProvider::NotifyThemeChanged() { 922 void BrowserThemeProvider::NotifyThemeChanged() {
909 // Redraw! 923 // Redraw!
910 NotificationService* service = NotificationService::current(); 924 NotificationService* service = NotificationService::current();
911 service->Notify(NotificationType::BROWSER_THEME_CHANGED, 925 service->Notify(NotificationType::BROWSER_THEME_CHANGED,
912 Source<BrowserThemeProvider>(this), 926 Source<BrowserThemeProvider>(this),
913 NotificationService::NoDetails()); 927 NotificationService::NoDetails());
914 } 928 }
915 929
916 void BrowserThemeProvider::LoadThemePrefs() { 930 void BrowserThemeProvider::LoadThemePrefs() {
917 PrefService* prefs = profile_->GetPrefs(); 931 PrefService* prefs = profile_->GetPrefs();
(...skipping 30 matching lines...) Expand all
948 delete i->second; 962 delete i->second;
949 } 963 }
950 image_cache_.clear(); 964 image_cache_.clear();
951 } 965 }
952 966
953 #if defined(TOOLKIT_VIEWS) 967 #if defined(TOOLKIT_VIEWS)
954 void BrowserThemeProvider::FreePlatformCaches() { 968 void BrowserThemeProvider::FreePlatformCaches() {
955 // Views (Skia) has no platform image cache to clear. 969 // Views (Skia) has no platform image cache to clear.
956 } 970 }
957 #endif 971 #endif
OLDNEW
« no previous file with comments | « chrome/browser/browser_theme_provider.h ('k') | chrome/browser/profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698