OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2362 chrome::HostDesktopType desktop_type) { | 2362 chrome::HostDesktopType desktop_type) { |
2363 return NativeBrowserFrameFactory::AdjustHostDesktopType(desktop_type); | 2363 return NativeBrowserFrameFactory::AdjustHostDesktopType(desktop_type); |
2364 } | 2364 } |
2365 | 2365 |
2366 void BrowserView::ShowAvatarBubble(WebContents* web_contents, | 2366 void BrowserView::ShowAvatarBubble(WebContents* web_contents, |
2367 const gfx::Rect& rect) { | 2367 const gfx::Rect& rect) { |
2368 gfx::Point origin(rect.origin()); | 2368 gfx::Point origin(rect.origin()); |
2369 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin); | 2369 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin); |
2370 gfx::Rect bounds(origin, rect.size()); | 2370 gfx::Rect bounds(origin, rect.size()); |
2371 | 2371 |
2372 AvatarMenuBubbleView::ShowBubble(this, views::BubbleBorder::TOP_RIGHT, | 2372 AvatarMenuBubbleView::ShowBubble( |
| 2373 this, views::BubbleBorder::TOP_RIGHT, views::BubbleBorder::PAINT_NORMAL, |
2373 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, browser_.get()); | 2374 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, browser_.get()); |
2374 } | 2375 } |
2375 | 2376 |
2376 void BrowserView::ShowAvatarBubbleFromAvatarButton(AvatarBubbleMode mode) { | 2377 void BrowserView::ShowAvatarBubbleFromAvatarButton(AvatarBubbleMode mode) { |
2377 if (switches::IsNewAvatarMenu()) { | 2378 if (switches::IsNewAvatarMenu()) { |
2378 NewAvatarButton* button = frame_->GetNewAvatarMenuButton(); | 2379 NewAvatarButton* button = frame_->GetNewAvatarMenuButton(); |
2379 if (button) { | 2380 if (button) { |
2380 gfx::Point origin; | 2381 gfx::Point origin; |
2381 views::View::ConvertPointToScreen(button, &origin); | 2382 views::View::ConvertPointToScreen(button, &origin); |
2382 gfx::Rect bounds(origin, size()); | 2383 gfx::Rect bounds(origin, size()); |
2383 | 2384 |
2384 ProfileChooserView::BubbleViewMode view_mode = | 2385 ProfileChooserView::BubbleViewMode view_mode = |
2385 (mode == BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT) ? | 2386 (mode == BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT) ? |
2386 ProfileChooserView::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : | 2387 ProfileChooserView::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
2387 ProfileChooserView::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; | 2388 ProfileChooserView::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; |
2388 ProfileChooserView::ShowBubble( | 2389 ProfileChooserView::ShowBubble( |
2389 view_mode, button, views::BubbleBorder::TOP_RIGHT, | 2390 view_mode, button, views::BubbleBorder::TOP_RIGHT, |
2390 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, browser()); | 2391 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, browser()); |
2391 } | 2392 } |
2392 } else { | 2393 } else { |
2393 AvatarMenuButton* button = frame_->GetAvatarMenuButton(); | 2394 views::BubbleBorder::Arrow arrow = views::BubbleBorder::TOP_RIGHT; |
2394 if (button) | 2395 views::View* anchor_view = frame_->GetAvatarMenuButton(); |
2395 button->ShowAvatarBubble(); | 2396 if (!anchor_view) |
| 2397 anchor_view = toolbar_->app_menu(); |
| 2398 else if (!frame_->GetAvatarMenuButton()->button_on_right()) |
| 2399 arrow = views::BubbleBorder::TOP_LEFT; |
| 2400 gfx::Point origin; |
| 2401 views::View::ConvertPointToScreen(anchor_view, &origin); |
| 2402 gfx::Rect bounds(origin, anchor_view->size()); |
| 2403 views::BubbleBorder::ArrowPaintType arrow_paint_type = |
| 2404 ShouldHideUIForFullscreen() ? views::BubbleBorder::PAINT_TRANSPARENT : |
| 2405 views::BubbleBorder::PAINT_NORMAL; |
| 2406 AvatarMenuBubbleView::ShowBubble(anchor_view, arrow, arrow_paint_type, |
| 2407 views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bounds, browser()); |
| 2408 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); |
2396 } | 2409 } |
2397 } | 2410 } |
2398 | 2411 |
2399 void BrowserView::ShowPasswordGenerationBubble( | 2412 void BrowserView::ShowPasswordGenerationBubble( |
2400 const gfx::Rect& rect, | 2413 const gfx::Rect& rect, |
2401 const autofill::PasswordForm& form, | 2414 const autofill::PasswordForm& form, |
2402 autofill::PasswordGenerator* password_generator) { | 2415 autofill::PasswordGenerator* password_generator) { |
2403 // Create a rect in the content bounds that the bubble will point to. | 2416 // Create a rect in the content bounds that the bubble will point to. |
2404 gfx::Point origin(rect.origin()); | 2417 gfx::Point origin(rect.origin()); |
2405 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin); | 2418 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2520 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { | 2533 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { |
2521 gfx::Point icon_bottom( | 2534 gfx::Point icon_bottom( |
2522 toolbar_->location_bar()->GetLocationBarAnchorPoint()); | 2535 toolbar_->location_bar()->GetLocationBarAnchorPoint()); |
2523 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); | 2536 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); |
2524 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); | 2537 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); |
2525 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2538 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
2526 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2539 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
2527 } | 2540 } |
2528 return top_arrow_height; | 2541 return top_arrow_height; |
2529 } | 2542 } |
OLD | NEW |