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

Side by Side Diff: chrome/browser/themes/theme_service.cc

Issue 2909183002: Replace deprecated base::NonThreadSafe in chrome/browser/themes in favor of SequenceChecker. (Closed)
Patch Set: Merge with theme_service_mac.mm changes Created 3 years, 6 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
« no previous file with comments | « chrome/browser/themes/theme_service.h ('k') | chrome/browser/themes/theme_service_mac.mm » ('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) 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 : ready_(false), 218 : ready_(false),
219 rb_(ResourceBundle::GetSharedInstance()), 219 rb_(ResourceBundle::GetSharedInstance()),
220 profile_(nullptr), 220 profile_(nullptr),
221 installed_pending_load_id_(kDefaultThemeID), 221 installed_pending_load_id_(kDefaultThemeID),
222 number_of_infobars_(0), 222 number_of_infobars_(0),
223 original_theme_provider_(*this, false), 223 original_theme_provider_(*this, false),
224 incognito_theme_provider_(*this, true), 224 incognito_theme_provider_(*this, true),
225 weak_ptr_factory_(this) {} 225 weak_ptr_factory_(this) {}
226 226
227 ThemeService::~ThemeService() { 227 ThemeService::~ThemeService() {
228 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
228 FreePlatformCaches(); 229 FreePlatformCaches();
229 } 230 }
230 231
231 void ThemeService::Init(Profile* profile) { 232 void ThemeService::Init(Profile* profile) {
232 DCHECK(CalledOnValidThread()); 233 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
233 profile_ = profile; 234 profile_ = profile;
234 235
235 LoadThemePrefs(); 236 LoadThemePrefs();
236 237
237 registrar_.Add(this, 238 registrar_.Add(this,
238 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED, 239 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
239 content::Source<Profile>(profile_)); 240 content::Source<Profile>(profile_));
240 241
241 theme_syncable_service_.reset(new ThemeSyncableService(profile_, this)); 242 theme_syncable_service_.reset(new ThemeSyncableService(profile_, this));
242 } 243 }
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 #endif 514 #endif
514 } 515 }
515 516
516 // Always fall back to the non-incognito color when there's a custom theme 517 // Always fall back to the non-incognito color when there's a custom theme
517 // because the default (classic) incognito color may be dramatically different 518 // because the default (classic) incognito color may be dramatically different
518 // (optimized for a light-on-dark color). 519 // (optimized for a light-on-dark color).
519 return ThemeProperties::GetDefaultColor(id, incognito && !theme_supplier_); 520 return ThemeProperties::GetDefaultColor(id, incognito && !theme_supplier_);
520 } 521 }
521 522
522 color_utils::HSL ThemeService::GetTint(int id, bool incognito) const { 523 color_utils::HSL ThemeService::GetTint(int id, bool incognito) const {
523 DCHECK(CalledOnValidThread()); 524 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
524 525
525 color_utils::HSL hsl; 526 color_utils::HSL hsl;
526 if (theme_supplier_ && theme_supplier_->GetTint(id, &hsl)) 527 if (theme_supplier_ && theme_supplier_->GetTint(id, &hsl))
527 return hsl; 528 return hsl;
528 529
529 // Always fall back to the non-incognito tint when there's a custom theme. 530 // Always fall back to the non-incognito tint when there's a custom theme.
530 // See comment in GetDefaultColor(). 531 // See comment in GetDefaultColor().
531 return ThemeProperties::GetDefaultTint(id, incognito && !theme_supplier_); 532 return ThemeProperties::GetDefaultTint(id, incognito && !theme_supplier_);
532 } 533 }
533 534
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id, bool incognito) const { 688 gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id, bool incognito) const {
688 gfx::Image image = GetImageNamed(id, incognito); 689 gfx::Image image = GetImageNamed(id, incognito);
689 if (image.IsEmpty()) 690 if (image.IsEmpty())
690 return nullptr; 691 return nullptr;
691 // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns 692 // TODO(pkotwicz): Remove this const cast. The gfx::Image interface returns
692 // its images const. GetImageSkiaNamed() also should but has many callsites. 693 // its images const. GetImageSkiaNamed() also should but has many callsites.
693 return const_cast<gfx::ImageSkia*>(image.ToImageSkia()); 694 return const_cast<gfx::ImageSkia*>(image.ToImageSkia());
694 } 695 }
695 696
696 SkColor ThemeService::GetColor(int id, bool incognito) const { 697 SkColor ThemeService::GetColor(int id, bool incognito) const {
697 DCHECK(CalledOnValidThread()); 698 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
698 699
699 // For legacy reasons, |theme_supplier_| requires the incognito variants 700 // For legacy reasons, |theme_supplier_| requires the incognito variants
700 // of color IDs. 701 // of color IDs.
701 int theme_supplier_id = id; 702 int theme_supplier_id = id;
702 if (incognito) { 703 if (incognito) {
703 if (id == ThemeProperties::COLOR_FRAME) 704 if (id == ThemeProperties::COLOR_FRAME)
704 theme_supplier_id = ThemeProperties::COLOR_FRAME_INCOGNITO; 705 theme_supplier_id = ThemeProperties::COLOR_FRAME_INCOGNITO;
705 else if (id == ThemeProperties::COLOR_FRAME_INACTIVE) 706 else if (id == ThemeProperties::COLOR_FRAME_INACTIVE)
706 theme_supplier_id = ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE; 707 theme_supplier_id = ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE;
707 } 708 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 base::RefCountedMemory* data = nullptr; 752 base::RefCountedMemory* data = nullptr;
752 if (theme_supplier_) 753 if (theme_supplier_)
753 data = theme_supplier_->GetRawData(id, scale_factor); 754 data = theme_supplier_->GetRawData(id, scale_factor);
754 if (!data) 755 if (!data)
755 data = rb_.LoadDataResourceBytesForScale(id, ui::SCALE_FACTOR_100P); 756 data = rb_.LoadDataResourceBytesForScale(id, ui::SCALE_FACTOR_100P);
756 757
757 return data; 758 return data;
758 } 759 }
759 760
760 gfx::Image ThemeService::GetImageNamed(int id, bool incognito) const { 761 gfx::Image ThemeService::GetImageNamed(int id, bool incognito) const {
761 DCHECK(CalledOnValidThread()); 762 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
762 763
763 int adjusted_id = id; 764 int adjusted_id = id;
764 if (incognito) { 765 if (incognito) {
765 if (id == IDR_THEME_FRAME) 766 if (id == IDR_THEME_FRAME)
766 adjusted_id = IDR_THEME_FRAME_INCOGNITO; 767 adjusted_id = IDR_THEME_FRAME_INCOGNITO;
767 else if (id == IDR_THEME_FRAME_INACTIVE) 768 else if (id == IDR_THEME_FRAME_INACTIVE)
768 adjusted_id = IDR_THEME_FRAME_INCOGNITO_INACTIVE; 769 adjusted_id = IDR_THEME_FRAME_INCOGNITO_INACTIVE;
769 } 770 }
770 771
771 gfx::Image image; 772 gfx::Image image;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 869
869 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) 870 #if BUILDFLAG(ENABLE_SUPERVISED_USERS)
870 bool ThemeService::IsSupervisedUser() const { 871 bool ThemeService::IsSupervisedUser() const {
871 return profile_->IsSupervised(); 872 return profile_->IsSupervised();
872 } 873 }
873 874
874 void ThemeService::SetSupervisedUserTheme() { 875 void ThemeService::SetSupervisedUserTheme() {
875 SetCustomDefaultTheme(new SupervisedUserTheme); 876 SetCustomDefaultTheme(new SupervisedUserTheme);
876 } 877 }
877 #endif 878 #endif
OLDNEW
« no previous file with comments | « chrome/browser/themes/theme_service.h ('k') | chrome/browser/themes/theme_service_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698