Commit 9b525b71 authored by noms's avatar noms Committed by Commit bot

The Apps ntp page should not display an avatar menu when clicking on the username.

The menu displayed is a Chrome native menu, and it's being displayed inside the
content area, which is pretty wrong. Also, it's the wrong, old profiles UI.

BUG=323977

Review URL: https://codereview.chromium.org/776423002

Cr-Commit-Position: refs/heads/master@{#308349}
parent e8f73201
...@@ -264,7 +264,6 @@ html[dir='rtl'] .login-status-icon { ...@@ -264,7 +264,6 @@ html[dir='rtl'] .login-status-icon {
background-position-x: left; background-position-x: left;
} }
.profile-name:hover,
.link-span { .link-span {
text-decoration: underline; text-decoration: underline;
} }
......
...@@ -358,12 +358,6 @@ class BrowserWindow : public ui::BaseWindow { ...@@ -358,12 +358,6 @@ class BrowserWindow : public ui::BaseWindow {
static chrome::HostDesktopType AdjustHostDesktopType( static chrome::HostDesktopType AdjustHostDesktopType(
chrome::HostDesktopType desktop_type); chrome::HostDesktopType desktop_type);
// Shows the avatar bubble inside |web_contents|. The bubble is positioned
// relative to |rect|. |rect| should be in the |web_contents| coordinate
// system.
virtual void ShowAvatarBubble(content::WebContents* web_contents,
const gfx::Rect& rect) = 0;
// Shows the avatar bubble on the window frame off of the avatar button with // Shows the avatar bubble on the window frame off of the avatar button with
// the given mode. The Service Type specified by GAIA is provided as well. // the given mode. The Service Type specified by GAIA is provided as well.
enum AvatarBubbleMode { enum AvatarBubbleMode {
......
...@@ -147,8 +147,6 @@ class BrowserWindowCocoa : ...@@ -147,8 +147,6 @@ class BrowserWindowCocoa :
FindBar* CreateFindBar() override; FindBar* CreateFindBar() override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost() web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
override; override;
void ShowAvatarBubble(content::WebContents* web_contents,
const gfx::Rect& rect) override;
void ShowAvatarBubbleFromAvatarButton( void ShowAvatarBubbleFromAvatarButton(
AvatarBubbleMode mode, AvatarBubbleMode mode,
const signin::ManageAccountsParams& manage_accounts_params) override; const signin::ManageAccountsParams& manage_accounts_params) override;
......
...@@ -89,20 +89,6 @@ const int kBookmarkAppBubbleViewHeight = 46; ...@@ -89,20 +89,6 @@ const int kBookmarkAppBubbleViewHeight = 46;
const int kIconPreviewTargetSize = 64; const int kIconPreviewTargetSize = 64;
NSPoint GetPointForBubble(content::WebContents* web_contents,
int x_offset,
int y_offset) {
NSView* view = web_contents->GetNativeView();
NSRect bounds = [view bounds];
NSPoint point;
point.x = NSMinX(bounds) + x_offset;
// The view's origin is at the bottom but |rect|'s origin is at the top.
point.y = NSMaxY(bounds) - y_offset;
point = [view convertPoint:point toView:nil];
point = [[view window] convertBaseToScreen:point];
return point;
}
} // namespace } // namespace
BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser, BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser,
...@@ -778,18 +764,6 @@ NSWindow* BrowserWindowCocoa::window() const { ...@@ -778,18 +764,6 @@ NSWindow* BrowserWindowCocoa::window() const {
return [controller_ window]; return [controller_ window];
} }
void BrowserWindowCocoa::ShowAvatarBubble(WebContents* web_contents,
const gfx::Rect& rect) {
NSPoint point = GetPointForBubble(web_contents, rect.right(), rect.bottom());
// |menu| will automatically release itself on close.
AvatarMenuBubbleController* menu =
[[AvatarMenuBubbleController alloc] initWithBrowser:browser_
anchoredAt:point];
[[menu bubble] setAlignment:info_bubble::kAlignEdgeToAnchorEdge];
[menu showWindow:nil];
}
void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton( void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton(
AvatarBubbleMode mode, AvatarBubbleMode mode,
const signin::ManageAccountsParams& manage_accounts_params) { const signin::ManageAccountsParams& manage_accounts_params) {
......
...@@ -2401,17 +2401,6 @@ void BrowserView::UpdateAcceleratorMetrics(const ui::Accelerator& accelerator, ...@@ -2401,17 +2401,6 @@ void BrowserView::UpdateAcceleratorMetrics(const ui::Accelerator& accelerator,
#endif #endif
} }
void BrowserView::ShowAvatarBubble(WebContents* web_contents,
const gfx::Rect& rect) {
gfx::Point origin(rect.origin());
views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin);
gfx::Rect bounds(origin, rect.size());
AvatarMenuBubbleView::ShowBubble(
this, views::BubbleBorder::TOP_RIGHT, views::BubbleBorder::PAINT_NORMAL,
views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, browser_.get());
}
void BrowserView::ShowAvatarBubbleFromAvatarButton( void BrowserView::ShowAvatarBubbleFromAvatarButton(
AvatarBubbleMode mode, AvatarBubbleMode mode,
const signin::ManageAccountsParams& manage_accounts_params) { const signin::ManageAccountsParams& manage_accounts_params) {
......
...@@ -359,8 +359,6 @@ class BrowserView : public BrowserWindow, ...@@ -359,8 +359,6 @@ class BrowserView : public BrowserWindow,
FindBar* CreateFindBar() override; FindBar* CreateFindBar() override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost() web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
override; override;
void ShowAvatarBubble(content::WebContents* web_contents,
const gfx::Rect& rect) override;
void ShowAvatarBubbleFromAvatarButton( void ShowAvatarBubbleFromAvatarButton(
AvatarBubbleMode mode, AvatarBubbleMode mode,
const signin::ManageAccountsParams& manage_accounts_params) override; const signin::ManageAccountsParams& manage_accounts_params) override;
......
...@@ -121,45 +121,26 @@ void NTPLoginHandler::HandleInitializeSyncLogin(const base::ListValue* args) { ...@@ -121,45 +121,26 @@ void NTPLoginHandler::HandleInitializeSyncLogin(const base::ListValue* args) {
void NTPLoginHandler::HandleShowSyncLoginUI(const base::ListValue* args) { void NTPLoginHandler::HandleShowSyncLoginUI(const base::ListValue* args) {
Profile* profile = Profile::FromWebUI(web_ui()); Profile* profile = Profile::FromWebUI(web_ui());
if (!signin::ShouldShowPromo(profile))
return;
std::string username = std::string username =
SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername(); SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername();
if (!username.empty())
return;
content::WebContents* web_contents = web_ui()->GetWebContents(); content::WebContents* web_contents = web_ui()->GetWebContents();
Browser* browser = chrome::FindBrowserWithWebContents(web_contents); Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
if (!browser) if (!browser)
return; return;
if (username.empty()) { // The user isn't signed in, show the sign in promo.
// The user isn't signed in, show the sign in promo. signin::Source source =
if (signin::ShouldShowPromo(profile)) { web_contents->GetURL().spec() == chrome::kChromeUIAppsURL ?
signin::Source source = signin::SOURCE_APPS_PAGE_LINK :
(web_contents->GetURL().spec() == chrome::kChromeUIAppsURL) ? signin::SOURCE_NTP_LINK;
signin::SOURCE_APPS_PAGE_LINK : chrome::ShowBrowserSignin(browser, source);
signin::SOURCE_NTP_LINK; RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED);
chrome::ShowBrowserSignin(browser, source);
RecordInHistogram(NTP_SIGN_IN_PROMO_CLICKED);
}
} else if (args->GetSize() == 4) {
// The user is signed in, show the profiles menu.
double x = 0;
double y = 0;
double width = 0;
double height = 0;
bool success = args->GetDouble(0, &x);
DCHECK(success);
success = args->GetDouble(1, &y);
DCHECK(success);
success = args->GetDouble(2, &width);
DCHECK(success);
success = args->GetDouble(3, &height);
DCHECK(success);
double zoom = content::ZoomLevelToZoomFactor(
ui_zoom::ZoomController::FromWebContents(web_contents)->GetZoomLevel());
gfx::Rect rect(x * zoom, y * zoom, width * zoom, height * zoom);
browser->window()->ShowAvatarBubble(web_ui()->GetWebContents(), rect);
ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::NTP_AVATAR_BUBBLE);
}
} }
void NTPLoginHandler::RecordInHistogram(int type) { void NTPLoginHandler::RecordInHistogram(int type) {
......
...@@ -140,8 +140,6 @@ class TestBrowserWindow : public BrowserWindow { ...@@ -140,8 +140,6 @@ class TestBrowserWindow : public BrowserWindow {
FindBar* CreateFindBar() override; FindBar* CreateFindBar() override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost() web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
override; override;
void ShowAvatarBubble(content::WebContents* web_contents,
const gfx::Rect& rect) override {}
void ShowAvatarBubbleFromAvatarButton( void ShowAvatarBubbleFromAvatarButton(
AvatarBubbleMode mode, AvatarBubbleMode mode,
const signin::ManageAccountsParams& manage_accounts_params) override {} const signin::ManageAccountsParams& manage_accounts_params) override {}
......
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