1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "chrome/browser/supervised_user/supervised_user_theme.h" 6 7 #include "chrome/browser/themes/theme_properties.h" 8 #include "grit/theme_resources.h" 9 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/gfx/image/image.h" 11 12 namespace { 13 14 const SkColor kDefaultColorFrameSupervisedUser = SkColorSetRGB(165, 197, 225); 15 const SkColor kDefaultColorFrameSupervisedUserInactive = 16 SkColorSetRGB(180, 225, 247); 17 const SkColor kDefaultColorSupervisedUserLabelBackground = 18 SkColorSetRGB(108, 167, 210); 19 20 // Map resource ids to the supervised user resource ids. MapToSupervisedUserResourceIds(int id)21int MapToSupervisedUserResourceIds(int id) { 22 switch (id) { 23 case IDR_THEME_FRAME: 24 #if defined(USE_ASH) && !defined(OS_CHROMEOS) 25 case IDR_THEME_FRAME_DESKTOP: 26 #endif 27 return IDR_SUPERVISED_USER_THEME_FRAME; 28 case IDR_THEME_FRAME_INACTIVE: 29 #if defined(USE_ASH) && !defined(OS_CHROMEOS) 30 case IDR_THEME_FRAME_INACTIVE_DESKTOP: 31 #endif 32 return IDR_SUPERVISED_USER_THEME_FRAME_INACTIVE; 33 case IDR_THEME_TAB_BACKGROUND: 34 case IDR_THEME_TAB_BACKGROUND_V: 35 #if defined(USE_ASH) && !defined(OS_CHROMEOS) 36 case IDR_THEME_TAB_BACKGROUND_DESKTOP: 37 #endif 38 return IDR_SUPERVISED_USER_THEME_TAB_BACKGROUND; 39 } 40 return id; 41 } 42 43 } // namespace 44 SupervisedUserTheme()45SupervisedUserTheme::SupervisedUserTheme() 46 : CustomThemeSupplier(SUPERVISED_USER_THEME) {} 47 ~SupervisedUserTheme()48SupervisedUserTheme::~SupervisedUserTheme() {} 49 GetColor(int id,SkColor * color) const50bool SupervisedUserTheme::GetColor(int id, SkColor* color) const { 51 switch (id) { 52 case ThemeProperties::COLOR_FRAME: 53 *color = kDefaultColorFrameSupervisedUser; 54 return true; 55 case ThemeProperties::COLOR_FRAME_INACTIVE: 56 *color = kDefaultColorFrameSupervisedUserInactive; 57 return true; 58 case ThemeProperties::COLOR_SUPERVISED_USER_LABEL: 59 *color = SK_ColorWHITE; 60 return true; 61 case ThemeProperties::COLOR_SUPERVISED_USER_LABEL_BACKGROUND: 62 *color = kDefaultColorSupervisedUserLabelBackground; 63 return true; 64 } 65 return false; 66 } 67 GetImageNamed(int id)68gfx::Image SupervisedUserTheme::GetImageNamed(int id) { 69 if (!HasCustomImage(id)) 70 return gfx::Image(); 71 72 id = MapToSupervisedUserResourceIds(id); 73 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(id); 74 } 75 HasCustomImage(int id) const76bool SupervisedUserTheme::HasCustomImage(int id) const { 77 return id != MapToSupervisedUserResourceIds(id); 78 } 79