Chromium Code Reviews| 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/theme_service.h" | 5 #include "chrome/browser/themes/theme_service.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/themes/browser_theme_pack.h" | 10 #include "chrome/browser/themes/browser_theme_pack.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 | 176 |
| 177 bool ThemeService::HasCustomColor(int id) const { | 177 bool ThemeService::HasCustomColor(int id) const { |
| 178 SkColor color; | 178 SkColor color; |
| 179 return theme_supplier_ && theme_supplier_->GetColor(id, &color); | 179 return theme_supplier_ && theme_supplier_->GetColor(id, &color); |
| 180 } | 180 } |
| 181 | 181 |
| 182 NSColor* ThemeService::GetNSColor(int id, bool incognito) const { | 182 NSColor* ThemeService::GetNSColor(int id, bool incognito) const { |
| 183 DCHECK(CalledOnValidThread()); | 183 DCHECK(CalledOnValidThread()); |
| 184 | 184 |
| 185 int original_id = id; | 185 int original_id = id; |
| 186 if (ui::MaterialDesignController::IsModeMaterial() && incognito) { | 186 const bool kIsModeMaterial = ui::MaterialDesignController::IsModeMaterial(); |
|
sky
2016/05/26 22:32:57
mode_material as this isn't a compile time constan
shrike
2016/05/31 16:26:34
Acknowledged.
| |
| 187 if (kIsModeMaterial && incognito) { | |
| 187 id += kMaterialDesignIdOffset; | 188 id += kMaterialDesignIdOffset; |
| 188 } | 189 } |
| 189 | 190 |
| 190 // Check to see if we already have the color in the cache. | 191 // Check to see if we already have the color in the cache. |
| 191 NSColorMap::const_iterator nscolor_iter = nscolor_cache_.find(id); | 192 NSColorMap::const_iterator nscolor_iter = nscolor_cache_.find(id); |
| 192 if (nscolor_iter != nscolor_cache_.end()) | 193 if (nscolor_iter != nscolor_cache_.end()) |
| 193 return nscolor_iter->second; | 194 return nscolor_iter->second; |
| 194 | 195 |
| 195 SkColor sk_color = GetColor(original_id, incognito); | 196 SkColor sk_color = GetColor(original_id, incognito); |
| 196 NSColor* color = skia::SkColorToCalibratedNSColor(sk_color); | 197 NSColor* color = nil; |
| 198 if (kIsModeMaterial) { | |
| 199 color = skia::SkColorToSRGBNSColor(sk_color); | |
| 200 } else { | |
| 201 color = skia::SkColorToCalibratedNSColor(sk_color); | |
| 202 } | |
| 197 | 203 |
| 198 // We loaded successfully. Cache the color. | 204 // We loaded successfully. Cache the color. |
| 199 if (color) | 205 if (color) |
| 200 nscolor_cache_[id] = [color retain]; | 206 nscolor_cache_[id] = [color retain]; |
| 201 | 207 |
| 202 return color; | 208 return color; |
| 203 } | 209 } |
| 204 | 210 |
| 205 NSColor* ThemeService::GetNSColorTint(int id) const { | 211 NSColor* ThemeService::GetNSColorTint(int id) const { |
| 206 DCHECK(CalledOnValidThread()); | 212 DCHECK(CalledOnValidThread()); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 return theme_service_.GetNSColor(id, incognito_); | 398 return theme_service_.GetNSColor(id, incognito_); |
| 393 } | 399 } |
| 394 | 400 |
| 395 NSColor* ThemeService::BrowserThemeProvider::GetNSColorTint(int id) const { | 401 NSColor* ThemeService::BrowserThemeProvider::GetNSColorTint(int id) const { |
| 396 return theme_service_.GetNSColorTint(id); | 402 return theme_service_.GetNSColorTint(id); |
| 397 } | 403 } |
| 398 | 404 |
| 399 NSGradient* ThemeService::BrowserThemeProvider::GetNSGradient(int id) const { | 405 NSGradient* ThemeService::BrowserThemeProvider::GetNSGradient(int id) const { |
| 400 return theme_service_.GetNSGradient(id); | 406 return theme_service_.GetNSGradient(id); |
| 401 } | 407 } |
| OLD | NEW |