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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
26 #include "grit/ui_resources.h" | 26 #include "grit/ui_resources.h" |
27 #include "ui/base/layout.h" | 27 #include "ui/base/layout.h" |
28 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
29 #include "ui/gfx/image/image_skia.h" | 29 #include "ui/gfx/image/image_skia.h" |
30 | 30 |
31 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
32 #include "ui/base/win/shell.h" | 32 #include "ui/base/win/shell.h" |
33 #endif | 33 #endif |
34 | 34 |
35 #if defined(USE_AURA) && !defined(USE_ASH) && defined(OS_LINUX) | |
36 #include "ui/linux_ui/linux_ui.h" | |
37 #endif | |
38 | |
39 #if defined(ENABLE_MANAGED_USERS) | 35 #if defined(ENABLE_MANAGED_USERS) |
40 #include "chrome/browser/managed_mode/managed_user_service.h" | 36 #include "chrome/browser/managed_mode/managed_user_service.h" |
41 #endif | 37 #endif |
42 | 38 |
43 using content::BrowserThread; | 39 using content::BrowserThread; |
44 using content::UserMetricsAction; | 40 using content::UserMetricsAction; |
45 using extensions::Extension; | 41 using extensions::Extension; |
46 using ui::ResourceBundle; | 42 using ui::ResourceBundle; |
47 | 43 |
48 typedef ThemeProperties Properties; | 44 typedef ThemeProperties Properties; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 if (id == IDR_THEME_FRAME) | 110 if (id == IDR_THEME_FRAME) |
115 id = IDR_MANAGED_USER_THEME_FRAME; | 111 id = IDR_MANAGED_USER_THEME_FRAME; |
116 else if (id == IDR_THEME_FRAME_INACTIVE) | 112 else if (id == IDR_THEME_FRAME_INACTIVE) |
117 id = IDR_MANAGED_USER_THEME_FRAME_INACTIVE; | 113 id = IDR_MANAGED_USER_THEME_FRAME_INACTIVE; |
118 } | 114 } |
119 | 115 |
120 gfx::Image image; | 116 gfx::Image image; |
121 if (theme_pack_.get()) | 117 if (theme_pack_.get()) |
122 image = theme_pack_->GetImageNamed(id); | 118 image = theme_pack_->GetImageNamed(id); |
123 | 119 |
124 #if defined(USE_AURA) && !defined(USE_ASH) && defined(OS_LINUX) | |
125 const ui::LinuxUI* linux_ui = ui::LinuxUI::instance(); | |
126 if (image.IsEmpty() && linux_ui) | |
127 image = linux_ui->GetThemeImageNamed(id); | |
128 #endif | |
129 | |
130 if (image.IsEmpty()) | 120 if (image.IsEmpty()) |
131 image = rb_.GetNativeImageNamed(id); | 121 image = rb_.GetNativeImageNamed(id); |
132 | 122 |
133 return image; | 123 return image; |
134 } | 124 } |
135 | 125 |
136 gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id) const { | 126 gfx::ImageSkia* ThemeService::GetImageSkiaNamed(int id) const { |
137 gfx::Image image = GetImageNamed(id); | 127 gfx::Image image = GetImageNamed(id); |
138 if (image.IsEmpty()) | 128 if (image.IsEmpty()) |
139 return NULL; | 129 return NULL; |
(...skipping 10 matching lines...) Expand all Loading... |
150 if (id == Properties::COLOR_FRAME) | 140 if (id == Properties::COLOR_FRAME) |
151 id = Properties::COLOR_FRAME_MANAGED_USER; | 141 id = Properties::COLOR_FRAME_MANAGED_USER; |
152 else if (id == Properties::COLOR_FRAME_INACTIVE) | 142 else if (id == Properties::COLOR_FRAME_INACTIVE) |
153 id = Properties::COLOR_FRAME_MANAGED_USER_INACTIVE; | 143 id = Properties::COLOR_FRAME_MANAGED_USER_INACTIVE; |
154 } | 144 } |
155 | 145 |
156 SkColor color; | 146 SkColor color; |
157 if (theme_pack_.get() && theme_pack_->GetColor(id, &color)) | 147 if (theme_pack_.get() && theme_pack_->GetColor(id, &color)) |
158 return color; | 148 return color; |
159 | 149 |
160 #if defined(USE_AURA) && !defined(USE_ASH) && defined(OS_LINUX) | |
161 const ui::LinuxUI* linux_ui = ui::LinuxUI::instance(); | |
162 if (linux_ui && linux_ui->GetColor(id, &color)) | |
163 return color; | |
164 #endif | |
165 | |
166 // For backward compat with older themes, some newer colors are generated from | 150 // For backward compat with older themes, some newer colors are generated from |
167 // older ones if they are missing. | 151 // older ones if they are missing. |
168 switch (id) { | 152 switch (id) { |
169 case Properties::COLOR_NTP_SECTION_HEADER_TEXT: | 153 case Properties::COLOR_NTP_SECTION_HEADER_TEXT: |
170 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.30); | 154 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.30); |
171 case Properties::COLOR_NTP_SECTION_HEADER_TEXT_HOVER: | 155 case Properties::COLOR_NTP_SECTION_HEADER_TEXT_HOVER: |
172 return GetColor(Properties::COLOR_NTP_TEXT); | 156 return GetColor(Properties::COLOR_NTP_TEXT); |
173 case Properties::COLOR_NTP_SECTION_HEADER_RULE: | 157 case Properties::COLOR_NTP_SECTION_HEADER_RULE: |
174 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.70); | 158 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.70); |
175 case Properties::COLOR_NTP_SECTION_HEADER_RULE_LIGHT: | 159 case Properties::COLOR_NTP_SECTION_HEADER_RULE_LIGHT: |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 void ThemeService::OnInfobarDestroyed() { | 440 void ThemeService::OnInfobarDestroyed() { |
457 number_of_infobars_--; | 441 number_of_infobars_--; |
458 | 442 |
459 if (number_of_infobars_ == 0) | 443 if (number_of_infobars_ == 0) |
460 RemoveUnusedThemes(); | 444 RemoveUnusedThemes(); |
461 } | 445 } |
462 | 446 |
463 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { | 447 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { |
464 return theme_syncable_service_.get(); | 448 return theme_syncable_service_.get(); |
465 } | 449 } |
OLD | NEW |