Replace the default frame properties for managed users.
This is a temporary solution until we finish the real default theme.
BUG=241377
Review URL: https://chromiumcodereview.appspot.com/17498004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207674 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index 6e9802a..76d0b183 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -829,6 +829,8 @@
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_INCOGNITO_INACTIVE_WIN" file="theme_frame_incognito_inactive.png" />
</if>
</if>
+ <structure type="chrome_scaled_image" name="IDR_MANAGED_USER_THEME_FRAME" file="common/managed_user_theme/theme_frame_supervised.png" />
+ <structure type="chrome_scaled_image" name="IDR_MANAGED_USER_THEME_FRAME_INACTIVE" file="common/managed_user_theme/theme_frame_supervised_inactive.png" />
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_OVERLAY" file="notused.png" />
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_OVERLAY_INACTIVE" file="notused.png" />
<structure type="chrome_scaled_image" name="IDR_THEME_NTP_ATTRIBUTION" file="notused.png" />
diff --git a/chrome/browser/themes/theme_properties.cc b/chrome/browser/themes/theme_properties.cc
index ec777b6..0390af4 100644
--- a/chrome/browser/themes/theme_properties.cc
+++ b/chrome/browser/themes/theme_properties.cc
@@ -30,6 +30,9 @@
const SkColor kDefaultColorFrameIncognito = SkColorSetRGB(83, 106, 139);
const SkColor kDefaultColorFrameIncognitoInactive =
SkColorSetRGB(126, 139, 156);
+const SkColor kDefaultColorFrameManagedUser = SkColorSetRGB(165, 197, 225);
+const SkColor kDefaultColorFrameManagedUserInactive =
+ SkColorSetRGB(180, 225, 247);
#if defined(OS_MACOSX)
const SkColor kDefaultColorToolbar = SkColorSetRGB(230, 230, 230);
#else
@@ -249,6 +252,10 @@
return kDefaultColorFrameIncognito;
case COLOR_FRAME_INCOGNITO_INACTIVE:
return kDefaultColorFrameIncognitoInactive;
+ case COLOR_FRAME_MANAGED_USER:
+ return kDefaultColorFrameManagedUser;
+ case COLOR_FRAME_MANAGED_USER_INACTIVE:
+ return kDefaultColorFrameManagedUserInactive;
case COLOR_TOOLBAR:
return kDefaultColorToolbar;
case COLOR_TAB_TEXT:
diff --git a/chrome/browser/themes/theme_properties.h b/chrome/browser/themes/theme_properties.h
index 2eaa1ed7..0f503c9c 100644
--- a/chrome/browser/themes/theme_properties.h
+++ b/chrome/browser/themes/theme_properties.h
@@ -80,6 +80,8 @@
enum NotOverwritableByUserThemeProperty {
COLOR_CONTROL_BACKGROUND = 1000,
COLOR_TOOLBAR_SEPARATOR,
+ COLOR_FRAME_MANAGED_USER,
+ COLOR_FRAME_MANAGED_USER_INACTIVE,
// These colors don't have constant default values. They are derived from
// the runtime value of other colors.
diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc
index 6a90368..1a7cb7b2 100644
--- a/chrome/browser/themes/theme_service.cc
+++ b/chrome/browser/themes/theme_service.cc
@@ -36,6 +36,10 @@
#include "ui/linux_ui/linux_ui.h"
#endif
+#if defined(ENABLE_MANAGED_USERS)
+#include "chrome/browser/managed_mode/managed_user_service.h"
+#endif
+
using content::BrowserThread;
using content::UserMetricsAction;
using extensions::Extension;
@@ -104,6 +108,15 @@
gfx::Image ThemeService::GetImageNamed(int id) const {
DCHECK(CalledOnValidThread());
+ // For a managed user, use the special frame instead of the default one.
+ // TODO(akuegel): Remove this once we have the default managed user theme.
+ if (IsManagedUser()) {
+ if (id == IDR_THEME_FRAME)
+ id = IDR_MANAGED_USER_THEME_FRAME;
+ else if (id == IDR_THEME_FRAME_INACTIVE)
+ id = IDR_MANAGED_USER_THEME_FRAME_INACTIVE;
+ }
+
gfx::Image image;
if (theme_pack_.get())
image = theme_pack_->GetImageNamed(id);
@@ -132,6 +145,14 @@
SkColor ThemeService::GetColor(int id) const {
DCHECK(CalledOnValidThread());
+ // TODO(akuegel): Remove this once we have the default managed user theme.
+ if (IsManagedUser()) {
+ if (id == Properties::COLOR_FRAME)
+ id = Properties::COLOR_FRAME_MANAGED_USER;
+ else if (id == Properties::COLOR_FRAME_INACTIVE)
+ id = Properties::COLOR_FRAME_MANAGED_USER_INACTIVE;
+ }
+
SkColor color;
if (theme_pack_.get() && theme_pack_->GetColor(id, &color))
return color;
@@ -157,11 +178,13 @@
return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.40);
case Properties::COLOR_MANAGED_USER_LABEL:
return color_utils::GetReadableColor(
- SK_ColorWHITE,
+ SkColorSetRGB(231, 245, 255),
GetColor(Properties::COLOR_MANAGED_USER_LABEL_BACKGROUND));
case Properties::COLOR_MANAGED_USER_LABEL_BACKGROUND:
- return color_utils::BlendTowardOppositeLuminance(
- GetColor(Properties::COLOR_FRAME), 0x80);
+ // TODO(akuegel): Replace this constant by a color calculated from the
+ // frame color once the default managed user theme is finished and we
+ // allow managed users to install other themes.
+ return SkColorSetRGB(108, 167, 210);
}
return Properties::GetDefaultColor(id);
@@ -419,6 +442,13 @@
theme_pack_ = pack;
}
+bool ThemeService::IsManagedUser() const {
+#if defined(ENABLE_MANAGED_USERS)
+ return ManagedUserService::ProfileIsManaged(profile_);
+#endif
+ return false;
+}
+
void ThemeService::OnInfobarDisplayed() {
number_of_infobars_++;
}
diff --git a/chrome/browser/themes/theme_service.h b/chrome/browser/themes/theme_service.h
index 48f320d2c..b6d88696 100644
--- a/chrome/browser/themes/theme_service.h
+++ b/chrome/browser/themes/theme_service.h
@@ -163,7 +163,7 @@
// from ClearCaches().
virtual void FreePlatformCaches();
- Profile* profile() { return profile_; }
+ Profile* profile() const { return profile_; }
void set_ready() { ready_ = true; }
@@ -184,6 +184,9 @@
// case we don't have a theme pack).
void BuildFromExtension(const extensions::Extension* extension);
+ // Returns true if the profile belongs to a managed user.
+ bool IsManagedUser() const;
+
#if defined(TOOLKIT_GTK)
// Loads an image and flips it horizontally if |rtl_enabled| is true.
GdkPixbuf* GetPixbufImpl(int id, bool rtl_enabled) const;
diff --git a/chrome/browser/ui/gtk/gtk_theme_service.cc b/chrome/browser/ui/gtk/gtk_theme_service.cc
index 5ab6203..143ddcb0 100644
--- a/chrome/browser/ui/gtk/gtk_theme_service.cc
+++ b/chrome/browser/ui/gtk/gtk_theme_service.cc
@@ -15,6 +15,7 @@
#include "base/nix/xdg_util.h"
#include "base/prefs/pref_service.h"
#include "base/stl_util.h"
+#include "chrome/browser/managed_mode/managed_user_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service_factory.h"
@@ -308,6 +309,14 @@
}
gfx::Image GtkThemeService::GetImageNamed(int id) const {
+ // TODO(akuegel): Remove this once we have the default managed user theme.
+ if (ManagedUserService::ProfileIsManaged(profile())) {
+ if (id == IDR_THEME_FRAME)
+ id = IDR_MANAGED_USER_THEME_FRAME;
+ else if (id == IDR_THEME_FRAME_INACTIVE)
+ id = IDR_MANAGED_USER_THEME_FRAME_INACTIVE;
+ }
+
// Try to get our cached version:
ImageCache::const_iterator it = gtk_images_.find(id);
if (it != gtk_images_.end())
@@ -324,6 +333,14 @@
}
SkColor GtkThemeService::GetColor(int id) const {
+ // TODO(akuegel): Remove this once we have the default managed user theme.
+ if (ManagedUserService::ProfileIsManaged(profile())) {
+ if (id == ThemeProperties::COLOR_FRAME)
+ id = ThemeProperties::COLOR_FRAME_MANAGED_USER;
+ else if (id == ThemeProperties::COLOR_FRAME_INACTIVE)
+ id = ThemeProperties::COLOR_FRAME_MANAGED_USER_INACTIVE;
+ }
+
if (use_gtk_) {
ColorMap::const_iterator it = colors_.find(id);
if (it != colors_.end())