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

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

Issue 355233002: Fix build when ENABLE_MANAGED_USERS is not defined (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Include missing browsertest .js file in chrome_tests.gypi Created 6 years, 2 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_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) 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/supervised_user/supervised_user_theme.h"
20 #include "chrome/browser/themes/browser_theme_pack.h" 19 #include "chrome/browser/themes/browser_theme_pack.h"
21 #include "chrome/browser/themes/custom_theme_supplier.h" 20 #include "chrome/browser/themes/custom_theme_supplier.h"
22 #include "chrome/browser/themes/theme_properties.h" 21 #include "chrome/browser/themes/theme_properties.h"
23 #include "chrome/browser/themes/theme_syncable_service.h" 22 #include "chrome/browser/themes/theme_syncable_service.h"
24 #include "chrome/common/chrome_constants.h" 23 #include "chrome/common/chrome_constants.h"
25 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
26 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
27 #include "content/public/browser/user_metrics.h" 26 #include "content/public/browser/user_metrics.h"
28 #include "extensions/browser/extension_prefs.h" 27 #include "extensions/browser/extension_prefs.h"
29 #include "extensions/browser/extension_registry.h" 28 #include "extensions/browser/extension_registry.h"
30 #include "extensions/browser/extension_system.h" 29 #include "extensions/browser/extension_system.h"
31 #include "extensions/browser/uninstall_reason.h" 30 #include "extensions/browser/uninstall_reason.h"
32 #include "extensions/common/extension.h" 31 #include "extensions/common/extension.h"
33 #include "extensions/common/extension_set.h" 32 #include "extensions/common/extension_set.h"
34 #include "grit/theme_resources.h" 33 #include "grit/theme_resources.h"
35 #include "ui/base/layout.h" 34 #include "ui/base/layout.h"
36 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
37 #include "ui/gfx/image/image_skia.h" 36 #include "ui/gfx/image/image_skia.h"
38 37
38 #if defined(ENABLE_MANAGED_USERS)
39 #include "chrome/browser/supervised_user/supervised_user_theme.h"
40 #endif
41
39 #if defined(OS_WIN) 42 #if defined(OS_WIN)
40 #include "ui/base/win/shell.h" 43 #include "ui/base/win/shell.h"
41 #endif 44 #endif
42 45
43 using base::UserMetricsAction; 46 using base::UserMetricsAction;
44 using content::BrowserThread; 47 using content::BrowserThread;
45 using extensions::Extension; 48 using extensions::Extension;
46 using extensions::UnloadedExtensionInfo; 49 using extensions::UnloadedExtensionInfo;
47 using ui::ResourceBundle; 50 using ui::ResourceBundle;
48 51
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 case Properties::COLOR_NTP_SECTION_HEADER_TEXT: 164 case Properties::COLOR_NTP_SECTION_HEADER_TEXT:
162 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.30); 165 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.30);
163 case Properties::COLOR_NTP_SECTION_HEADER_TEXT_HOVER: 166 case Properties::COLOR_NTP_SECTION_HEADER_TEXT_HOVER:
164 return GetColor(Properties::COLOR_NTP_TEXT); 167 return GetColor(Properties::COLOR_NTP_TEXT);
165 case Properties::COLOR_NTP_SECTION_HEADER_RULE: 168 case Properties::COLOR_NTP_SECTION_HEADER_RULE:
166 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.70); 169 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.70);
167 case Properties::COLOR_NTP_SECTION_HEADER_RULE_LIGHT: 170 case Properties::COLOR_NTP_SECTION_HEADER_RULE_LIGHT:
168 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.86); 171 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.86);
169 case Properties::COLOR_NTP_TEXT_LIGHT: 172 case Properties::COLOR_NTP_TEXT_LIGHT:
170 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.40); 173 return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.40);
174 #if defined(ENABLE_MANAGED_USERS)
171 case Properties::COLOR_SUPERVISED_USER_LABEL: 175 case Properties::COLOR_SUPERVISED_USER_LABEL:
172 return color_utils::GetReadableColor( 176 return color_utils::GetReadableColor(
173 SK_ColorWHITE, 177 SK_ColorWHITE,
174 GetColor(Properties::COLOR_SUPERVISED_USER_LABEL_BACKGROUND)); 178 GetColor(Properties::COLOR_SUPERVISED_USER_LABEL_BACKGROUND));
175 case Properties::COLOR_SUPERVISED_USER_LABEL_BACKGROUND: 179 case Properties::COLOR_SUPERVISED_USER_LABEL_BACKGROUND:
176 return color_utils::BlendTowardOppositeLuminance( 180 return color_utils::BlendTowardOppositeLuminance(
177 GetColor(Properties::COLOR_FRAME), 0x80); 181 GetColor(Properties::COLOR_FRAME), 0x80);
178 case Properties::COLOR_SUPERVISED_USER_LABEL_BORDER: 182 case Properties::COLOR_SUPERVISED_USER_LABEL_BORDER:
179 return color_utils::AlphaBlend( 183 return color_utils::AlphaBlend(
180 GetColor(Properties::COLOR_SUPERVISED_USER_LABEL_BACKGROUND), 184 GetColor(Properties::COLOR_SUPERVISED_USER_LABEL_BACKGROUND),
181 SK_ColorBLACK, 185 SK_ColorBLACK,
182 230); 186 230);
187 #endif
183 case Properties::COLOR_STATUS_BAR_TEXT: { 188 case Properties::COLOR_STATUS_BAR_TEXT: {
184 // A long time ago, we blended the toolbar and the tab text together to 189 // A long time ago, we blended the toolbar and the tab text together to
185 // get the status bar text because, at the time, our text rendering in 190 // get the status bar text because, at the time, our text rendering in
186 // views couldn't do alpha blending. Even though this is no longer the 191 // views couldn't do alpha blending. Even though this is no longer the
187 // case, this blending decision is built into the majority of themes that 192 // case, this blending decision is built into the majority of themes that
188 // exist, and we must keep doing it. 193 // exist, and we must keep doing it.
189 SkColor toolbar_color = GetColor(Properties::COLOR_TOOLBAR); 194 SkColor toolbar_color = GetColor(Properties::COLOR_TOOLBAR);
190 SkColor text_color = GetColor(Properties::COLOR_TAB_TEXT); 195 SkColor text_color = GetColor(Properties::COLOR_TAB_TEXT);
191 return SkColorSetARGB( 196 return SkColorSetARGB(
192 SkColorGetA(text_color), 197 SkColorGetA(text_color),
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 service->UninstallExtension(remove_list[i], 393 service->UninstallExtension(remove_list[i],
389 extensions::UNINSTALL_REASON_ORPHANED_THEME, 394 extensions::UNINSTALL_REASON_ORPHANED_THEME,
390 base::Bind(&base::DoNothing), 395 base::Bind(&base::DoNothing),
391 NULL); 396 NULL);
392 } 397 }
393 } 398 }
394 399
395 void ThemeService::UseDefaultTheme() { 400 void ThemeService::UseDefaultTheme() {
396 if (ready_) 401 if (ready_)
397 content::RecordAction(UserMetricsAction("Themes_Reset")); 402 content::RecordAction(UserMetricsAction("Themes_Reset"));
403 #if defined(ENABLE_MANAGED_USERS)
398 if (IsSupervisedUser()) { 404 if (IsSupervisedUser()) {
399 SetSupervisedUserTheme(); 405 SetSupervisedUserTheme();
400 return; 406 return;
401 } 407 }
408 #endif
402 ClearAllThemeData(); 409 ClearAllThemeData();
403 NotifyThemeChanged(); 410 NotifyThemeChanged();
404 } 411 }
405 412
406 void ThemeService::UseSystemTheme() { 413 void ThemeService::UseSystemTheme() {
407 UseDefaultTheme(); 414 UseDefaultTheme();
408 } 415 }
409 416
410 bool ThemeService::UsingDefaultTheme() const { 417 bool ThemeService::UsingDefaultTheme() const {
411 std::string id = GetThemeID(); 418 std::string id = GetThemeID();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 base::Bind(&ThemeService::RemoveUnusedThemes, 454 base::Bind(&ThemeService::RemoveUnusedThemes,
448 weak_ptr_factory_.GetWeakPtr(), 455 weak_ptr_factory_.GetWeakPtr(),
449 true)); 456 true));
450 } 457 }
451 458
452 void ThemeService::LoadThemePrefs() { 459 void ThemeService::LoadThemePrefs() {
453 PrefService* prefs = profile_->GetPrefs(); 460 PrefService* prefs = profile_->GetPrefs();
454 461
455 std::string current_id = GetThemeID(); 462 std::string current_id = GetThemeID();
456 if (current_id == kDefaultThemeID) { 463 if (current_id == kDefaultThemeID) {
464 #if defined(ENABLE_MANAGED_USERS)
457 // Supervised users have a different default theme. 465 // Supervised users have a different default theme.
458 if (IsSupervisedUser()) 466 if (IsSupervisedUser()) {
459 SetSupervisedUserTheme(); 467 SetSupervisedUserTheme();
460 else if (ShouldInitWithSystemTheme()) 468 set_ready();
469 return;
470 }
471 #endif
472 if (ShouldInitWithSystemTheme())
461 UseSystemTheme(); 473 UseSystemTheme();
462 else 474 else
463 UseDefaultTheme(); 475 UseDefaultTheme();
464 set_ready(); 476 set_ready();
465 return; 477 return;
466 } 478 }
467 479
468 bool loaded_pack = false; 480 bool loaded_pack = false;
469 481
470 // If we don't have a file pack, we're updating from an old version. 482 // If we don't have a file pack, we're updating from an old version.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 base::FilePath pack_path = 609 base::FilePath pack_path =
598 extension->path().Append(chrome::kThemePackFilename); 610 extension->path().Append(chrome::kThemePackFilename);
599 service->GetFileTaskRunner()->PostTask( 611 service->GetFileTaskRunner()->PostTask(
600 FROM_HERE, 612 FROM_HERE,
601 base::Bind(&WritePackToDiskCallback, pack, pack_path)); 613 base::Bind(&WritePackToDiskCallback, pack, pack_path));
602 614
603 SavePackName(pack_path); 615 SavePackName(pack_path);
604 SwapThemeSupplier(pack); 616 SwapThemeSupplier(pack);
605 } 617 }
606 618
619 #if defined(ENABLE_MANAGED_USERS)
607 bool ThemeService::IsSupervisedUser() const { 620 bool ThemeService::IsSupervisedUser() const {
608 return profile_->IsSupervised(); 621 return profile_->IsSupervised();
609 } 622 }
610 623
611 void ThemeService::SetSupervisedUserTheme() { 624 void ThemeService::SetSupervisedUserTheme() {
612 SetCustomDefaultTheme(new SupervisedUserTheme); 625 SetCustomDefaultTheme(new SupervisedUserTheme);
613 } 626 }
627 #endif
614 628
615 void ThemeService::OnInfobarDisplayed() { 629 void ThemeService::OnInfobarDisplayed() {
616 number_of_infobars_++; 630 number_of_infobars_++;
617 } 631 }
618 632
619 void ThemeService::OnInfobarDestroyed() { 633 void ThemeService::OnInfobarDestroyed() {
620 number_of_infobars_--; 634 number_of_infobars_--;
621 635
622 if (number_of_infobars_ == 0) 636 if (number_of_infobars_ == 0)
623 RemoveUnusedThemes(false); 637 RemoveUnusedThemes(false);
624 } 638 }
625 639
626 ThemeSyncableService* ThemeService::GetThemeSyncableService() const { 640 ThemeSyncableService* ThemeService::GetThemeSyncableService() const {
627 return theme_syncable_service_.get(); 641 return theme_syncable_service_.get();
628 } 642 }
OLDNEW
« no previous file with comments | « chrome/browser/themes/theme_service.h ('k') | chrome/browser/themes/theme_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698