summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormckev <mckev@amazon.com>2014-09-29 11:52:33 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-29 18:52:52 +0000
commita1a18dc36d89030a8fb6c514fcdf3c7a0153ee07 (patch)
tree27a8192d93d94be6a459438a4e389af05fc29a91
parenta391bbc3a20480c1d16fb7b8b51654413023c1c5 (diff)
downloadchromium_src-a1a18dc36d89030a8fb6c514fcdf3c7a0153ee07.zip
chromium_src-a1a18dc36d89030a8fb6c514fcdf3c7a0153ee07.tar.gz
chromium_src-a1a18dc36d89030a8fb6c514fcdf3c7a0153ee07.tar.bz2
Fix build when ENABLE_MANAGED_USERS is not defined
This commit resolves build errors that occur when ENABLE_MANAGED_USERS is not defined: 1. Managed/supervised code for various components are now conditionally excluded in gyp files. 2. Added #ifdef guards in source files that include files in the chrome/browser/supervised_user folder. 3. Add missing include to supervised_users.h in files in the supervised_user folder to force compiler errors when not guarded properly. 4. Added an include in create_profile_handler.cc to web_ui.h, since it is indirectly included by the supervised_user* .h files. BUG=389611 Review URL: https://codereview.chromium.org/355233002 Cr-Commit-Position: refs/heads/master@{#297219}
-rw-r--r--chrome/browser/extensions/extension_service_unittest.cc9
-rw-r--r--chrome/browser/search/search_unittest.cc11
-rw-r--r--chrome/browser/supervised_user/supervised_user_theme.h1
-rw-r--r--chrome/browser/themes/theme_properties.h2
-rw-r--r--chrome/browser/themes/theme_service.cc20
-rw-r--r--chrome/browser/themes/theme_service.h2
-rw-r--r--chrome/browser/themes/theme_service_unittest.cc11
-rw-r--r--chrome/browser/ui/startup/startup_browser_creator_browsertest.cc9
-rw-r--r--chrome/browser/ui/view_ids.h4
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view.cc37
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view.h18
-rw-r--r--chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc15
-rw-r--r--chrome/browser/ui/views/frame/opaque_browser_frame_view.cc34
-rw-r--r--chrome/browser/ui/views/frame/opaque_browser_frame_view.h3
-rw-r--r--chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc46
-rw-r--r--chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h9
-rw-r--r--chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc134
-rw-r--r--chrome/browser/ui/views/profiles/supervised_user_avatar_label.cc (renamed from chrome/browser/ui/views/profiles/avatar_label.cc)31
-rw-r--r--chrome/browser/ui/views/profiles/supervised_user_avatar_label.h (renamed from chrome/browser/ui/views/profiles/avatar_label.h)17
-rw-r--r--chrome/browser/ui/webui/downloads_ui_browsertest.cc9
-rw-r--r--chrome/browser/ui/webui/downloads_ui_browsertest.h6
-rw-r--r--chrome/browser/ui/webui/downloads_ui_browsertest.js153
-rw-r--r--chrome/browser/ui/webui/downloads_ui_browsertest_base.js134
-rw-r--r--chrome/browser/ui/webui/downloads_ui_supervised_browsertest.cc15
-rw-r--r--chrome/browser/ui/webui/downloads_ui_supervised_browsertest.h16
-rw-r--r--chrome/browser/ui/webui/downloads_ui_supervised_browsertest.js27
-rw-r--r--chrome/browser/ui/webui/extensions/extension_settings_handler.cc2
-rw-r--r--chrome/browser/ui/webui/options/create_profile_handler.cc361
-rw-r--r--chrome/browser/ui/webui/options/create_profile_handler.h88
-rw-r--r--chrome/browser/ui/webui/options/options_ui.cc8
-rw-r--r--chrome/chrome_browser_ui.gypi16
-rw-r--r--chrome/chrome_tests.gypi17
32 files changed, 755 insertions, 510 deletions
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index 3743654..9280b0a 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -60,8 +60,6 @@
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
-#include "chrome/browser/supervised_user/supervised_user_service.h"
-#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/chrome_constants.h"
@@ -130,6 +128,11 @@
#include "testing/platform_test.h"
#include "url/gurl.h"
+#if defined(ENABLE_MANAGED_USERS)
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#endif
+
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
@@ -6111,6 +6114,7 @@ TEST_F(ExtensionServiceTest, ProcessSyncDataNotInstalled) {
// TODO(akalin): Figure out a way to test |info.ShouldAllowInstall()|.
}
+#if defined(ENABLE_MANAGED_USERS)
TEST_F(ExtensionServiceTest, SupervisedUser_InstallOnlyAllowedByCustodian) {
ExtensionServiceInitParams params = CreateDefaultInitParams();
params.profile_is_supervised = true;
@@ -6265,6 +6269,7 @@ TEST_F(ExtensionServiceTest,
EXPECT_FALSE(
registry()->GenerateInstalledExtensionsSet()->Contains(extension_ids[1]));
}
+#endif // defined(ENABLE_MANAGED_USERS)
TEST_F(ExtensionServiceTest, InstallPriorityExternalUpdateUrl) {
InitializeEmptyExtensionService();
diff --git a/chrome/browser/search/search_unittest.cc b/chrome/browser/search/search_unittest.cc
index ad923b4..0fb0bbf 100644
--- a/chrome/browser/search/search_unittest.cc
+++ b/chrome/browser/search/search_unittest.cc
@@ -13,9 +13,6 @@
#include "chrome/browser/search/search.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
-#include "chrome/browser/supervised_user/supervised_user_service.h"
-#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
-#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -34,6 +31,12 @@
#include "content/public/common/renderer_preferences.h"
#include "url/gurl.h"
+#if defined(ENABLE_MANAGED_USERS)
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
+#endif
+
namespace chrome {
class SearchTest : public BrowserWithTestWindowTest {
@@ -431,6 +434,7 @@ TEST_F(SearchTest, UseLocalNTPIfNTPURLIsNotSet) {
EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), new_tab_url);
}
+#if defined(ENABLE_MANAGED_USERS)
TEST_F(SearchTest, UseLocalNTPIfNTPURLIsBlockedForSupervisedUser) {
// Block access to foo.com in the URL filter.
SupervisedUserService* supervised_user_service =
@@ -448,6 +452,7 @@ TEST_F(SearchTest, UseLocalNTPIfNTPURLIsBlockedForSupervisedUser) {
EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), new_tab_url);
EXPECT_EQ(GURL(), GetInstantURL(profile(), false));
}
+#endif
TEST_F(SearchTest, GetInstantURL) {
// No Instant URL because "strk" is missing.
diff --git a/chrome/browser/supervised_user/supervised_user_theme.h b/chrome/browser/supervised_user/supervised_user_theme.h
index dc11d6f..82b934d 100644
--- a/chrome/browser/supervised_user/supervised_user_theme.h
+++ b/chrome/browser/supervised_user/supervised_user_theme.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_THEME_H_
#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_THEME_H_
+#include "chrome/browser/supervised_user/supervised_users.h"
#include "chrome/browser/themes/custom_theme_supplier.h"
namespace gfx {
diff --git a/chrome/browser/themes/theme_properties.h b/chrome/browser/themes/theme_properties.h
index 0088e4d..249a8bc 100644
--- a/chrome/browser/themes/theme_properties.h
+++ b/chrome/browser/themes/theme_properties.h
@@ -88,9 +88,11 @@ class ThemeProperties {
COLOR_NTP_SECTION_HEADER_RULE,
COLOR_NTP_SECTION_HEADER_RULE_LIGHT,
COLOR_NTP_TEXT_LIGHT,
+#if defined(ENABLE_MANAGED_USERS)
COLOR_SUPERVISED_USER_LABEL,
COLOR_SUPERVISED_USER_LABEL_BACKGROUND,
COLOR_SUPERVISED_USER_LABEL_BORDER,
+#endif
COLOR_STATUS_BAR_TEXT,
diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc
index 886521a..cecfd45 100644
--- a/chrome/browser/themes/theme_service.cc
+++ b/chrome/browser/themes/theme_service.cc
@@ -16,7 +16,6 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/supervised_user/supervised_user_theme.h"
#include "chrome/browser/themes/browser_theme_pack.h"
#include "chrome/browser/themes/custom_theme_supplier.h"
#include "chrome/browser/themes/theme_properties.h"
@@ -36,6 +35,10 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia.h"
+#if defined(ENABLE_MANAGED_USERS)
+#include "chrome/browser/supervised_user/supervised_user_theme.h"
+#endif
+
#if defined(OS_WIN)
#include "ui/base/win/shell.h"
#endif
@@ -168,6 +171,7 @@ SkColor ThemeService::GetColor(int id) const {
return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.86);
case Properties::COLOR_NTP_TEXT_LIGHT:
return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.40);
+#if defined(ENABLE_MANAGED_USERS)
case Properties::COLOR_SUPERVISED_USER_LABEL:
return color_utils::GetReadableColor(
SK_ColorWHITE,
@@ -180,6 +184,7 @@ SkColor ThemeService::GetColor(int id) const {
GetColor(Properties::COLOR_SUPERVISED_USER_LABEL_BACKGROUND),
SK_ColorBLACK,
230);
+#endif
case Properties::COLOR_STATUS_BAR_TEXT: {
// A long time ago, we blended the toolbar and the tab text together to
// get the status bar text because, at the time, our text rendering in
@@ -395,10 +400,12 @@ void ThemeService::RemoveUnusedThemes(bool ignore_infobars) {
void ThemeService::UseDefaultTheme() {
if (ready_)
content::RecordAction(UserMetricsAction("Themes_Reset"));
+#if defined(ENABLE_MANAGED_USERS)
if (IsSupervisedUser()) {
SetSupervisedUserTheme();
return;
}
+#endif
ClearAllThemeData();
NotifyThemeChanged();
}
@@ -454,10 +461,15 @@ void ThemeService::LoadThemePrefs() {
std::string current_id = GetThemeID();
if (current_id == kDefaultThemeID) {
+#if defined(ENABLE_MANAGED_USERS)
// Supervised users have a different default theme.
- if (IsSupervisedUser())
+ if (IsSupervisedUser()) {
SetSupervisedUserTheme();
- else if (ShouldInitWithSystemTheme())
+ set_ready();
+ return;
+ }
+#endif
+ if (ShouldInitWithSystemTheme())
UseSystemTheme();
else
UseDefaultTheme();
@@ -604,6 +616,7 @@ void ThemeService::BuildFromExtension(const Extension* extension) {
SwapThemeSupplier(pack);
}
+#if defined(ENABLE_MANAGED_USERS)
bool ThemeService::IsSupervisedUser() const {
return profile_->IsSupervised();
}
@@ -611,6 +624,7 @@ bool ThemeService::IsSupervisedUser() const {
void ThemeService::SetSupervisedUserTheme() {
SetCustomDefaultTheme(new SupervisedUserTheme);
}
+#endif
void ThemeService::OnInfobarDisplayed() {
number_of_infobars_++;
diff --git a/chrome/browser/themes/theme_service.h b/chrome/browser/themes/theme_service.h
index f13e5c1..8a86d30 100644
--- a/chrome/browser/themes/theme_service.h
+++ b/chrome/browser/themes/theme_service.h
@@ -208,12 +208,14 @@ class ThemeService : public base::NonThreadSafe,
// case we don't have a theme pack).
void BuildFromExtension(const extensions::Extension* extension);
+#if defined(ENABLE_MANAGED_USERS)
// Returns true if the profile belongs to a supervised user.
bool IsSupervisedUser() const;
// Sets the current theme to the supervised user theme. Should only be used
// for supervised user profiles.
void SetSupervisedUserTheme();
+#endif
#if defined(OS_MACOSX)
// |nsimage_cache_| retains the images it has cached.
diff --git a/chrome/browser/themes/theme_service_unittest.cc b/chrome/browser/themes/theme_service_unittest.cc
index 6617e49..441911f 100644
--- a/chrome/browser/themes/theme_service_unittest.cc
+++ b/chrome/browser/themes/theme_service_unittest.cc
@@ -10,8 +10,6 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_service_test_base.h"
#include "chrome/browser/extensions/unpacked_installer.h"
-#include "chrome/browser/supervised_user/supervised_user_service.h"
-#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/themes/custom_theme_supplier.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/common/chrome_paths.h"
@@ -25,6 +23,11 @@
#include "extensions/common/extension.h"
#include "testing/gtest/include/gtest/gtest.h"
+#if defined(ENABLE_MANAGED_USERS)
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#endif
+
using extensions::ExtensionRegistry;
namespace theme_service_internal {
@@ -234,6 +237,7 @@ TEST_F(ThemeServiceTest, ThemeUpgrade) {
ExtensionRegistry::DISABLED));
}
+#if defined(ENABLE_MANAGED_USERS)
class ThemeServiceSupervisedUserTest : public ThemeServiceTest {
public:
ThemeServiceSupervisedUserTest() {}
@@ -270,6 +274,7 @@ TEST_F(ThemeServiceSupervisedUserTest, SupervisedUserThemeReplacesNativeTheme) {
EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(),
CustomThemeSupplier::SUPERVISED_USER_THEME);
}
-#endif
+#endif // defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#endif // defined(ENABLE_MANAGED_USERS)
}; // namespace theme_service_internal
diff --git a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
index 9a9c634..ad8eef8 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
@@ -21,9 +21,6 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sessions/session_restore.h"
#include "chrome/browser/signin/signin_promo.h"
-#include "chrome/browser/supervised_user/supervised_user_navigation_observer.h"
-#include "chrome/browser/supervised_user/supervised_user_service.h"
-#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -63,6 +60,12 @@ using testing::_;
using testing::Return;
#endif // defined(ENABLE_CONFIGURATION_POLICY) && !defined(OS_CHROMEOS)
+#if defined(ENABLE_MANAGED_USERS)
+#include "chrome/browser/supervised_user/supervised_user_navigation_observer.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#endif
+
using extensions::Extension;
namespace {
diff --git a/chrome/browser/ui/view_ids.h b/chrome/browser/ui/view_ids.h
index ad8739c..4a77562 100644
--- a/chrome/browser/ui/view_ids.h
+++ b/chrome/browser/ui/view_ids.h
@@ -22,7 +22,9 @@ enum ViewID {
VIEW_ID_CLOSE_BUTTON,
VIEW_ID_WINDOW_ICON,
VIEW_ID_WINDOW_TITLE,
- VIEW_ID_AVATAR_LABEL,
+#if defined(ENABLE_MANAGED_USERS)
+ VIEW_ID_SUPERVISED_USER_AVATAR_LABEL,
+#endif
VIEW_ID_AVATAR_BUTTON,
VIEW_ID_NEW_AVATAR_BUTTON,
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc
index 232ad19..5ba04c2 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/taskbar_decorator.h"
-#include "chrome/browser/ui/views/profiles/avatar_label.h"
#include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
#include "chrome/browser/ui/views/profiles/new_avatar_button.h"
#include "components/signin/core/common/profile_management_switches.h"
@@ -25,12 +24,18 @@
#include "ui/gfx/image/image.h"
#include "ui/views/background.h"
+#if defined(ENABLE_MANAGED_USERS)
+#include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h"
+#endif
+
BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame,
BrowserView* browser_view)
: frame_(frame),
browser_view_(browser_view),
avatar_button_(NULL),
- avatar_label_(NULL),
+#if defined(ENABLE_MANAGED_USERS)
+ supervised_user_avatar_label_(NULL),
+#endif
new_avatar_button_(NULL) {
}
@@ -49,20 +54,26 @@ void BrowserNonClientFrameView::VisibilityChanged(views::View* starting_from,
UpdateAvatarInfo();
}
+#if defined(ENABLE_MANAGED_USERS)
void BrowserNonClientFrameView::OnThemeChanged() {
- if (avatar_label_)
- avatar_label_->UpdateLabelStyle();
+ if (supervised_user_avatar_label_)
+ supervised_user_avatar_label_->UpdateLabelStyle();
}
+#endif
void BrowserNonClientFrameView::UpdateAvatarInfo() {
if (browser_view_->ShouldShowAvatar()) {
if (!avatar_button_) {
+#if defined(ENABLE_MANAGED_USERS)
Profile* profile = browser_view_->browser()->profile();
- if (profile->IsSupervised() && !avatar_label_) {
- avatar_label_ = new AvatarLabel(browser_view_);
- avatar_label_->set_id(VIEW_ID_AVATAR_LABEL);
- AddChildView(avatar_label_);
+ if (profile->IsSupervised() && !supervised_user_avatar_label_) {
+ supervised_user_avatar_label_ =
+ new SupervisedUserAvatarLabel(browser_view_);
+ supervised_user_avatar_label_->set_id(
+ VIEW_ID_SUPERVISED_USER_AVATAR_LABEL);
+ AddChildView(supervised_user_avatar_label_);
}
+#endif
avatar_button_ = new AvatarMenuButton(
browser_view_->browser(), !browser_view_->IsRegularOrGuestSession());
avatar_button_->set_id(VIEW_ID_AVATAR_BUTTON);
@@ -72,12 +83,14 @@ void BrowserNonClientFrameView::UpdateAvatarInfo() {
frame_->GetRootView()->Layout();
}
} else if (avatar_button_) {
+#if defined(ENABLE_MANAGED_USERS)
// The avatar label can just be there if there is also an avatar button.
- if (avatar_label_) {
- RemoveChildView(avatar_label_);
- delete avatar_label_;
- avatar_label_ = NULL;
+ if (supervised_user_avatar_label_) {
+ RemoveChildView(supervised_user_avatar_label_);
+ delete supervised_user_avatar_label_;
+ supervised_user_avatar_label_ = NULL;
}
+#endif
RemoveChildView(avatar_button_);
delete avatar_button_;
avatar_button_ = NULL;
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view.h b/chrome/browser/ui/views/frame/browser_non_client_frame_view.h
index 3167a17..016fda0 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view.h
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view.h
@@ -8,7 +8,9 @@
#include "chrome/browser/ui/views/profiles/new_avatar_button.h"
#include "ui/views/window/non_client_view.h"
-class AvatarLabel;
+#if defined(ENABLE_MANAGED_USERS)
+class SupervisedUserAvatarLabel;
+#endif
class AvatarMenuButton;
class BrowserFrame;
class BrowserView;
@@ -25,7 +27,13 @@ class BrowserNonClientFrameView : public views::NonClientFrameView {
NewAvatarButton* new_avatar_button() const { return new_avatar_button_; }
- AvatarLabel* avatar_label() const { return avatar_label_; }
+#if defined(ENABLE_MANAGED_USERS)
+ SupervisedUserAvatarLabel* supervised_user_avatar_label() const {
+ return supervised_user_avatar_label_;
+ }
+
+ virtual void OnThemeChanged() OVERRIDE;
+#endif
// Retrieves the bounds, in non-client view coordinates within which the
// TabStrip should be laid out.
@@ -46,7 +54,6 @@ class BrowserNonClientFrameView : public views::NonClientFrameView {
// Overriden from views::View.
virtual void VisibilityChanged(views::View* starting_from,
bool is_visible) OVERRIDE;
- virtual void OnThemeChanged() OVERRIDE;
protected:
BrowserView* browser_view() const { return browser_view_; }
@@ -72,8 +79,9 @@ class BrowserNonClientFrameView : public views::NonClientFrameView {
// icon. May be NULL for some frame styles.
AvatarMenuButton* avatar_button_;
- // Avatar label that is used for a supervised user.
- AvatarLabel* avatar_label_;
+#if defined(ENABLE_MANAGED_USERS)
+ SupervisedUserAvatarLabel* supervised_user_avatar_label_;
+#endif
// Menu button that displays the name of the active or guest profile.
// May be NULL and will not be displayed for off the record profiles.
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
index 18cbad8..91cbb2f 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
@@ -21,7 +21,6 @@
#include "chrome/browser/ui/views/frame/browser_header_painter_ash.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
-#include "chrome/browser/ui/views/profiles/avatar_label.h"
#include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
#include "chrome/browser/ui/views/tab_icon_view.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
@@ -44,6 +43,10 @@
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
+#if defined(ENABLE_MANAGED_USERS)
+#include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h"
+#endif
+
namespace {
// The avatar ends 2 px above the bottom of the tabstrip (which, given the
@@ -236,7 +239,7 @@ int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) {
int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this,
caption_button_container_, point);
- // See if the point is actually within the avatar menu button.
+ // See if the point is actually within the avatar menu button.d
if (hit_test == HTCAPTION && avatar_button() &&
ConvertedHitTest(this, avatar_button(), point)) {
return HTCLIENT;
@@ -248,6 +251,14 @@ int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) {
return HTCLIENT;
}
+#if defined(ENABLE_MANAGED_USERS)
+ // ...or within the avatar label, if it's a supervised user.
+ if (hit_test == HTCAPTION && supervised_user_avatar_label() &&
+ ConvertedHitTest(this, supervised_user_avatar_label(), point)) {
+ return HTCLIENT;
+ }
+#endif
+
// When the window is restored we want a large click target above the tabs
// to drag the window, so redirect clicks in the tab's shadow to caption.
if (hit_test == HTCLIENT &&
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
index 88814b0..479d51e 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h"
#include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_specific.h"
-#include "chrome/browser/ui/views/profiles/avatar_label.h"
#include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
#include "chrome/browser/ui/views/profiles/new_avatar_button.h"
#include "chrome/browser/ui/views/tab_icon_view.h"
@@ -52,6 +51,10 @@
#include "ui/views/window/frame_background.h"
#include "ui/views/window/window_shape.h"
+#if defined(ENABLE_MANAGED_USERS)
+#include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h"
+#endif
+
#if defined(OS_LINUX)
#include "ui/views/controls/menu/menu_runner.h"
#endif
@@ -204,18 +207,33 @@ gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds(
return layout_->GetWindowBoundsForClientBounds(client_bounds);
}
+bool OpaqueBrowserFrameView::IsWithinAvatarMenuButtons(
+ const gfx::Point& point) const {
+ if (avatar_button() &&
+ avatar_button()->GetMirroredBounds().Contains(point)) {
+ return true;
+ }
+ if (new_avatar_button() &&
+ new_avatar_button()->GetMirroredBounds().Contains(point)) {
+ return true;
+ }
+
+ return false;
+}
+
int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (!bounds().Contains(point))
return HTNOWHERE;
- // See if the point is within the avatar menu button or within the avatar
- // label.
- if ((avatar_button() &&
- avatar_button()->GetMirroredBounds().Contains(point)) ||
- (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)) ||
- (new_avatar_button() &&
- new_avatar_button()->GetMirroredBounds().Contains(point)))
+ // See if the point is within the avatar menu button.
+ if (IsWithinAvatarMenuButtons(point))
return HTCLIENT;
+#if defined(ENABLE_MANAGED_USERS)
+ // ...or within the avatar label, if it's a supervised user.
+ if ((supervised_user_avatar_label() &&
+ supervised_user_avatar_label()->GetMirroredBounds().Contains(point)))
+ return HTCLIENT;
+#endif
int frame_component = frame()->client_view()->NonClientHitTest(point);
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.h b/chrome/browser/ui/views/frame/opaque_browser_frame_view.h
index 5707073..8146e3e 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.h
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.h
@@ -129,6 +129,9 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
// border height in order to increase the window draggable area.
int TopResizeHeight() const;
+ // Returns true if the specified point is within the avatar menu buttons.
+ bool IsWithinAvatarMenuButtons(const gfx::Point& point) const;
+
// Returns the thickness of the entire nonclient left, right, and bottom
// borders, including both the window frame and any client edge.
int NonClientBorderThickness() const;
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc
index a7dd9d9..cc1ece8 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc
@@ -6,7 +6,6 @@
#include "base/command_line.h"
#include "chrome/browser/profiles/profiles_state.h"
-#include "chrome/browser/ui/views/profiles/avatar_label.h"
#include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/common/chrome_switches.h"
@@ -15,6 +14,10 @@
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/label.h"
+#if defined(ENABLE_MANAGED_USERS)
+#include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h"
+#endif
+
namespace {
// Besides the frame border, there's another 9 px of empty space atop the
@@ -52,8 +55,10 @@ const int kAvatarOuterSpacing = 2;
// Space between the edge of the avatar and the tabstrip.
const int kAvatarInnerSpacing = 4;
+#if defined(ENABLE_MANAGED_USERS)
// Space between the trailing edge of the avatar label and the tabstrip.
-const int kAvatarLabelInnerSpacing = 10;
+const int kSupervisedUserAvatarLabelInnerSpacing = 10;
+#endif
// How far the new avatar button is from the closest caption button.
const int kNewAvatarButtonOffset = 5;
@@ -115,7 +120,9 @@ OpaqueBrowserFrameViewLayout::OpaqueBrowserFrameViewLayout(
close_button_(NULL),
window_icon_(NULL),
window_title_(NULL),
- avatar_label_(NULL),
+#if defined(ENABLE_MANAGED_USERS)
+ supervised_user_avatar_label_(NULL),
+#endif
avatar_button_(NULL),
new_avatar_button_(NULL) {
trailing_buttons_.push_back(views::FRAME_BUTTON_MINIMIZE);
@@ -146,10 +153,15 @@ gfx::Rect OpaqueBrowserFrameViewLayout::GetBoundsForTabStrip(
int leading_tabstrip_indent = kTabStripIndent;
if (delegate_->ShouldShowAvatar() && !ShouldAvatarBeOnRight()) {
- if (avatar_label_ && avatar_label_->bounds().width())
- leading_tabstrip_indent += kAvatarLabelInnerSpacing;
+#if defined(ENABLE_MANAGED_USERS)
+ if (supervised_user_avatar_label_ &&
+ supervised_user_avatar_label_->bounds().width())
+ leading_tabstrip_indent += kSupervisedUserAvatarLabelInnerSpacing;
else
leading_tabstrip_indent += kAvatarInnerSpacing;
+#else
+ leading_tabstrip_indent += kAvatarInnerSpacing;
+#endif
}
bounds.Inset(leading_tabstrip_indent, 0, 0, 0);
return bounds;
@@ -432,12 +444,13 @@ void OpaqueBrowserFrameViewLayout::LayoutAvatar(views::View* host) {
avatar_button_->SetBoundsRect(avatar_bounds_);
int edge_offset;
- if (avatar_label_) {
- avatar_label_->SetLabelOnRight(avatar_on_right);
+#if defined(ENABLE_MANAGED_USERS)
+ if (supervised_user_avatar_label_) {
+ supervised_user_avatar_label_->SetLabelOnRight(avatar_on_right);
// Space between the bottom of the avatar and the bottom of the avatar
// label.
- const int kAvatarLabelBottomSpacing = 3;
- gfx::Size label_size = avatar_label_->GetPreferredSize();
+ const int kSupervisedUserAvatarLabelBottomSpacing = 3;
+ gfx::Size label_size = supervised_user_avatar_label_->GetPreferredSize();
// The outside edge of the avatar label should be just outside that of the
// avatar menu button.
int avatar_label_x = avatar_on_right ?
@@ -445,14 +458,18 @@ void OpaqueBrowserFrameViewLayout::LayoutAvatar(views::View* host) {
leading_button_start_;
gfx::Rect label_bounds(
avatar_label_x,
- avatar_bottom - kAvatarLabelBottomSpacing - label_size.height(),
+ avatar_bottom - kSupervisedUserAvatarLabelBottomSpacing -
+ label_size.height(),
label_size.width(),
delegate_->ShouldShowAvatar() ? label_size.height() : 0);
- avatar_label_->SetBoundsRect(label_bounds);
+ supervised_user_avatar_label_->SetBoundsRect(label_bounds);
edge_offset = label_size.width();
} else {
edge_offset = kAvatarOuterSpacing + incognito_icon.width();
}
+#else
+ edge_offset = kAvatarOuterSpacing + incognito_icon.width();
+#endif
if (avatar_on_right)
trailing_button_start_ += edge_offset;
else
@@ -630,9 +647,12 @@ void OpaqueBrowserFrameViewLayout::SetView(int id, views::View* view) {
}
window_title_ = static_cast<views::Label*>(view);
break;
- case VIEW_ID_AVATAR_LABEL:
- avatar_label_ = static_cast<AvatarLabel*>(view);
+#if defined(ENABLE_MANAGED_USERS)
+ case VIEW_ID_SUPERVISED_USER_AVATAR_LABEL:
+ supervised_user_avatar_label_ =
+ static_cast<SupervisedUserAvatarLabel*>(view);
break;
+#endif
case VIEW_ID_AVATAR_BUTTON:
if (view) {
DCHECK_EQ(std::string(AvatarMenuButton::kViewClassName),
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h
index 16ca682..3c82c8f 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h
@@ -9,11 +9,14 @@
#include "ui/views/layout/layout_manager.h"
#include "ui/views/window/frame_buttons.h"
-class AvatarLabel;
class AvatarMenuButton;
class NewAvatarButton;
class OpaqueBrowserFrameViewLayoutDelegate;
+#if defined(ENABLE_MANAGED_USERS)
+class SupervisedUserAvatarLabel;
+#endif
+
namespace views {
class ImageButton;
class Label;
@@ -185,7 +188,9 @@ class OpaqueBrowserFrameViewLayout : public views::LayoutManager {
views::View* window_icon_;
views::Label* window_title_;
- AvatarLabel* avatar_label_;
+#if defined(ENABLE_MANAGED_USERS)
+ SupervisedUserAvatarLabel* supervised_user_avatar_label_;
+#endif
AvatarMenuButton* avatar_button_;
views::View* new_avatar_button_;
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc
index 8579da2..b42f92d 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc
@@ -7,7 +7,6 @@
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/ui/views/profiles/avatar_label.h"
#include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
#include "chrome/browser/ui/views/tab_icon_view.h"
#include "chrome/browser/ui/views/tabs/tab.h"
@@ -21,6 +20,10 @@
#include "ui/views/controls/label.h"
#include "ui/views/test/views_test_base.h"
+#if defined(ENABLE_MANAGED_USERS)
+#include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h"
+#endif
+
using views::Widget;
namespace {
@@ -223,14 +226,16 @@ class OpaqueBrowserFrameViewLayoutTest : public views::ViewsTestBase {
root_view_->AddChildView(menu_button_);
}
- void AddAvatarLabel() {
- avatar_label_ = new AvatarLabel(NULL);
- avatar_label_->set_id(VIEW_ID_AVATAR_LABEL);
- root_view_->AddChildView(avatar_label_);
+#if defined(ENABLE_MANAGED_USERS)
+ void AddSupervisedUserAvatarLabel() {
+ supervised_user_avatar_label_ = new SupervisedUserAvatarLabel(NULL);
+ supervised_user_avatar_label_->set_id(VIEW_ID_SUPERVISED_USER_AVATAR_LABEL);
+ root_view_->AddChildView(supervised_user_avatar_label_);
// The avatar label should only be used together with the avatar button.
AddAvatarButton();
}
+#endif
void AddNewAvatarButton() {
// Enable the New Avatar Menu.
@@ -263,7 +268,9 @@ class OpaqueBrowserFrameViewLayoutTest : public views::ViewsTestBase {
TabIconView* tab_icon_view_;
views::Label* window_title_;
- AvatarLabel* avatar_label_;
+#if defined(ENABLE_MANAGED_USERS)
+ SupervisedUserAvatarLabel* supervised_user_avatar_label_;
+#endif
AvatarMenuButton* menu_button_;
views::MenuButton* new_avatar_button_;
@@ -436,55 +443,6 @@ TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithAvatar) {
EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString());
}
-TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithAvatarWithButtonsOnLeft) {
- // Tests the layout of a chrome window with an avatar icon and caption buttons
- // on the left. The avatar icon should therefore be on the right.
- // AddAvatarLabel() also adds the avatar button.
- AddAvatarLabel();
- std::vector<views::FrameButton> leading_buttons;
- std::vector<views::FrameButton> trailing_buttons;
- leading_buttons.push_back(views::FRAME_BUTTON_CLOSE);
- leading_buttons.push_back(views::FRAME_BUTTON_MINIMIZE);
- leading_buttons.push_back(views::FRAME_BUTTON_MAXIMIZE);
- layout_manager_->SetButtonOrdering(leading_buttons, trailing_buttons);
- root_view_->Layout();
-
- EXPECT_EQ("73,1 25x18", maximize_button_->bounds().ToString());
- EXPECT_EQ("47,1 26x18", minimize_button_->bounds().ToString());
- EXPECT_EQ("0,0 0x0", restore_button_->bounds().ToString());
- EXPECT_EQ("4,1 43x18", close_button_->bounds().ToString());
-
- // Check the location of the avatar
- EXPECT_EQ("454,11 40x29", menu_button_->bounds().ToString());
-
- // Check the tab strip bounds.
- gfx::Rect tab_strip_bounds = layout_manager_->GetBoundsForTabStrip(
- delegate_->GetTabstripPreferredSize(), kWidth);
- EXPECT_GT(tab_strip_bounds.x(), maximize_button_->bounds().x());
- EXPECT_GT(maximize_button_->bounds().right(), tab_strip_bounds.x());
- EXPECT_EQ(13, tab_strip_bounds.y());
- EXPECT_EQ(29, tab_strip_bounds.height());
- EXPECT_GT(avatar_label_->bounds().x(), tab_strip_bounds.right());
- EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString());
-
- // Check the relative location of the avatar label to the avatar. The right
- // end of the avatar label should be slightly to the right of the right end of
- // the avatar icon.
- EXPECT_GT(avatar_label_->bounds().right(), menu_button_->bounds().right());
- EXPECT_GT(menu_button_->bounds().x(), avatar_label_->bounds().x());
- EXPECT_GT(menu_button_->bounds().bottom(),
- avatar_label_->bounds().bottom());
- EXPECT_GT(avatar_label_->bounds().y(), menu_button_->bounds().y());
-
- // This means that the menu will pop out facing the left (if it were to face
- // the right, it would go outside the window frame and be clipped).
- EXPECT_TRUE(menu_button_->button_on_right());
-
- // If the buttons are on the left, there should be no hidden icon for the user
- // to double click.
- EXPECT_EQ("0,0 0x0", layout_manager_->IconBounds().ToString());
-}
-
TEST_F(OpaqueBrowserFrameViewLayoutTest,
WindowWithAvatarWithoutCaptionButtonsOnLeft) {
// Tests the layout of a chrome window with an avatar icon and no caption
@@ -536,8 +494,62 @@ TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithNewAvatar) {
EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString());
}
+#if defined(ENABLE_MANAGED_USERS)
+TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithAvatarWithButtonsOnLeft) {
+ // Tests the layout of a chrome window with an avatar icon and caption buttons
+ // on the left. The avatar icon should therefore be on the right.
+ // AddAvatarLabel() also adds the avatar button.
+ AddSupervisedUserAvatarLabel();
+ std::vector<views::FrameButton> leading_buttons;
+ std::vector<views::FrameButton> trailing_buttons;
+ leading_buttons.push_back(views::FRAME_BUTTON_CLOSE);
+ leading_buttons.push_back(views::FRAME_BUTTON_MINIMIZE);
+ leading_buttons.push_back(views::FRAME_BUTTON_MAXIMIZE);
+ layout_manager_->SetButtonOrdering(leading_buttons, trailing_buttons);
+ root_view_->Layout();
+
+ EXPECT_EQ("73,1 25x18", maximize_button_->bounds().ToString());
+ EXPECT_EQ("47,1 26x18", minimize_button_->bounds().ToString());
+ EXPECT_EQ("0,0 0x0", restore_button_->bounds().ToString());
+ EXPECT_EQ("4,1 43x18", close_button_->bounds().ToString());
+
+ // Check the location of the avatar
+ EXPECT_EQ("454,11 40x29", menu_button_->bounds().ToString());
+
+ // Check the tab strip bounds.
+ gfx::Rect tab_strip_bounds = layout_manager_->GetBoundsForTabStrip(
+ delegate_->GetTabstripPreferredSize(), kWidth);
+ EXPECT_GT(tab_strip_bounds.x(), maximize_button_->bounds().x());
+ EXPECT_GT(maximize_button_->bounds().right(), tab_strip_bounds.x());
+ EXPECT_EQ(13, tab_strip_bounds.y());
+ EXPECT_EQ(29, tab_strip_bounds.height());
+ EXPECT_GT(supervised_user_avatar_label_->bounds().x(),
+ tab_strip_bounds.right());
+ EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString());
+
+ // Check the relative location of the avatar label to the avatar. The right
+ // end of the avatar label should be slightly to the right of the right end of
+ // the avatar icon.
+ EXPECT_GT(supervised_user_avatar_label_->bounds().right(),
+ menu_button_->bounds().right());
+ EXPECT_GT(menu_button_->bounds().x(),
+ supervised_user_avatar_label_->bounds().x());
+ EXPECT_GT(menu_button_->bounds().bottom(),
+ supervised_user_avatar_label_->bounds().bottom());
+ EXPECT_GT(supervised_user_avatar_label_->bounds().y(),
+ menu_button_->bounds().y());
+
+ // This means that the menu will pop out facing the left (if it were to face
+ // the right, it would go outside the window frame and be clipped).
+ EXPECT_TRUE(menu_button_->button_on_right());
+
+ // If the buttons are on the left, there should be no hidden icon for the user
+ // to double click.
+ EXPECT_EQ("0,0 0x0", layout_manager_->IconBounds().ToString());
+}
+
TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithAvatarLabelAndButtonOnLeft) {
- AddAvatarLabel();
+ AddSupervisedUserAvatarLabel();
root_view_->Layout();
ExpectBasicWindowBounds();
@@ -546,8 +558,10 @@ TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithAvatarLabelAndButtonOnLeft) {
// both are displayed on the left side.
// The label height and width depends on the font size and the text displayed.
// This may possibly change, so we don't test it here.
- EXPECT_EQ(menu_button_->bounds().x() - 2, avatar_label_->bounds().x());
- EXPECT_EQ(
- menu_button_->bounds().bottom() - 3 - avatar_label_->bounds().height(),
- avatar_label_->bounds().y());
+ EXPECT_EQ(menu_button_->bounds().x() - 2,
+ supervised_user_avatar_label_->bounds().x());
+ EXPECT_EQ(menu_button_->bounds().bottom() - 3 -
+ supervised_user_avatar_label_->bounds().height(),
+ supervised_user_avatar_label_->bounds().y());
}
+#endif
diff --git a/chrome/browser/ui/views/profiles/avatar_label.cc b/chrome/browser/ui/views/profiles/supervised_user_avatar_label.cc
index b91db49..72c05ad 100644
--- a/chrome/browser/ui/views/profiles/avatar_label.cc
+++ b/chrome/browser/ui/views/profiles/supervised_user_avatar_label.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/views/profiles/avatar_label.h"
+#include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/signin/signin_header_helper.h"
@@ -20,9 +20,9 @@
namespace {
// A custom border for the supervised user avatar label.
-class AvatarLabelBorder : public views::Border {
+class SupervisedUserAvatarLabelBorder : public views::Border {
public:
- explicit AvatarLabelBorder(bool label_on_right);
+ explicit SupervisedUserAvatarLabelBorder(bool label_on_right);
// views::Border:
virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE;
@@ -33,10 +33,11 @@ class AvatarLabelBorder : public views::Border {
scoped_ptr<views::Painter> painter_;
gfx::Insets insets_;
- DISALLOW_COPY_AND_ASSIGN(AvatarLabelBorder);
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserAvatarLabelBorder);
};
-AvatarLabelBorder::AvatarLabelBorder(bool label_on_right) {
+SupervisedUserAvatarLabelBorder::SupervisedUserAvatarLabelBorder(
+ bool label_on_right) {
const int kHorizontalInsetRight = label_on_right ? 43 : 10;
const int kHorizontalInsetLeft = label_on_right ? 10 : 43;
const int kVerticalInsetTop = 2;
@@ -54,7 +55,8 @@ AvatarLabelBorder::AvatarLabelBorder(bool label_on_right) {
painter_.reset(views::Painter::CreateImageGridPainter(kImages));
}
-void AvatarLabelBorder::Paint(const views::View& view, gfx::Canvas* canvas) {
+void SupervisedUserAvatarLabelBorder::Paint(
+ const views::View& view, gfx::Canvas* canvas) {
// Paint the default background using the image assets provided by UI. This
// includes a border with almost transparent white color.
painter_->Paint(canvas, view.size());
@@ -80,11 +82,11 @@ void AvatarLabelBorder::Paint(const views::View& view, gfx::Canvas* canvas) {
canvas->DrawRoundRect(rect, kRadius, paint);
}
-gfx::Insets AvatarLabelBorder::GetInsets() const {
+gfx::Insets SupervisedUserAvatarLabelBorder::GetInsets() const {
return insets_;
}
-gfx::Size AvatarLabelBorder::GetMinimumSize() const {
+gfx::Size SupervisedUserAvatarLabelBorder::GetMinimumSize() const {
gfx::Size size(4, 4);
size.SetToMax(painter_->GetMinimumSize());
return size;
@@ -92,7 +94,7 @@ gfx::Size AvatarLabelBorder::GetMinimumSize() const {
} // namespace
-AvatarLabel::AvatarLabel(BrowserView* browser_view)
+SupervisedUserAvatarLabel::SupervisedUserAvatarLabel(BrowserView* browser_view)
: LabelButton(NULL,
l10n_util::GetStringUTF16(IDS_SUPERVISED_USER_AVATAR_LABEL)),
browser_view_(browser_view) {
@@ -100,9 +102,9 @@ AvatarLabel::AvatarLabel(BrowserView* browser_view)
UpdateLabelStyle();
}
-AvatarLabel::~AvatarLabel() {}
+SupervisedUserAvatarLabel::~SupervisedUserAvatarLabel() {}
-bool AvatarLabel::OnMousePressed(const ui::MouseEvent& event) {
+bool SupervisedUserAvatarLabel::OnMousePressed(const ui::MouseEvent& event) {
if (!LabelButton::OnMousePressed(event))
return false;
@@ -112,7 +114,7 @@ bool AvatarLabel::OnMousePressed(const ui::MouseEvent& event) {
return true;
}
-void AvatarLabel::UpdateLabelStyle() {
+void SupervisedUserAvatarLabel::UpdateLabelStyle() {
// |browser_view_| can be NULL in unit tests.
if (!browser_view_)
return;
@@ -124,6 +126,7 @@ void AvatarLabel::UpdateLabelStyle() {
SchedulePaint();
}
-void AvatarLabel::SetLabelOnRight(bool label_on_right) {
- SetBorder(scoped_ptr<views::Border>(new AvatarLabelBorder(label_on_right)));
+void SupervisedUserAvatarLabel::SetLabelOnRight(bool label_on_right) {
+ SetBorder(scoped_ptr<views::Border>(
+ new SupervisedUserAvatarLabelBorder(label_on_right)));
}
diff --git a/chrome/browser/ui/views/profiles/avatar_label.h b/chrome/browser/ui/views/profiles/supervised_user_avatar_label.h
index 9126d02..506fba2 100644
--- a/chrome/browser/ui/views/profiles/avatar_label.h
+++ b/chrome/browser/ui/views/profiles/supervised_user_avatar_label.h
@@ -2,22 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_LABEL_H_
-#define CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_LABEL_H_
+#ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_SUPERVISED_USER_AVATAR_LABEL_H_
+#define CHROME_BROWSER_UI_VIEWS_PROFILES_SUPERVISED_USER_AVATAR_LABEL_H_
#include "base/compiler_specific.h"
+#include "chrome/browser/supervised_user/supervised_users.h"
#include "ui/views/controls/button/label_button.h"
class BrowserView;
-// AvatarLabel
+// SupervisedUserAvatarLabel
//
// A label used to display a string indicating that the current profile belongs
// to a supervised user.
-class AvatarLabel : public views::LabelButton {
+class SupervisedUserAvatarLabel : public views::LabelButton {
public:
- explicit AvatarLabel(BrowserView* browser_view);
- virtual ~AvatarLabel();
+ explicit SupervisedUserAvatarLabel(BrowserView* browser_view);
+ virtual ~SupervisedUserAvatarLabel();
// views::LabelButton:
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
@@ -33,7 +34,7 @@ class AvatarLabel : public views::LabelButton {
private:
BrowserView* browser_view_;
- DISALLOW_COPY_AND_ASSIGN(AvatarLabel);
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserAvatarLabel);
};
-#endif // CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_LABEL_H_
+#endif // CHROME_BROWSER_UI_VIEWS_PROFILES_SUPERVISED_USER_AVATAR_LABEL_H_
diff --git a/chrome/browser/ui/webui/downloads_ui_browsertest.cc b/chrome/browser/ui/webui/downloads_ui_browsertest.cc
index eafa460..025d54a 100644
--- a/chrome/browser/ui/webui/downloads_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/downloads_ui_browsertest.cc
@@ -4,13 +4,9 @@
#include "chrome/browser/ui/webui/downloads_ui_browsertest.h"
-#include "base/command_line.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/supervised_user/supervised_user_service.h"
-#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "content/public/test/test_utils.h"
@@ -22,8 +18,3 @@ void DownloadsUIBrowserTest::SetDeleteAllowed(bool allowed) {
browser()->profile()->GetPrefs()->
SetBoolean(prefs::kAllowDeletingBrowserHistory, allowed);
}
-
-void DownloadsWebUIForSupervisedUsersTest::SetUpCommandLine(
- CommandLine* command_line) {
- command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf");
-}
diff --git a/chrome/browser/ui/webui/downloads_ui_browsertest.h b/chrome/browser/ui/webui/downloads_ui_browsertest.h
index 4d35321..7b02787 100644
--- a/chrome/browser/ui/webui/downloads_ui_browsertest.h
+++ b/chrome/browser/ui/webui/downloads_ui_browsertest.h
@@ -21,10 +21,4 @@ class DownloadsUIBrowserTest : public WebUIBrowserTest {
DISALLOW_COPY_AND_ASSIGN(DownloadsUIBrowserTest);
};
-class DownloadsWebUIForSupervisedUsersTest : public DownloadsUIBrowserTest {
- public:
- // InProcessBrowserTest overrides:
- virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
-};
-
#endif // CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UI_BROWSERTEST_H_
diff --git a/chrome/browser/ui/webui/downloads_ui_browsertest.js b/chrome/browser/ui/webui/downloads_ui_browsertest.js
index 4eb5bc1d..4329f4f 100644
--- a/chrome/browser/ui/webui/downloads_ui_browsertest.js
+++ b/chrome/browser/ui/webui/downloads_ui_browsertest.js
@@ -2,139 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+GEN_INCLUDE(['downloads_ui_browsertest_base.js']);
GEN('#include "chrome/browser/ui/webui/downloads_ui_browsertest.h"');
-/** @const */ var TOTAL_RESULT_COUNT = 25;
-
-/**
- * Test C++ fixture for downloads WebUI testing.
- * @constructor
- * @extends {testing.Test}
- */
-function DownloadsUIBrowserTest() {}
-
-/**
- * Base fixture for Downloads WebUI testing.
- * @extends {testing.Test}
- * @constructor
- */
-function BaseDownloadsWebUITest() {}
-
-BaseDownloadsWebUITest.prototype = {
- __proto__: testing.Test.prototype,
-
- /**
- * Browse to the downloads page & call our preLoad().
- */
- browsePreload: 'chrome://downloads/',
-
- /** @override */
- typedefCppFixture: 'DownloadsUIBrowserTest',
-
- /** @override */
- testGenPreamble: function() {
- GEN(' SetDeleteAllowed(true);');
- },
-
- /** @override */
- runAccessibilityChecks: true,
-
- /** @override */
- accessibilityIssuesAreErrors: true,
-
- /**
- * Sends TOTAL_RESULT_COUNT fake downloads to the page. This can't be called
- * in the preLoad, because it requires the global Download object to have
- * been created by the page.
- * @override
- */
- setUp: function() {
- // The entries will begin at 1:00 AM on Sept 2, 2008, and will be spaced
- // two minutes apart.
- var timestamp = new Date(2008, 9, 2, 1, 0).getTime();
- for (var i = 0; i < TOTAL_RESULT_COUNT; ++i) {
- downloads.updated(this.createDownload_(i, timestamp));
- timestamp += 2 * 60 * 1000; // Next visit is two minutes later.
- }
- expectEquals(downloads.size(), TOTAL_RESULT_COUNT);
- },
-
- /**
- * Creates a download object to be passed to the page, following the expected
- * backend format (see downloads_dom_handler.cc).
- * @param {number} A unique ID for the download.
- * @param {number} The time the download purportedly started.
- * @return {!Object} A fake download object.
- * @private
- */
- createDownload_: function(id, timestamp) {
- return {
- id: id,
- started: timestamp,
- otr: false,
- state: Download.States.COMPLETE,
- retry: false,
- file_path: '/path/to/file',
- file_url: 'http://google.com/' + timestamp,
- file_name: 'download_' + timestamp,
- url: 'http://google.com/' + timestamp,
- file_externally_removed: false,
- danger_type: Download.DangerType.NOT_DANGEROUS,
- last_reason_text: '',
- since_string: 'today',
- date_string: 'today',
- percent: 100,
- progress_status_text: 'done',
- received: 128,
- };
- },
-
- /**
- * Asserts the correctness of the state of the UI elements
- * that delete the download history.
- * @param {boolean} allowDelete True if download history deletion is
- * allowed and false otherwise.
- * @param {boolean} expectControlsHidden True if the controls to delete
- * download history are expected to be hidden and false otherwise.
- */
- testHelper: function(allowDelete, expectControlsHidden) {
- var clearAllElements = document.getElementsByClassName('clear-all-link');
- var disabledElements = document.getElementsByClassName('disabled-link');
- var removeLinkElements =
- document.getElementsByClassName('control-remove-link');
-
- // "Clear all" should be a link only when deletions are allowed.
- expectEquals(allowDelete ? 1 : 0, clearAllElements.length);
-
- // There should be no disabled links when deletions are allowed.
- // On the other hand, when deletions are not allowed, "Clear All"
- // and all "Remove from list" links should be disabled.
- expectEquals(allowDelete ? 0 : TOTAL_RESULT_COUNT + 1,
- disabledElements.length);
-
- // All "Remove from list" items should be links when deletions are allowed.
- // On the other hand, when deletions are not allowed, all
- // "Remove from list" items should be text.
- expectEquals(allowDelete ? TOTAL_RESULT_COUNT : 0,
- removeLinkElements.length);
-
- if (allowDelete) {
- // "Clear all" should not be hidden.
- expectFalse(clearAllElements[0].hidden);
-
- // No "Remove from list" items should be hidden.
- expectFalse(removeLinkElements[0].hidden);
- } else {
- expectEquals(expectControlsHidden, disabledElements[0].hidden);
- }
-
- // The model is updated synchronously, even though the actual
- // back-end removal (tested elsewhere) is asynchronous.
- clearAll();
- expectEquals(allowDelete ? 0 : TOTAL_RESULT_COUNT, downloads.size());
- },
-};
-
// Test UI when removing entries is allowed.
TEST_F('BaseDownloadsWebUITest', 'DeleteAllowed', function() {
this.testHelper(true, false);
@@ -174,24 +44,3 @@ TEST_F('DownloadsWebUIDeleteProhibitedTest', 'DeleteProhibited', function() {
// single item.
testDone();
});
-
-/**
- * Fixture for Downloads WebUI testing for a supervised user.
- * @extends {BaseDownloadsWebUITest}
- * @constructor
- */
-function DownloadsWebUIForSupervisedUsersTest() {}
-
-DownloadsWebUIForSupervisedUsersTest.prototype = {
- __proto__: BaseDownloadsWebUITest.prototype,
-
- /** @override */
- typedefCppFixture: 'DownloadsWebUIForSupervisedUsersTest',
-};
-
-// Test UI for supervised users, removing entries should be disabled
-// and removal controls should be hidden.
-TEST_F('DownloadsWebUIForSupervisedUsersTest', 'SupervisedUsers', function() {
- this.testHelper(false, true);
- testDone();
-});
diff --git a/chrome/browser/ui/webui/downloads_ui_browsertest_base.js b/chrome/browser/ui/webui/downloads_ui_browsertest_base.js
new file mode 100644
index 0000000..c6d0db0
--- /dev/null
+++ b/chrome/browser/ui/webui/downloads_ui_browsertest_base.js
@@ -0,0 +1,134 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/** @const */ var TOTAL_RESULT_COUNT = 25;
+
+/**
+ * Test C++ fixture for downloads WebUI testing.
+ * @constructor
+ * @extends {testing.Test}
+ */
+function DownloadsUIBrowserTest() {}
+
+/**
+ * Base fixture for Downloads WebUI testing.
+ * @extends {testing.Test}
+ * @constructor
+ */
+function BaseDownloadsWebUITest() {}
+
+BaseDownloadsWebUITest.prototype = {
+ __proto__: testing.Test.prototype,
+
+ /**
+ * Browse to the downloads page & call our preLoad().
+ */
+ browsePreload: 'chrome://downloads/',
+
+ /** @override */
+ typedefCppFixture: 'DownloadsUIBrowserTest',
+
+ /** @override */
+ testGenPreamble: function() {
+ GEN(' SetDeleteAllowed(true);');
+ },
+
+ /** @override */
+ runAccessibilityChecks: true,
+
+ /** @override */
+ accessibilityIssuesAreErrors: true,
+
+ /**
+ * Sends TOTAL_RESULT_COUNT fake downloads to the page. This can't be called
+ * in the preLoad, because it requires the global Download object to have
+ * been created by the page.
+ * @override
+ */
+ setUp: function() {
+ // The entries will begin at 1:00 AM on Sept 2, 2008, and will be spaced
+ // two minutes apart.
+ var timestamp = new Date(2008, 9, 2, 1, 0).getTime();
+ for (var i = 0; i < TOTAL_RESULT_COUNT; ++i) {
+ downloads.updated(this.createDownload_(i, timestamp));
+ timestamp += 2 * 60 * 1000; // Next visit is two minutes later.
+ }
+ expectEquals(downloads.size(), TOTAL_RESULT_COUNT);
+ },
+
+ /**
+ * Creates a download object to be passed to the page, following the expected
+ * backend format (see downloads_dom_handler.cc).
+ * @param {number} A unique ID for the download.
+ * @param {number} The time the download purportedly started.
+ * @return {!Object} A fake download object.
+ * @private
+ */
+ createDownload_: function(id, timestamp) {
+ return {
+ id: id,
+ started: timestamp,
+ otr: false,
+ state: Download.States.COMPLETE,
+ retry: false,
+ file_path: '/path/to/file',
+ file_url: 'http://google.com/' + timestamp,
+ file_name: 'download_' + timestamp,
+ url: 'http://google.com/' + timestamp,
+ file_externally_removed: false,
+ danger_type: Download.DangerType.NOT_DANGEROUS,
+ last_reason_text: '',
+ since_string: 'today',
+ date_string: 'today',
+ percent: 100,
+ progress_status_text: 'done',
+ received: 128,
+ };
+ },
+
+ /**
+ * Asserts the correctness of the state of the UI elements
+ * that delete the download history.
+ * @param {boolean} allowDelete True if download history deletion is
+ * allowed and false otherwise.
+ * @param {boolean} expectControlsHidden True if the controls to delete
+ * download history are expected to be hidden and false otherwise.
+ */
+ testHelper: function(allowDelete, expectControlsHidden) {
+ var clearAllElements = document.getElementsByClassName('clear-all-link');
+ var disabledElements = document.getElementsByClassName('disabled-link');
+ var removeLinkElements =
+ document.getElementsByClassName('control-remove-link');
+
+ // "Clear all" should be a link only when deletions are allowed.
+ expectEquals(allowDelete ? 1 : 0, clearAllElements.length);
+
+ // There should be no disabled links when deletions are allowed.
+ // On the other hand, when deletions are not allowed, "Clear All"
+ // and all "Remove from list" links should be disabled.
+ expectEquals(allowDelete ? 0 : TOTAL_RESULT_COUNT + 1,
+ disabledElements.length);
+
+ // All "Remove from list" items should be links when deletions are allowed.
+ // On the other hand, when deletions are not allowed, all
+ // "Remove from list" items should be text.
+ expectEquals(allowDelete ? TOTAL_RESULT_COUNT : 0,
+ removeLinkElements.length);
+
+ if (allowDelete) {
+ // "Clear all" should not be hidden.
+ expectFalse(clearAllElements[0].hidden);
+
+ // No "Remove from list" items should be hidden.
+ expectFalse(removeLinkElements[0].hidden);
+ } else {
+ expectEquals(expectControlsHidden, disabledElements[0].hidden);
+ }
+
+ // The model is updated synchronously, even though the actual
+ // back-end removal (tested elsewhere) is asynchronous.
+ clearAll();
+ expectEquals(allowDelete ? 0 : TOTAL_RESULT_COUNT, downloads.size());
+ },
+};
diff --git a/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.cc b/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.cc
new file mode 100644
index 0000000..52d7f27
--- /dev/null
+++ b/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.cc
@@ -0,0 +1,15 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/downloads_ui_supervised_browsertest.h"
+
+#include "base/command_line.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/common/chrome_switches.h"
+#include "content/public/test/test_utils.h"
+
+void DownloadsWebUIForSupervisedUsersTest::SetUpCommandLine(
+ CommandLine* command_line) {
+ command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf");
+}
diff --git a/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.h b/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.h
new file mode 100644
index 0000000..bf4d869
--- /dev/null
+++ b/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.h
@@ -0,0 +1,16 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UI_SUPERVISED_BROWSERTEST_H_
+#define CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UI_SUPERVISED_BROWSERTEST_H_
+
+#include "chrome/browser/ui/webui/downloads_ui_browsertest.h"
+
+class DownloadsWebUIForSupervisedUsersTest : public DownloadsUIBrowserTest {
+ public:
+ // InProcessBrowserTest implementation.
+ virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UI_SUPERVISED_BROWSERTEST_H_
diff --git a/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.js b/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.js
new file mode 100644
index 0000000..23b70d1
--- /dev/null
+++ b/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.js
@@ -0,0 +1,27 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+GEN_INCLUDE(['downloads_ui_browsertest_base.js']);
+GEN('#include "chrome/browser/ui/webui/downloads_ui_supervised_browsertest.h"');
+
+/**
+ * Fixture for Downloads WebUI testing for a supervised user.
+ * @extends {BaseDownloadsWebUITest}
+ * @constructor
+ */
+function DownloadsWebUIForSupervisedUsersTest() {}
+
+DownloadsWebUIForSupervisedUsersTest.prototype = {
+ __proto__: BaseDownloadsWebUITest.prototype,
+
+ /** @override */
+ typedefCppFixture: 'DownloadsWebUIForSupervisedUsersTest',
+};
+
+// Test UI for supervised users, removing entries should be disabled
+// and removal controls should be hidden.
+TEST_F('DownloadsWebUIForSupervisedUsersTest', 'SupervisedUsers', function() {
+ this.testHelper(false, true);
+ testDone();
+});
diff --git a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
index 305d975..b2317ca 100644
--- a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
+++ b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
@@ -44,8 +44,6 @@
#include "chrome/browser/platform_util.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/supervised_user/supervised_user_service.h"
-#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
#include "chrome/browser/tab_contents/background_contents.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
diff --git a/chrome/browser/ui/webui/options/create_profile_handler.cc b/chrome/browser/ui/webui/options/create_profile_handler.cc
index 135c876..b357dbf 100644
--- a/chrome/browser/ui/webui/options/create_profile_handler.cc
+++ b/chrome/browser/ui/webui/options/create_profile_handler.cc
@@ -15,18 +15,22 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/profiles/profiles_state.h"
-#include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
-#include "chrome/browser/supervised_user/supervised_user_service.h"
-#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
-#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
-#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/webui/options/options_handlers_helper.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
+#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/l10n_util.h"
+#if defined(ENABLE_MANAGED_USERS)
+#include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
+#include "chrome/browser/supervised_user/supervised_user_service.h"
+#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service.h"
+#include "chrome/browser/supervised_user/supervised_user_sync_service_factory.h"
+#endif
+
namespace options {
CreateProfileHandler::CreateProfileHandler()
@@ -35,7 +39,10 @@ CreateProfileHandler::CreateProfileHandler()
}
CreateProfileHandler::~CreateProfileHandler() {
+#if defined(ENABLE_MANAGED_USERS)
+ // Cancellation is only supported for supervised users.
CancelProfileRegistration(false);
+#endif
}
void CreateProfileHandler::GetLocalizedValues(
@@ -43,10 +50,13 @@ void CreateProfileHandler::GetLocalizedValues(
}
void CreateProfileHandler::RegisterMessages() {
+#if defined(ENABLE_MANAGED_USERS)
+ // Cancellation is only supported for supervised users.
web_ui()->RegisterMessageCallback(
"cancelCreateProfile",
base::Bind(&CreateProfileHandler::HandleCancelProfileCreation,
base::Unretained(this)));
+#endif
web_ui()->RegisterMessageCallback(
"createProfile",
base::Bind(&CreateProfileHandler::CreateProfile,
@@ -54,12 +64,12 @@ void CreateProfileHandler::RegisterMessages() {
}
void CreateProfileHandler::CreateProfile(const base::ListValue* args) {
+#if defined(ENABLE_MANAGED_USERS)
// This handler could have been called for a supervised user, for example
- // because the user fiddled with the web inspector. Silently return in this
- // case.
- Profile* current_profile = Profile::FromWebUI(web_ui());
- if (current_profile->IsSupervised())
+ // because the user fiddled with the web inspector. Silently return.
+ if (Profile::FromWebUI(web_ui())->IsSupervised())
return;
+#endif
if (!profiles::IsMultipleProfilesEnabled())
return;
@@ -77,44 +87,17 @@ void CreateProfileHandler::CreateProfile(const base::ListValue* args) {
base::string16 name;
base::string16 icon;
- std::string supervised_user_id;
bool create_shortcut = false;
- bool supervised_user = false;
if (args->GetString(0, &name) && args->GetString(1, &icon)) {
base::TrimWhitespace(name, base::TRIM_ALL, &name);
CHECK(!name.empty());
- if (args->GetBoolean(2, &create_shortcut)) {
- bool success = args->GetBoolean(3, &supervised_user);
- DCHECK(success);
- success = args->GetString(4, &supervised_user_id);
- DCHECK(success);
- }
- }
-
- if (supervised_user) {
- if (!IsValidExistingSupervisedUserId(supervised_user_id))
- return;
-
- profile_creation_type_ = SUPERVISED_PROFILE_IMPORT;
- if (supervised_user_id.empty()) {
- profile_creation_type_ = SUPERVISED_PROFILE_CREATION;
- supervised_user_id =
- SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId();
-
- // If sync is not yet fully initialized, the creation may take extra time,
- // so show a message. Import doesn't wait for an acknowledgement, so it
- // won't have the same potential delay.
- ProfileSyncService* sync_service =
- ProfileSyncServiceFactory::GetInstance()->GetForProfile(
- current_profile);
- ProfileSyncService::SyncStatusSummary status =
- sync_service->QuerySyncStatusSummary();
- if (status == ProfileSyncService::DATATYPES_NOT_INITIALIZED) {
- ShowProfileCreationWarning(l10n_util::GetStringUTF16(
- IDS_PROFILES_CREATE_SUPERVISED_JUST_SIGNED_IN));
- }
- }
+ args->GetBoolean(2, &create_shortcut);
}
+ std::string supervised_user_id;
+#if defined(ENABLE_MANAGED_USERS)
+ if (!ProcessSupervisedCreateProfileArgs(args, &supervised_user_id))
+ return;
+#endif
ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_USER_DIALOG);
@@ -139,8 +122,7 @@ void CreateProfileHandler::OnProfileCreated(
switch (status) {
case Profile::CREATE_STATUS_LOCAL_FAIL: {
- ShowProfileCreationError(profile,
- GetProfileCreationErrorMessage(LOCAL_ERROR));
+ ShowProfileCreationError(profile, GetProfileCreationErrorMessageLocal());
break;
}
case Profile::CREATE_STATUS_CREATED: {
@@ -176,66 +158,19 @@ void CreateProfileHandler::HandleProfileCreationSuccess(
CreateShortcutAndShowSuccess(create_shortcut, desktop_type, profile);
break;
}
+#if defined(ENABLE_MANAGED_USERS)
case SUPERVISED_PROFILE_CREATION:
case SUPERVISED_PROFILE_IMPORT:
RegisterSupervisedUser(create_shortcut, desktop_type,
supervised_user_id, profile);
break;
+#endif
case NO_CREATION_IN_PROGRESS:
NOTREACHED();
break;
}
}
-void CreateProfileHandler::RegisterSupervisedUser(
- bool create_shortcut,
- chrome::HostDesktopType desktop_type,
- const std::string& supervised_user_id,
- Profile* new_profile) {
- DCHECK_EQ(profile_path_being_created_.value(),
- new_profile->GetPath().value());
-
- SupervisedUserService* supervised_user_service =
- SupervisedUserServiceFactory::GetForProfile(new_profile);
-
- // Register the supervised user using the profile of the custodian.
- supervised_user_registration_utility_ =
- SupervisedUserRegistrationUtility::Create(Profile::FromWebUI(web_ui()));
- supervised_user_service->RegisterAndInitSync(
- supervised_user_registration_utility_.get(),
- Profile::FromWebUI(web_ui()),
- supervised_user_id,
- base::Bind(&CreateProfileHandler::OnSupervisedUserRegistered,
- weak_ptr_factory_.GetWeakPtr(),
- create_shortcut,
- desktop_type,
- new_profile));
-}
-
-void CreateProfileHandler::OnSupervisedUserRegistered(
- bool create_shortcut,
- chrome::HostDesktopType desktop_type,
- Profile* profile,
- const GoogleServiceAuthError& error) {
- GoogleServiceAuthError::State state = error.state();
- RecordSupervisedProfileCreationMetrics(state);
- if (state == GoogleServiceAuthError::NONE) {
- CreateShortcutAndShowSuccess(create_shortcut, desktop_type, profile);
- return;
- }
-
- base::string16 error_msg;
- if (state == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS ||
- state == GoogleServiceAuthError::USER_NOT_SIGNED_UP ||
- state == GoogleServiceAuthError::ACCOUNT_DELETED ||
- state == GoogleServiceAuthError::ACCOUNT_DISABLED) {
- error_msg = GetProfileCreationErrorMessage(SIGNIN_ERROR);
- } else {
- error_msg = GetProfileCreationErrorMessage(REMOTE_ERROR);
- }
- ShowProfileCreationError(profile, error_msg);
-}
-
void CreateProfileHandler::CreateShortcutAndShowSuccess(
bool create_shortcut,
chrome::HostDesktopType desktop_type,
@@ -255,10 +190,12 @@ void CreateProfileHandler::CreateShortcutAndShowSuccess(
dict.SetString("name",
profile->GetPrefs()->GetString(prefs::kProfileName));
dict.Set("filePath", base::CreateFilePathValue(profile->GetPath()));
+#if defined(ENABLE_MANAGED_USERS)
bool is_supervised =
profile_creation_type_ == SUPERVISED_PROFILE_CREATION ||
profile_creation_type_ == SUPERVISED_PROFILE_IMPORT;
dict.SetBoolean("isSupervised", is_supervised);
+#endif
web_ui()->CallJavascriptFunction(
GetJavascriptMethodName(PROFILE_CREATION_SUCCESS), dict);
@@ -267,7 +204,13 @@ void CreateProfileHandler::CreateShortcutAndShowSuccess(
// dialog. If we are importing an existing supervised profile or creating a
// new non-supervised user profile we don't show any confirmation, so open
// the new window now.
- if (profile_creation_type_ != SUPERVISED_PROFILE_CREATION) {
+ bool should_open_new_window = true;
+#if defined(ENABLE_MANAGED_USERS)
+ if (profile_creation_type_ == SUPERVISED_PROFILE_CREATION)
+ should_open_new_window = false;
+#endif
+
+ if (should_open_new_window) {
// Opening the new window must be the last action, after all callbacks
// have been run, to give them a chance to initialize the profile.
helper::OpenNewWindowForProfile(desktop_type,
@@ -291,11 +234,109 @@ void CreateProfileHandler::ShowProfileCreationError(
helper::DeleteProfileAtPath(profile->GetPath(), web_ui());
}
-void CreateProfileHandler::ShowProfileCreationWarning(
- const base::string16& warning) {
- DCHECK_EQ(SUPERVISED_PROFILE_CREATION, profile_creation_type_);
- web_ui()->CallJavascriptFunction("BrowserOptions.showCreateProfileWarning",
- base::StringValue(warning));
+void CreateProfileHandler::RecordProfileCreationMetrics(
+ Profile::CreateStatus status) {
+ UMA_HISTOGRAM_ENUMERATION("Profile.CreateResult",
+ status,
+ Profile::MAX_CREATE_STATUS);
+ UMA_HISTOGRAM_MEDIUM_TIMES(
+ "Profile.CreateTimeNoTimeout",
+ base::TimeTicks::Now() - profile_creation_start_time_);
+}
+
+base::string16 CreateProfileHandler::GetProfileCreationErrorMessageLocal()
+ const {
+ int message_id = IDS_PROFILES_CREATE_LOCAL_ERROR;
+#if defined(ENABLE_MANAGED_USERS)
+ // Local errors can occur during supervised profile import.
+ if (profile_creation_type_ == SUPERVISED_PROFILE_IMPORT)
+ message_id = IDS_SUPERVISED_USER_IMPORT_LOCAL_ERROR;
+#endif
+ return l10n_util::GetStringUTF16(message_id);
+}
+
+#if defined(ENABLE_MANAGED_USERS)
+base::string16 CreateProfileHandler::GetProfileCreationErrorMessageRemote()
+ const {
+ return l10n_util::GetStringUTF16(
+ profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ?
+ IDS_SUPERVISED_USER_IMPORT_REMOTE_ERROR :
+ IDS_PROFILES_CREATE_REMOTE_ERROR);
+}
+
+base::string16 CreateProfileHandler::GetProfileCreationErrorMessageSignin()
+ const {
+ return l10n_util::GetStringUTF16(
+ profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ?
+ IDS_SUPERVISED_USER_IMPORT_SIGN_IN_ERROR :
+ IDS_PROFILES_CREATE_SIGN_IN_ERROR);
+}
+#endif
+
+std::string CreateProfileHandler::GetJavascriptMethodName(
+ ProfileCreationStatus status) const {
+ switch (profile_creation_type_) {
+#if defined(ENABLE_MANAGED_USERS)
+ case SUPERVISED_PROFILE_IMPORT:
+ switch (status) {
+ case PROFILE_CREATION_SUCCESS:
+ return "BrowserOptions.showSupervisedUserImportSuccess";
+ case PROFILE_CREATION_ERROR:
+ return "BrowserOptions.showSupervisedUserImportError";
+ }
+ break;
+#endif
+ default:
+ switch (status) {
+ case PROFILE_CREATION_SUCCESS:
+ return "BrowserOptions.showCreateProfileSuccess";
+ case PROFILE_CREATION_ERROR:
+ return "BrowserOptions.showCreateProfileError";
+ }
+ break;
+ }
+
+ NOTREACHED();
+ return std::string();
+}
+
+#if defined(ENABLE_MANAGED_USERS)
+bool CreateProfileHandler::ProcessSupervisedCreateProfileArgs(
+ const base::ListValue* args, std::string* supervised_user_id) {
+ bool supervised_user = false;
+ if (args->GetSize() == 4) {
+ bool success = args->GetBoolean(3, &supervised_user);
+ DCHECK(success);
+
+ success = args->GetString(4, supervised_user_id);
+ DCHECK(success);
+ }
+
+ if (supervised_user) {
+ if (!IsValidExistingSupervisedUserId(*supervised_user_id))
+ return false;
+
+ profile_creation_type_ = SUPERVISED_PROFILE_IMPORT;
+ if (supervised_user_id->empty()) {
+ profile_creation_type_ = SUPERVISED_PROFILE_CREATION;
+ *supervised_user_id =
+ SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId();
+
+ // If sync is not yet fully initialized, the creation may take extra time,
+ // so show a message. Import doesn't wait for an acknowledgment, so it
+ // won't have the same potential delay.
+ ProfileSyncService* sync_service =
+ ProfileSyncServiceFactory::GetInstance()->GetForProfile(
+ Profile::FromWebUI(web_ui()));
+ ProfileSyncService::SyncStatusSummary status =
+ sync_service->QuerySyncStatusSummary();
+ if (status == ProfileSyncService::DATATYPES_NOT_INITIALIZED) {
+ ShowProfileCreationWarning(l10n_util::GetStringUTF16(
+ IDS_PROFILES_CREATE_SUPERVISED_JUST_SIGNED_IN));
+ }
+ }
+ }
+ return true;
}
void CreateProfileHandler::HandleCancelProfileCreation(
@@ -303,20 +344,20 @@ void CreateProfileHandler::HandleCancelProfileCreation(
CancelProfileRegistration(true);
}
+// Non-supervised user creation cannot be canceled. (Creating a non-supervised
+// profile shouldn't take significant time, and it can easily be deleted
+// afterward.)
void CreateProfileHandler::CancelProfileRegistration(bool user_initiated) {
if (profile_path_being_created_.empty())
return;
ProfileManager* manager = g_browser_process->profile_manager();
Profile* new_profile = manager->GetProfileByPath(profile_path_being_created_);
- if (!new_profile)
+ if (!new_profile || !new_profile->IsSupervised())
return;
- // Non-supervised user creation cannot be canceled. (Creating a non-supervised
- // profile shouldn't take significant time, and it can easily be deleted
- // afterward.)
- if (!new_profile->IsSupervised())
- return;
+ DCHECK(supervised_user_registration_utility_.get());
+ supervised_user_registration_utility_.reset();
if (user_initiated) {
UMA_HISTOGRAM_MEDIUM_TIMES(
@@ -325,9 +366,6 @@ void CreateProfileHandler::CancelProfileRegistration(bool user_initiated) {
RecordProfileCreationMetrics(Profile::CREATE_STATUS_CANCELED);
}
- DCHECK(supervised_user_registration_utility_.get());
- supervised_user_registration_utility_.reset();
-
DCHECK_NE(NO_CREATION_IN_PROGRESS, profile_creation_type_);
profile_creation_type_ = NO_CREATION_IN_PROGRESS;
@@ -337,14 +375,60 @@ void CreateProfileHandler::CancelProfileRegistration(bool user_initiated) {
helper::DeleteProfileAtPath(new_profile->GetPath(), web_ui());
}
-void CreateProfileHandler::RecordProfileCreationMetrics(
- Profile::CreateStatus status) {
- UMA_HISTOGRAM_ENUMERATION("Profile.CreateResult",
- status,
- Profile::MAX_CREATE_STATUS);
- UMA_HISTOGRAM_MEDIUM_TIMES(
- "Profile.CreateTimeNoTimeout",
- base::TimeTicks::Now() - profile_creation_start_time_);
+void CreateProfileHandler::RegisterSupervisedUser(
+ bool create_shortcut,
+ chrome::HostDesktopType desktop_type,
+ const std::string& supervised_user_id,
+ Profile* new_profile) {
+ DCHECK_EQ(profile_path_being_created_.value(),
+ new_profile->GetPath().value());
+
+ SupervisedUserService* supervised_user_service =
+ SupervisedUserServiceFactory::GetForProfile(new_profile);
+
+ // Register the supervised user using the profile of the custodian.
+ supervised_user_registration_utility_ =
+ SupervisedUserRegistrationUtility::Create(Profile::FromWebUI(web_ui()));
+ supervised_user_service->RegisterAndInitSync(
+ supervised_user_registration_utility_.get(),
+ Profile::FromWebUI(web_ui()),
+ supervised_user_id,
+ base::Bind(&CreateProfileHandler::OnSupervisedUserRegistered,
+ weak_ptr_factory_.GetWeakPtr(),
+ create_shortcut,
+ desktop_type,
+ new_profile));
+}
+
+void CreateProfileHandler::OnSupervisedUserRegistered(
+ bool create_shortcut,
+ chrome::HostDesktopType desktop_type,
+ Profile* profile,
+ const GoogleServiceAuthError& error) {
+ GoogleServiceAuthError::State state = error.state();
+ RecordSupervisedProfileCreationMetrics(state);
+ if (state == GoogleServiceAuthError::NONE) {
+ CreateShortcutAndShowSuccess(create_shortcut, desktop_type, profile);
+ return;
+ }
+
+ base::string16 error_msg;
+ if (state == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS ||
+ state == GoogleServiceAuthError::USER_NOT_SIGNED_UP ||
+ state == GoogleServiceAuthError::ACCOUNT_DELETED ||
+ state == GoogleServiceAuthError::ACCOUNT_DISABLED) {
+ error_msg = GetProfileCreationErrorMessageSignin();
+ } else {
+ error_msg = GetProfileCreationErrorMessageRemote();
+ }
+ ShowProfileCreationError(profile, error_msg);
+}
+
+void CreateProfileHandler::ShowProfileCreationWarning(
+ const base::string16& warning) {
+ DCHECK_EQ(SUPERVISED_PROFILE_CREATION, profile_creation_type_);
+ web_ui()->CallJavascriptFunction("BrowserOptions.showCreateProfileWarning",
+ base::StringValue(warning));
}
void CreateProfileHandler::RecordSupervisedProfileCreationMetrics(
@@ -367,50 +451,6 @@ void CreateProfileHandler::RecordSupervisedProfileCreationMetrics(
}
}
-base::string16 CreateProfileHandler::GetProfileCreationErrorMessage(
- ProfileCreationErrorType error) const {
- int message_id = -1;
- switch (error) {
- case SIGNIN_ERROR:
- message_id =
- profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ?
- IDS_SUPERVISED_USER_IMPORT_SIGN_IN_ERROR :
- IDS_PROFILES_CREATE_SIGN_IN_ERROR;
- break;
- case REMOTE_ERROR:
- message_id =
- profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ?
- IDS_SUPERVISED_USER_IMPORT_REMOTE_ERROR :
- IDS_PROFILES_CREATE_REMOTE_ERROR;
- break;
- case LOCAL_ERROR:
- message_id =
- profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ?
- IDS_SUPERVISED_USER_IMPORT_LOCAL_ERROR :
- IDS_PROFILES_CREATE_LOCAL_ERROR;
- break;
- }
-
- return l10n_util::GetStringUTF16(message_id);
-}
-
-std::string CreateProfileHandler::GetJavascriptMethodName(
- ProfileCreationStatus status) const {
- switch (status) {
- case PROFILE_CREATION_SUCCESS:
- return profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ?
- "BrowserOptions.showSupervisedUserImportSuccess" :
- "BrowserOptions.showCreateProfileSuccess";
- case PROFILE_CREATION_ERROR:
- return profile_creation_type_ == SUPERVISED_PROFILE_IMPORT ?
- "BrowserOptions.showSupervisedUserImportError" :
- "BrowserOptions.showCreateProfileError";
- }
-
- NOTREACHED();
- return std::string();
-}
-
bool CreateProfileHandler::IsValidExistingSupervisedUserId(
const std::string& existing_supervised_user_id) const {
if (existing_supervised_user_id.empty())
@@ -433,5 +473,6 @@ bool CreateProfileHandler::IsValidExistingSupervisedUserId(
}
return true;
}
+#endif
} // namespace options
diff --git a/chrome/browser/ui/webui/options/create_profile_handler.h b/chrome/browser/ui/webui/options/create_profile_handler.h
index d6e3ea7..d299c10 100644
--- a/chrome/browser/ui/webui/options/create_profile_handler.h
+++ b/chrome/browser/ui/webui/options/create_profile_handler.h
@@ -19,7 +19,9 @@ class DictionaryValue;
class ListValue;
}
+#if defined(ENABLE_MANAGED_USERS)
class SupervisedUserRegistrationUtility;
+#endif
namespace options {
@@ -44,21 +46,14 @@ class CreateProfileHandler: public OptionsPageUIHandler {
PROFILE_CREATION_ERROR,
};
- // Represents errors that could occur during a profile creation.
- // It is used to map error types to messages that will be displayed
- // to the user.
- enum ProfileCreationErrorType {
- REMOTE_ERROR,
- LOCAL_ERROR,
- SIGNIN_ERROR
- };
-
// Represents the type of the in progress profile creation operation.
// It is used to map the type of the profile creation operation to the
// correct UMA metric name.
enum ProfileCreationOperationType {
+#if defined(ENABLE_MANAGED_USERS)
SUPERVISED_PROFILE_CREATION,
SUPERVISED_PROFILE_IMPORT,
+#endif
NON_SUPERVISED_PROFILE_CREATION,
NO_CREATION_IN_PROGRESS
};
@@ -90,19 +85,6 @@ class CreateProfileHandler: public OptionsPageUIHandler {
const std::string& supervised_user_id,
Profile* profile);
- // After a new supervised-user profile has been created, registers the user
- // with the management server.
- void RegisterSupervisedUser(bool create_shortcut,
- chrome::HostDesktopType desktop_type,
- const std::string& supervised_user_id,
- Profile* new_profile);
-
- // Called back with the result of the supervised user registration.
- void OnSupervisedUserRegistered(bool create_shortcut,
- chrome::HostDesktopType desktop_type,
- Profile* profile,
- const GoogleServiceAuthError& error);
-
// Creates desktop shortcut and updates the UI to indicate success
// when creating a profile.
void CreateShortcutAndShowSuccess(bool create_shortcut,
@@ -115,6 +97,37 @@ class CreateProfileHandler: public OptionsPageUIHandler {
// Updates the UI to show a non-fatal warning when creating a profile.
void ShowProfileCreationWarning(const base::string16& warning);
+ // Records UMA histograms relevant to profile creation.
+ void RecordProfileCreationMetrics(Profile::CreateStatus status);
+
+ base::string16 GetProfileCreationErrorMessageLocal() const;
+#if defined(ENABLE_MANAGED_USERS)
+ // The following error messages only apply to supervised profiles.
+ base::string16 GetProfileCreationErrorMessageRemote() const;
+ base::string16 GetProfileCreationErrorMessageSignin() const;
+#endif
+
+ std::string GetJavascriptMethodName(ProfileCreationStatus status) const;
+
+ // Used to allow cancelling a profile creation (particularly a supervised-user
+ // registration) in progress. Set when profile creation is begun, and
+ // cleared when all the callbacks have been run and creation is complete.
+ base::FilePath profile_path_being_created_;
+
+ // Used to track how long profile creation takes.
+ base::TimeTicks profile_creation_start_time_;
+
+ // Indicates the type of the in progress profile creation operation.
+ // The value is only relevant while we are creating/importing a profile.
+ ProfileCreationOperationType profile_creation_type_;
+
+#if defined(ENABLE_MANAGED_USERS)
+ // Extracts the supervised user ID from the args passed into CreateProfile,
+ // sets |profile_creation_type_| if necessary, and returns true if the
+ // supervised user id specified in |args| are valid.
+ bool ProcessSupervisedCreateProfileArgs(const base::ListValue* args,
+ std::string* supervised_user_id);
+
// Cancels creation of a supervised-user profile currently in progress, as
// indicated by profile_path_being_created_, removing the object and files
// and canceling supervised-user registration. This is the handler for the
@@ -127,35 +140,30 @@ class CreateProfileHandler: public OptionsPageUIHandler {
// was caused implicitly, e.g. by shutting down the browser.
void CancelProfileRegistration(bool user_initiated);
- // Records UMA histograms relevant to profile creation.
- void RecordProfileCreationMetrics(Profile::CreateStatus status);
+ // After a new supervised-user profile has been created, registers the user
+ // with the management server.
+ void RegisterSupervisedUser(bool create_shortcut,
+ chrome::HostDesktopType desktop_type,
+ const std::string& managed_user_id,
+ Profile* new_profile);
+
+ // Called back with the result of the supervised user registration.
+ void OnSupervisedUserRegistered(bool create_shortcut,
+ chrome::HostDesktopType desktop_type,
+ Profile* profile,
+ const GoogleServiceAuthError& error);
// Records UMA histograms relevant to supervised user profiles
// creation and registration.
void RecordSupervisedProfileCreationMetrics(
GoogleServiceAuthError::State error_state);
- base::string16 GetProfileCreationErrorMessage(
- ProfileCreationErrorType error) const;
- std::string GetJavascriptMethodName(ProfileCreationStatus status) const;
-
bool IsValidExistingSupervisedUserId(
const std::string& existing_supervised_user_id) const;
- // Used to allow cancelling a profile creation (particularly a supervised-user
- // registration) in progress. Set when profile creation is begun, and
- // cleared when all the callbacks have been run and creation is complete.
- base::FilePath profile_path_being_created_;
-
- // Used to track how long profile creation takes.
- base::TimeTicks profile_creation_start_time_;
-
scoped_ptr<SupervisedUserRegistrationUtility>
supervised_user_registration_utility_;
-
- // Indicates the type of the in progress profile creation operation.
- // The value is only relevant while we are creating/importing a profile.
- ProfileCreationOperationType profile_creation_type_;
+#endif
base::WeakPtrFactory<CreateProfileHandler> weak_ptr_factory_;
diff --git a/chrome/browser/ui/webui/options/options_ui.cc b/chrome/browser/ui/webui/options/options_ui.cc
index 76a997f..7581e87 100644
--- a/chrome/browser/ui/webui/options/options_ui.cc
+++ b/chrome/browser/ui/webui/options/options_ui.cc
@@ -70,6 +70,12 @@
#include "ui/base/webui/web_ui_util.h"
#include "url/gurl.h"
+#if defined(ENABLE_MANAGED_USERS)
+#include "chrome/browser/ui/webui/options/supervised_user_create_confirm_handler.h"
+#include "chrome/browser/ui/webui/options/supervised_user_import_handler.h"
+#include "chrome/browser/ui/webui/options/supervised_user_learn_more_handler.h"
+#endif
+
#if defined(OS_CHROMEOS)
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
@@ -295,11 +301,13 @@ OptionsUI::OptionsUI(content::WebUI* web_ui)
AddOptionsPageUIHandler(localized_strings, new SearchEngineManagerHandler());
AddOptionsPageUIHandler(localized_strings, new ImportDataHandler());
AddOptionsPageUIHandler(localized_strings, new StartupPagesHandler());
+#if defined(ENABLE_MANAGED_USERS)
AddOptionsPageUIHandler(localized_strings,
new SupervisedUserCreateConfirmHandler());
AddOptionsPageUIHandler(localized_strings, new SupervisedUserImportHandler());
AddOptionsPageUIHandler(localized_strings,
new SupervisedUserLearnMoreHandler());
+#endif
AddOptionsPageUIHandler(localized_strings, new SyncSetupHandler(
g_browser_process->profile_manager()));
AddOptionsPageUIHandler(localized_strings, new WebsiteSettingsHandler());
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index e852dcc..849062f 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -2157,8 +2157,6 @@
'browser/ui/views/passwords/manage_passwords_icon_view.h',
'browser/ui/views/pdf_password_dialog.cc',
'browser/ui/views/process_singleton_dialog_linux.cc',
- 'browser/ui/views/profiles/avatar_label.cc',
- 'browser/ui/views/profiles/avatar_label.h',
'browser/ui/views/profiles/avatar_menu_bubble_view.cc',
'browser/ui/views/profiles/avatar_menu_bubble_view.h',
'browser/ui/views/profiles/avatar_menu_button.cc',
@@ -2169,6 +2167,8 @@
'browser/ui/views/profiles/profile_chooser_view.h',
'browser/ui/views/profiles/profile_reset_bubble_view.cc',
'browser/ui/views/profiles/profile_reset_bubble_view.h',
+ 'browser/ui/views/profiles/supervised_user_avatar_label.cc',
+ 'browser/ui/views/profiles/supervised_user_avatar_label.h',
'browser/ui/views/profiles/user_manager_view.cc',
'browser/ui/views/profiles/user_manager_view.h',
'browser/ui/views/renderer_context_menu/render_view_context_menu_views.cc',
@@ -2963,6 +2963,18 @@
['enable_google_now==1 and OS!="android"', {
'sources': [ '<@(chrome_browser_ui_google_now_non_android_sources)' ],
}],
+ ['enable_managed_users==0', {
+ 'sources!': [
+ 'browser/ui/views/profiles/supervised_user_avatar_label.cc',
+ 'browser/ui/views/profiles/supervised_user_avatar_label.h',
+ 'browser/ui/webui/options/supervised_user_create_confirm_handler.cc',
+ 'browser/ui/webui/options/supervised_user_create_confirm_handler.h',
+ 'browser/ui/webui/options/supervised_user_import_handler.cc',
+ 'browser/ui/webui/options/supervised_user_import_handler.h',
+ 'browser/ui/webui/options/supervised_user_learn_more_handler.cc',
+ 'browser/ui/webui/options/supervised_user_learn_more_handler.h',
+ ],
+ }],
['enable_webrtc==1', {
'sources': [ '<@(chrome_browser_ui_webrtc_sources)' ],
}],
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index fce3e37..500764a 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1513,6 +1513,10 @@
'browser/ui/webui/downloads_ui_browsertest.cc',
'browser/ui/webui/downloads_ui_browsertest.h',
'browser/ui/webui/downloads_ui_browsertest.js',
+ 'browser/ui/webui/downloads_ui_browsertest_base.js',
+ 'browser/ui/webui/downloads_ui_supervised_browsertest.cc',
+ 'browser/ui/webui/downloads_ui_supervised_browsertest.h',
+ 'browser/ui/webui/downloads_ui_supervised_browsertest.js',
'browser/ui/webui/extensions/chromeos/kiosk_apps_browsertest.js',
'browser/ui/webui/extensions/extension_settings_browsertest.cc',
'browser/ui/webui/extensions/extension_settings_browsertest.h',
@@ -2078,6 +2082,14 @@
['exclude', '^browser/ui/webui/app_list/'],
],
}],
+ ['enable_managed_users==0', {
+ 'sources/': [
+ ['exclude', '^browser/supervised_user/'],
+ ['exclude', '^browser/ui/webui/downloads_ui_supervised_browsertest.cc'],
+ ['exclude', '^browser/ui/webui/downloads_ui_supervised_browsertest.h'],
+ ['exclude', '^browser/ui/webui/downloads_ui_supervised_browsertest.js'],
+ ],
+ }],
['enable_pepper_cdms==1', {
'dependencies': [
# Runtime dependencies.
@@ -2583,6 +2595,11 @@
'browser/sync/test/integration/two_client_app_list_sync_test.cc',
],
}],
+ ['enable_managed_users==0', {
+ 'sources!': [
+ 'browser/sync/test/integration/single_client_supervised_user_settings_sync_test.cc',
+ ],
+ }],
],
},
{