summaryrefslogtreecommitdiffstats
path: root/chrome/browser/profiles
diff options
context:
space:
mode:
authorbcwhite@chromium.org <bcwhite@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-13 16:43:27 +0000
committerbcwhite@chromium.org <bcwhite@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-13 16:43:27 +0000
commitc8160ae62304dacfaea4746b05fed00f567efc3d (patch)
treede45f03c7c40f47244f514091852a0cc019e3ed6 /chrome/browser/profiles
parentda72f31bf3b69c23b91b7a777408705be240256b (diff)
downloadchromium_src-c8160ae62304dacfaea4746b05fed00f567efc3d.zip
chromium_src-c8160ae62304dacfaea4746b05fed00f567efc3d.tar.gz
chromium_src-c8160ae62304dacfaea4746b05fed00f567efc3d.tar.bz2
First work towards new "avatar" menu.
This is not complete but it marks a point where others can try it and build off of it for other features (and thus work in parallel). The two main buttons are currently non-functional (to be worked on in parallel) but you can switch profiles by selecting the appropriate icon. The "sign-out" button does work. Example: http://www/~bcwhite/new-avatar-2.png To test this, add these two flags to the command line: --new-profile-management --gaia-profile-info BUG=239800 Review URL: https://chromiumcodereview.appspot.com/15145006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206092 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/profiles')
-rw-r--r--chrome/browser/profiles/avatar_menu_model.cc20
-rw-r--r--chrome/browser/profiles/avatar_menu_model.h10
-rw-r--r--chrome/browser/profiles/avatar_menu_model_browsertest.cc3
-rw-r--r--chrome/browser/profiles/profile_info_util.cc8
-rw-r--r--chrome/browser/profiles/profile_info_util.h1
5 files changed, 30 insertions, 12 deletions
diff --git a/chrome/browser/profiles/avatar_menu_model.cc b/chrome/browser/profiles/avatar_menu_model.cc
index e77577a..bc9767d 100644
--- a/chrome/browser/profiles/avatar_menu_model.cc
+++ b/chrome/browser/profiles/avatar_menu_model.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/profiles/avatar_menu_model.h"
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
@@ -23,6 +24,7 @@
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
@@ -283,8 +285,13 @@ void AvatarMenuModel::RebuildMenu() {
bool is_gaia_picture =
profile_info_->IsUsingGAIAPictureOfProfileAtIndex(i) &&
profile_info_->GetGAIAPictureOfProfileAtIndex(i);
- gfx::Image icon = profiles::GetAvatarIconForMenu(
- profile_info_->GetAvatarIconOfProfileAtIndex(i), is_gaia_picture);
+
+ gfx::Image icon = profile_info_->GetAvatarIconOfProfileAtIndex(i);
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kNewProfileManagement)) {
+ // old avatar menu uses resized-small images
+ icon = profiles::GetAvatarIconForMenu(icon, is_gaia_picture);
+ }
Item* item = new Item(i, icon);
item->name = profile_info_->GetNameOfProfileAtIndex(i);
@@ -309,8 +316,7 @@ void AvatarMenuModel::ClearMenu() {
}
-content::WebContents* AvatarMenuModel::BeginSignOut(
- const char* logout_override) {
+content::WebContents* AvatarMenuModel::BeginSignOut() {
ProfileManager* profile_manager = g_browser_process->profile_manager();
Profile* current_profile = browser_->profile();
@@ -321,10 +327,10 @@ content::WebContents* AvatarMenuModel::BeginSignOut(
std::string landing_url = SyncPromoUI::GetSyncLandingURL("close", 1);
GURL logout_url(GaiaUrls::GetInstance()->service_logout_url() +
"?continue=" + landing_url);
- if (logout_override) {
+ if (!logout_override_.empty()) {
// We're testing...
- landing_url = logout_override;
- logout_url = GURL(logout_override);
+ landing_url = logout_override_;
+ logout_url = GURL(logout_override_);
}
content::WebContents::CreateParams create_params(current_profile);
diff --git a/chrome/browser/profiles/avatar_menu_model.h b/chrome/browser/profiles/avatar_menu_model.h
index 52c7cc5..0ab6818 100644
--- a/chrome/browser/profiles/avatar_menu_model.h
+++ b/chrome/browser/profiles/avatar_menu_model.h
@@ -115,7 +115,12 @@ class AvatarMenuModel : public content::NotificationObserver {
// Parameter |logout_override| alows changing the destination URL for the
// sign-out process and return value (the WebContents executing the sign-out)
// are for testing; pass NULL for normal use.
- content::WebContents* BeginSignOut(const char* logout_override);
+ content::WebContents* BeginSignOut();
+
+ // Use a different URL for logout (for testing only).
+ void SetLogoutURL(const std::string& logout_url) {
+ logout_override_ = logout_url;
+ }
private:
// Rebuilds the menu from the cache and notifies the |observer_|.
@@ -139,6 +144,9 @@ class AvatarMenuModel : public content::NotificationObserver {
// Listens for notifications from the ProfileInfoCache.
content::NotificationRegistrar registrar_;
+ // Special "override" logout URL used to let tests work.
+ std::string logout_override_;
+
DISALLOW_COPY_AND_ASSIGN(AvatarMenuModel);
};
diff --git a/chrome/browser/profiles/avatar_menu_model_browsertest.cc b/chrome/browser/profiles/avatar_menu_model_browsertest.cc
index 970a660..816f801 100644
--- a/chrome/browser/profiles/avatar_menu_model_browsertest.cc
+++ b/chrome/browser/profiles/avatar_menu_model_browsertest.cc
@@ -37,7 +37,8 @@ IN_PROC_BROWSER_TEST_F(AvatarMenuModelTest, SignOut) {
content::Source<Browser>(browser()));
EXPECT_FALSE(cache.ProfileIsSigninRequiredAtIndex(index));
- model.BeginSignOut("about:blank");
+ model.SetLogoutURL("about:blank");
+ model.BeginSignOut();
EXPECT_TRUE(cache.ProfileIsSigninRequiredAtIndex(index));
window_close_observer.Wait(); // rely on test time-out for failure indication
diff --git a/chrome/browser/profiles/profile_info_util.cc b/chrome/browser/profiles/profile_info_util.cc
index 82e5360..680334c 100644
--- a/chrome/browser/profiles/profile_info_util.cc
+++ b/chrome/browser/profiles/profile_info_util.cc
@@ -12,6 +12,7 @@ namespace profiles {
const int kAvatarIconWidth = 38;
const int kAvatarIconHeight = 31;
+const int kAvatarIconBorder = 2;
gfx::Image GetSizedAvatarIconWithBorder(const gfx::Image& image,
bool is_gaia_picture,
@@ -19,7 +20,7 @@ gfx::Image GetSizedAvatarIconWithBorder(const gfx::Image& image,
if (!is_gaia_picture)
return image;
- int length = std::min(width, height) - 2;
+ int length = std::min(width, height) - kAvatarIconBorder;
SkBitmap bmp = skia::ImageOperations::Resize(
*image.ToSkBitmap(), skia::ImageOperations::RESIZE_BEST, length, length);
gfx::Canvas canvas(gfx::Size(width, height), ui::SCALE_FACTOR_100P, false);
@@ -47,7 +48,8 @@ gfx::Image GetAvatarIconForWebUI(const gfx::Image& image,
if (!is_gaia_picture)
return image;
- int length = std::min(kAvatarIconWidth, kAvatarIconHeight) - 2;
+ int length =
+ std::min(kAvatarIconWidth, kAvatarIconHeight) - kAvatarIconBorder;
SkBitmap bmp = skia::ImageOperations::Resize(
*image.ToSkBitmap(), skia::ImageOperations::RESIZE_BEST, length, length);
gfx::Canvas canvas(gfx::Size(kAvatarIconWidth, kAvatarIconHeight),
@@ -69,7 +71,7 @@ gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image,
return image;
int length = std::min(std::min(kAvatarIconWidth, kAvatarIconHeight),
- std::min(dst_width, dst_height)) - 2;
+ std::min(dst_width, dst_height)) - kAvatarIconBorder;
SkBitmap bmp = skia::ImageOperations::Resize(
*image.ToSkBitmap(), skia::ImageOperations::RESIZE_BEST, length, length);
gfx::Canvas canvas(gfx::Size(dst_width, dst_height), ui::SCALE_FACTOR_100P,
diff --git a/chrome/browser/profiles/profile_info_util.h b/chrome/browser/profiles/profile_info_util.h
index 9f0569e..f33d2b3 100644
--- a/chrome/browser/profiles/profile_info_util.h
+++ b/chrome/browser/profiles/profile_info_util.h
@@ -11,6 +11,7 @@ namespace profiles {
extern const int kAvatarIconWidth;
extern const int kAvatarIconHeight;
+extern const int kAvatarIconBorder;
// Returns a version of |image| of a specific size and with a grey border.
// Note that no checks are done on the width/height so make sure they're