Commit 5824d790 authored by janeliulwq's avatar janeliulwq Committed by Commit bot

Previous code change 2018643002 (for user menu redesign) modified code on the...

Previous code change 2018643002 (for user menu redesign) modified code on the spot and did not put the changes behind any flag. This CL is to:
1. add flags for the previous code change;
2. add back some of the deleted resources as they will still be used when the flag is not turned on.

BUG=615893

Review-Url: https://codereview.chromium.org/2034093003
Cr-Commit-Position: refs/heads/master@{#398184}
parent 0e577e54
...@@ -10802,6 +10802,12 @@ I don't think this site should be blocked! ...@@ -10802,6 +10802,12 @@ I don't think this site should be blocked!
<message name="IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE" desc="The Learn More link in the avatar tutorial bubble."> <message name="IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE" desc="The Learn More link in the avatar tutorial bubble.">
Learn more Learn more
</message> </message>
<message name="IDS_PROFILES_SWITCH_USERS_BUTTON" desc="Button in the avatar menu bubble view for launching the user manager.">
Switch person
</message>
<message name="IDS_PROFILES_GO_INCOGNITO_BUTTON" desc="Button in the avatar menu bubble view for launching an incognito browser.">
Go incognito
</message>
<message name="IDS_PROFILES_MANAGE_USERS_BUTTON" desc="Button in the avatar menu bubble view for launching the user manager."> <message name="IDS_PROFILES_MANAGE_USERS_BUTTON" desc="Button in the avatar menu bubble view for launching the user manager.">
Manage people Manage people
</message> </message>
...@@ -10819,6 +10825,12 @@ I don't think this site should be blocked! ...@@ -10819,6 +10825,12 @@ I don't think this site should be blocked!
<message name="IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE" desc="The Learn More link in the avatar tutorial bubble."> <message name="IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE" desc="The Learn More link in the avatar tutorial bubble.">
Learn More Learn More
</message> </message>
<message name="IDS_PROFILES_SWITCH_USERS_BUTTON" desc="Button in the avatar menu bubble view for launching the user manager.">
Switch Person
</message>
<message name="IDS_PROFILES_GO_INCOGNITO_BUTTON" desc="Button in the avatar menu bubble view for launching an incognito browser.">
Go Incognito
</message>
<message name="IDS_PROFILES_MANAGE_USERS_BUTTON" desc="Button in the avatar menu bubble view for launching the user manager."> <message name="IDS_PROFILES_MANAGE_USERS_BUTTON" desc="Button in the avatar menu bubble view for launching the user manager.">
Manage People Manage People
</message> </message>
......
...@@ -308,6 +308,10 @@ ...@@ -308,6 +308,10 @@
<structure type="chrome_scaled_image" name="IDR_HOME_P" file="common/browser_home_pressed.png" /> <structure type="chrome_scaled_image" name="IDR_HOME_P" file="common/browser_home_pressed.png" />
</if> </if>
<structure type="chrome_scaled_image" name="IDR_HOTWORD_NOTIFICATION_ICON" file="common/notification_hotword_icon.png" /> <structure type="chrome_scaled_image" name="IDR_HOTWORD_NOTIFICATION_ICON" file="common/notification_hotword_icon.png" />
<if expr="not is_android and not is_ios">
<!-- TODO(estade): replace with vector image when one's available. -->
<structure type="chrome_scaled_image" name="IDR_ICON_PROFILES_MENU_INCOGNITO" file="common/incognito.png" />
</if>
<if expr="is_macosx"> <if expr="is_macosx">
<structure type="chrome_scaled_image" name="IDR_ICON_PROFILES_ACCOUNT_BUTTON_ERROR" file="legacy/avatar_menu_auth_error.png" /> <structure type="chrome_scaled_image" name="IDR_ICON_PROFILES_ACCOUNT_BUTTON_ERROR" file="legacy/avatar_menu_auth_error.png" />
<structure type="chrome_scaled_image" name="IDR_ICON_PROFILES_AVATAR_BUTTON_ERROR" file="legacy/avatar_button_auth_error.png" /> <structure type="chrome_scaled_image" name="IDR_ICON_PROFILES_AVATAR_BUTTON_ERROR" file="legacy/avatar_button_auth_error.png" />
......
...@@ -1034,6 +1034,13 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1034,6 +1034,13 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
profiles::CloseGuestProfileWindows(); profiles::CloseGuestProfileWindows();
} }
- (IBAction)goIncognito:(id)sender {
DCHECK([self shouldShowGoIncognito]);
chrome::NewIncognitoWindow(browser_);
[self postActionPerformed:
ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO];
}
- (IBAction)showAccountManagement:(id)sender { - (IBAction)showAccountManagement:(id)sender {
[self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
} }
...@@ -1961,9 +1968,27 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1961,9 +1968,27 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
viewRect.origin.y = NSMaxY([separator frame]); viewRect.origin.y = NSMaxY([separator frame]);
} }
if (!switches::IsMaterialDesignUserMenu() && [self shouldShowGoIncognito]) {
NSButton* goIncognitoButton =
[self hoverButtonWithRect:viewRect
text:l10n_util::GetNSString(
IDS_PROFILES_GO_INCOGNITO_BUTTON)
imageResourceId:IDR_ICON_PROFILES_MENU_INCOGNITO
action:@selector(goIncognito:)];
viewRect.origin.y = NSMaxY([goIncognitoButton frame]);
[container addSubview:goIncognitoButton];
NSBox* separator = [self horizontalSeparatorWithFrame:viewRect];
[container addSubview:separator];
viewRect.origin.y = NSMaxY([separator frame]);
}
NSString* text = isGuestSession_ ? NSString* text = isGuestSession_ ?
l10n_util::GetNSString(IDS_PROFILES_EXIT_GUEST) : l10n_util::GetNSString(IDS_PROFILES_EXIT_GUEST) :
l10n_util::GetNSString(IDS_PROFILES_MANAGE_USERS_BUTTON); l10n_util::GetNSString(IDS_PROFILES_SWITCH_USERS_BUTTON);
if (!isGuestSession_ && switches::IsMaterialDesignUserMenu()) {
text = l10n_util::GetNSString(IDS_PROFILES_MANAGE_USERS_BUTTON);
}
NSButton* switchUsersButton = NSButton* switchUsersButton =
[self hoverButtonWithRect:viewRect [self hoverButtonWithRect:viewRect
text:text text:text
......
...@@ -181,11 +181,31 @@ TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) { ...@@ -181,11 +181,31 @@ TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) {
// There should be one button in the option buttons view. // There should be one button in the option buttons view.
NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
NSButton* userSwitcherButton;
if (switches::IsMaterialDesignUserMenu()) {
ASSERT_EQ(1U, [buttonSubviews count]); ASSERT_EQ(1U, [buttonSubviews count]);
// There should be a user switcher button. // There should be a user switcher button.
NSButton* userSwitcherButton = userSwitcherButton =
base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
} else {
// For non-material-design user menu, there should be two buttons and a
// separator in the option buttons view.
ASSERT_EQ(3U, [buttonSubviews count]);
// There should be an incognito button.
NSButton* incognitoButton =
base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
EXPECT_EQ(@selector(goIncognito:), [incognitoButton action]);
EXPECT_EQ(controller(), [incognitoButton target]);
// There should be a separator.
EXPECT_TRUE([[subviews objectAtIndex:1] isKindOfClass:[NSBox class]]);
// There should be a user switcher button.
userSwitcherButton =
base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:2]);
}
EXPECT_EQ(@selector(showUserManager:), [userSwitcherButton action]); EXPECT_EQ(@selector(showUserManager:), [userSwitcherButton action]);
EXPECT_EQ(controller(), [userSwitcherButton target]); EXPECT_EQ(controller(), [userSwitcherButton target]);
...@@ -422,13 +442,33 @@ TEST_F(ProfileChooserControllerTest, AccountManagementLayout) { ...@@ -422,13 +442,33 @@ TEST_F(ProfileChooserControllerTest, AccountManagementLayout) {
// and one option buttons view. // and one option buttons view.
ASSERT_EQ(5U, [subviews count]); ASSERT_EQ(5U, [subviews count]);
// There should be one button in the option buttons view.
NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
NSButton* userSwitcherButton;
if (switches::IsMaterialDesignUserMenu()) {
// There should be one button in the option buttons view.
ASSERT_EQ(1U, [buttonSubviews count]); ASSERT_EQ(1U, [buttonSubviews count]);
// There should be a user switcher button. // There should be a user switcher button.
NSButton* userSwitcherButton = userSwitcherButton =
base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
} else {
// For non-material-design user menu, there should be two buttons and one
// separator in the option buttons view.
ASSERT_EQ(3U, [buttonSubviews count]);
// There should be an incognito button.
NSButton* incognitoButton =
base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]); base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:0]);
EXPECT_EQ(@selector(goIncognito:), [incognitoButton action]);
EXPECT_EQ(controller(), [incognitoButton target]);
// There should be a separator.
EXPECT_TRUE([[buttonSubviews objectAtIndex:1] isKindOfClass:[NSBox class]]);
// There should be a user switcher button.
userSwitcherButton =
base::mac::ObjCCast<NSButton>([buttonSubviews objectAtIndex:2]);
}
EXPECT_EQ(@selector(showUserManager:), [userSwitcherButton action]); EXPECT_EQ(@selector(showUserManager:), [userSwitcherButton action]);
EXPECT_EQ(controller(), [userSwitcherButton target]); EXPECT_EQ(controller(), [userSwitcherButton target]);
...@@ -508,9 +548,15 @@ TEST_F(ProfileChooserControllerTest, SignedInProfileLockDisabled) { ...@@ -508,9 +548,15 @@ TEST_F(ProfileChooserControllerTest, SignedInProfileLockDisabled) {
ASSERT_EQ(2U, [subviews count]); ASSERT_EQ(2U, [subviews count]);
subviews = [[subviews objectAtIndex:0] subviews]; subviews = [[subviews objectAtIndex:0] subviews];
// There will be one button in the option buttons view.
NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
if (switches::IsMaterialDesignUserMenu()) {
// There will be one button in the option buttons view.
ASSERT_EQ(1U, [buttonSubviews count]); ASSERT_EQ(1U, [buttonSubviews count]);
} else {
// For non-material-design user menu, there will be two buttons and one
// separators in the option buttons view.
ASSERT_EQ(3U, [buttonSubviews count]);
}
// The last button should not be the lock button. // The last button should not be the lock button.
NSButton* lastButton = NSButton* lastButton =
...@@ -538,9 +584,15 @@ TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) { ...@@ -538,9 +584,15 @@ TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) {
ASSERT_EQ(2U, [subviews count]); ASSERT_EQ(2U, [subviews count]);
subviews = [[subviews objectAtIndex:0] subviews]; subviews = [[subviews objectAtIndex:0] subviews];
// There will be two buttons and one separator in the option buttons view.
NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
if (switches::IsMaterialDesignUserMenu()) {
// There will be two buttons and one separator in the option buttons view.
ASSERT_EQ(3U, [buttonSubviews count]); ASSERT_EQ(3U, [buttonSubviews count]);
} else {
// FOr non-material-design user menu, There will be three buttons and two
// separators in the option buttons view.
ASSERT_EQ(5U, [buttonSubviews count]);
}
// There should be a lock button. // There should be a lock button.
NSButton* lockButton = NSButton* lockButton =
......
...@@ -699,6 +699,7 @@ void ProfileChooserView::ResetView() { ...@@ -699,6 +699,7 @@ void ProfileChooserView::ResetView() {
current_profile_photo_ = NULL; current_profile_photo_ = NULL;
current_profile_name_ = NULL; current_profile_name_ = NULL;
users_button_ = NULL; users_button_ = NULL;
go_incognito_button_ = NULL;
lock_button_ = NULL; lock_button_ = NULL;
add_account_link_ = NULL; add_account_link_ = NULL;
gaia_signin_cancel_button_ = NULL; gaia_signin_cancel_button_ = NULL;
...@@ -911,6 +912,10 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, ...@@ -911,6 +912,10 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
} }
PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER);
} else if (sender == go_incognito_button_) {
DCHECK(ShouldShowGoIncognito());
chrome::NewIncognitoWindow(browser_);
PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO);
} else if (sender == lock_button_) { } else if (sender == lock_button_) {
profiles::LockProfile(browser_->profile()); profiles::LockProfile(browser_->profile());
PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK);
...@@ -1496,7 +1501,11 @@ views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { ...@@ -1496,7 +1501,11 @@ views::View* ProfileChooserView::CreateOptionsView(bool display_lock) {
base::string16 text = browser_->profile()->IsGuestSession() ? base::string16 text = browser_->profile()->IsGuestSession() ?
l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) :
l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON);
if (!browser_->profile()->IsGuestSession()
&& switches::IsMaterialDesignUserMenu()) {
text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON);
}
const int kIconSize = 16; const int kIconSize = 16;
gfx::VectorIconId settings_icon = switches::IsMaterialDesignUserMenu() ? gfx::VectorIconId settings_icon = switches::IsMaterialDesignUserMenu() ?
...@@ -1508,6 +1517,19 @@ views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { ...@@ -1508,6 +1517,19 @@ views::View* ProfileChooserView::CreateOptionsView(bool display_lock) {
layout->StartRow(1, 0); layout->StartRow(1, 0);
layout->AddView(users_button_); layout->AddView(users_button_);
if (!switches::IsMaterialDesignUserMenu() && ShouldShowGoIncognito()) {
layout->StartRow(1, 0);
layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
go_incognito_button_ = new BackgroundColorHoverButton(
this,
l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON),
*rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_INCOGNITO));
layout->StartRow(1, 0);
layout->AddView(go_incognito_button_);
}
if (display_lock) { if (display_lock) {
layout->StartRow(1, 0); layout->StartRow(1, 0);
layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
......
...@@ -247,6 +247,7 @@ class ProfileChooserView : public content::WebContentsDelegate, ...@@ -247,6 +247,7 @@ class ProfileChooserView : public content::WebContentsDelegate,
// Action buttons. // Action buttons.
views::LabelButton* users_button_; views::LabelButton* users_button_;
views::LabelButton* go_incognito_button_;
views::LabelButton* lock_button_; views::LabelButton* lock_button_;
views::Link* add_account_link_; views::Link* add_account_link_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment