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

Side by Side Diff: chrome/browser/themes/theme_service_mac.mm

Issue 2473863004: Remove MaterialDesignController::IsModeMaterial (Closed)
Patch Set: pkasting review and rebase Created 4 years, 1 month 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 | « no previous file | chrome/browser/themes/theme_service_unittest.cc » ('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) 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"
11 #include "chrome/browser/themes/theme_properties.h" 11 #include "chrome/browser/themes/theme_properties.h"
12 #include "chrome/grit/theme_resources.h" 12 #include "chrome/grit/theme_resources.h"
13 #include "skia/ext/skia_utils_mac.h" 13 #include "skia/ext/skia_utils_mac.h"
14 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h" 14 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h"
15 #include "ui/base/material_design/material_design_controller.h"
16 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/color_utils.h" 16 #include "ui/gfx/color_utils.h"
18 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
19 18
20 @interface NSWorkspace (Redeclarations) 19 @interface NSWorkspace (Redeclarations)
21 20
22 @property(readonly) BOOL accessibilityDisplayShouldIncreaseContrast; 21 @property(readonly) BOOL accessibilityDisplayShouldIncreaseContrast;
23 22
24 @end 23 @end
25 24
(...skipping 19 matching lines...) Expand all
45 } // namespace 44 } // namespace
46 45
47 NSImage* ThemeService::GetNSImageNamed(int id, bool incognito) const { 46 NSImage* ThemeService::GetNSImageNamed(int id, bool incognito) const {
48 DCHECK(CalledOnValidThread()); 47 DCHECK(CalledOnValidThread());
49 48
50 bool is_tab_or_toolbar_color = 49 bool is_tab_or_toolbar_color =
51 id == IDR_THEME_TAB_BACKGROUND_INACTIVE || 50 id == IDR_THEME_TAB_BACKGROUND_INACTIVE ||
52 id == IDR_THEME_TOOLBAR_INACTIVE || 51 id == IDR_THEME_TOOLBAR_INACTIVE ||
53 id == IDR_THEME_TAB_BACKGROUND || 52 id == IDR_THEME_TAB_BACKGROUND ||
54 id == IDR_THEME_TOOLBAR; 53 id == IDR_THEME_TOOLBAR;
55 bool isModeMaterial = ui::MaterialDesignController::IsModeMaterial(); 54 // TODO(ellyjones): remove traces of the MD redesign from this file. See
55 // crbug.com/648281
56 bool isModeMaterial = true;
56 57
57 // In Material Design, Incognito mode draws tabs and the toolbar using colors 58 // In Material Design, Incognito mode draws tabs and the toolbar using colors
58 // that are different from non-Incognito mode. If in MD, offset these ids so 59 // that are different from non-Incognito mode. If in MD, offset these ids so
59 // that they don't conflict with the non-MD colors in the cache. 60 // that they don't conflict with the non-MD colors in the cache.
60 int original_id = id; 61 int original_id = id;
61 if (isModeMaterial && incognito && is_tab_or_toolbar_color) { 62 if (isModeMaterial && incognito && is_tab_or_toolbar_color) {
62 id += kMaterialDesignIdOffset; 63 id += kMaterialDesignIdOffset;
63 } 64 }
64 65
65 // Check to see if we already have the image in the cache. 66 // Check to see if we already have the image in the cache.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 147 }
147 148
148 NSColor* ThemeService::GetNSImageColorNamed(int id, bool incognito) const { 149 NSColor* ThemeService::GetNSImageColorNamed(int id, bool incognito) const {
149 DCHECK(CalledOnValidThread()); 150 DCHECK(CalledOnValidThread());
150 151
151 bool is_tab_or_toolbar_color = 152 bool is_tab_or_toolbar_color =
152 id == IDR_THEME_TAB_BACKGROUND_INACTIVE || 153 id == IDR_THEME_TAB_BACKGROUND_INACTIVE ||
153 id == IDR_THEME_TOOLBAR_INACTIVE || 154 id == IDR_THEME_TOOLBAR_INACTIVE ||
154 id == IDR_THEME_TAB_BACKGROUND || 155 id == IDR_THEME_TAB_BACKGROUND ||
155 id == IDR_THEME_TOOLBAR; 156 id == IDR_THEME_TOOLBAR;
156 bool isModeMaterial = ui::MaterialDesignController::IsModeMaterial(); 157 bool isModeMaterial = true;
157 158
158 // In Material Design, Incognito mode draws tabs and the toolbar using colors 159 // In Material Design, Incognito mode draws tabs and the toolbar using colors
159 // that are different from non-Incognito mode. If in MD, offset these ids so 160 // that are different from non-Incognito mode. If in MD, offset these ids so
160 // that they don't clash with the non-MD colors in the cache. 161 // that they don't clash with the non-MD colors in the cache.
161 int original_id = id; 162 int original_id = id;
162 if (isModeMaterial && incognito && is_tab_or_toolbar_color) { 163 if (isModeMaterial && incognito && is_tab_or_toolbar_color) {
163 id += kMaterialDesignIdOffset; 164 id += kMaterialDesignIdOffset;
164 } 165 }
165 166
166 // Check to see if we already have the color in the cache. 167 // Check to see if we already have the color in the cache.
(...skipping 15 matching lines...) Expand all
182 183
183 bool ThemeService::HasCustomColor(int id) const { 184 bool ThemeService::HasCustomColor(int id) const {
184 SkColor color; 185 SkColor color;
185 return theme_supplier_ && theme_supplier_->GetColor(id, &color); 186 return theme_supplier_ && theme_supplier_->GetColor(id, &color);
186 } 187 }
187 188
188 NSColor* ThemeService::GetNSColor(int id, bool incognito) const { 189 NSColor* ThemeService::GetNSColor(int id, bool incognito) const {
189 DCHECK(CalledOnValidThread()); 190 DCHECK(CalledOnValidThread());
190 191
191 int original_id = id; 192 int original_id = id;
192 const bool is_mode_material = ui::MaterialDesignController::IsModeMaterial(); 193 const bool is_mode_material = true;
193 if (is_mode_material && incognito) { 194 if (is_mode_material && incognito) {
194 id += kMaterialDesignIdOffset; 195 id += kMaterialDesignIdOffset;
195 } 196 }
196 197
197 // Check to see if we already have the color in the cache. 198 // Check to see if we already have the color in the cache.
198 NSColorMap::const_iterator nscolor_iter = nscolor_cache_.find(id); 199 NSColorMap::const_iterator nscolor_iter = nscolor_cache_.find(id);
199 if (nscolor_iter != nscolor_cache_.end()) 200 if (nscolor_iter != nscolor_cache_.end())
200 return nscolor_iter->second; 201 return nscolor_iter->second;
201 202
202 SkColor sk_color = GetColor(original_id, incognito); 203 SkColor sk_color = GetColor(original_id, incognito);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 387
387 bool ThemeService::BrowserThemeProvider::ShouldIncreaseContrast() const { 388 bool ThemeService::BrowserThemeProvider::ShouldIncreaseContrast() const {
388 NSWorkspace* workspace = [NSWorkspace sharedWorkspace]; 389 NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
389 if ([workspace 390 if ([workspace
390 respondsToSelector:@selector( 391 respondsToSelector:@selector(
391 accessibilityDisplayShouldIncreaseContrast)]) { 392 accessibilityDisplayShouldIncreaseContrast)]) {
392 return workspace.accessibilityDisplayShouldIncreaseContrast == YES; 393 return workspace.accessibilityDisplayShouldIncreaseContrast == YES;
393 } 394 }
394 return false; 395 return false;
395 } 396 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/themes/theme_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698