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 2361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2372 gfx::Rect bounds(origin, rect.size()); | 2372 gfx::Rect bounds(origin, rect.size()); |
2373 | 2373 |
2374 AvatarMenuBubbleView::ShowBubble( | 2374 AvatarMenuBubbleView::ShowBubble( |
2375 this, views::BubbleBorder::TOP_RIGHT, views::BubbleBorder::PAINT_NORMAL, | 2375 this, views::BubbleBorder::TOP_RIGHT, views::BubbleBorder::PAINT_NORMAL, |
2376 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, browser_.get()); | 2376 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, browser_.get()); |
2377 } | 2377 } |
2378 | 2378 |
2379 void BrowserView::ShowAvatarBubbleFromAvatarButton( | 2379 void BrowserView::ShowAvatarBubbleFromAvatarButton( |
2380 AvatarBubbleMode mode, | 2380 AvatarBubbleMode mode, |
2381 signin::GAIAServiceType service_type) { | 2381 signin::GAIAServiceType service_type) { |
| 2382 views::BubbleBorder::Arrow arrow = views::BubbleBorder::TOP_RIGHT; |
| 2383 views::BubbleBorder::BubbleAlignment alignment = |
| 2384 views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR; |
| 2385 views::View* anchor_view = frame_->GetAvatarMenuButton(); |
| 2386 if (!anchor_view) |
| 2387 anchor_view = toolbar_->app_menu(); |
| 2388 else if (!frame_->GetAvatarMenuButton()->button_on_right()) |
| 2389 arrow = views::BubbleBorder::TOP_LEFT; |
| 2390 |
2382 if (switches::IsNewAvatarMenu()) { | 2391 if (switches::IsNewAvatarMenu()) { |
2383 NewAvatarButton* button = frame_->GetNewAvatarMenuButton(); | 2392 NewAvatarButton* button = frame_->GetNewAvatarMenuButton(); |
2384 if (button) { | 2393 if (button) { |
2385 gfx::Point origin; | 2394 anchor_view = button; |
2386 views::View::ConvertPointToScreen(button, &origin); | 2395 arrow = views::BubbleBorder::TOP_RIGHT; |
2387 gfx::Rect bounds(origin, size()); | 2396 alignment = views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE; |
| 2397 } |
2388 | 2398 |
2389 profiles::BubbleViewMode view_mode; | 2399 profiles::BubbleViewMode view_mode; |
2390 switch (mode) { | 2400 switch (mode) { |
2391 case AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT: | 2401 case AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT: |
2392 view_mode = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; | 2402 view_mode = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; |
2393 break; | 2403 break; |
2394 case AVATAR_BUBBLE_MODE_SIGNIN: | 2404 case AVATAR_BUBBLE_MODE_SIGNIN: |
2395 view_mode = profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN; | 2405 view_mode = profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN; |
2396 break; | 2406 break; |
2397 case AVATAR_BUBBLE_MODE_REAUTH: | 2407 case AVATAR_BUBBLE_MODE_REAUTH: |
2398 view_mode = profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH; | 2408 view_mode = profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH; |
2399 break; | 2409 break; |
2400 default: | 2410 default: |
2401 view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; | 2411 view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; |
2402 break; | 2412 break; |
2403 } | |
2404 ProfileChooserView::ShowBubble( | |
2405 view_mode, service_type, button, views::BubbleBorder::TOP_RIGHT, | |
2406 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, browser()); | |
2407 } | 2413 } |
| 2414 ProfileChooserView::ShowBubble(view_mode, service_type, anchor_view, arrow, |
| 2415 alignment, browser()); |
2408 } else { | 2416 } else { |
2409 views::BubbleBorder::Arrow arrow = views::BubbleBorder::TOP_RIGHT; | |
2410 views::View* anchor_view = frame_->GetAvatarMenuButton(); | |
2411 if (!anchor_view) | |
2412 anchor_view = toolbar_->app_menu(); | |
2413 else if (!frame_->GetAvatarMenuButton()->button_on_right()) | |
2414 arrow = views::BubbleBorder::TOP_LEFT; | |
2415 gfx::Point origin; | 2417 gfx::Point origin; |
2416 views::View::ConvertPointToScreen(anchor_view, &origin); | 2418 views::View::ConvertPointToScreen(anchor_view, &origin); |
2417 gfx::Rect bounds(origin, anchor_view->size()); | 2419 gfx::Rect bounds(origin, anchor_view->size()); |
2418 views::BubbleBorder::ArrowPaintType arrow_paint_type = | 2420 views::BubbleBorder::ArrowPaintType arrow_paint_type = |
2419 ShouldHideUIForFullscreen() ? views::BubbleBorder::PAINT_TRANSPARENT : | 2421 ShouldHideUIForFullscreen() ? views::BubbleBorder::PAINT_TRANSPARENT : |
2420 views::BubbleBorder::PAINT_NORMAL; | 2422 views::BubbleBorder::PAINT_NORMAL; |
2421 AvatarMenuBubbleView::ShowBubble(anchor_view, arrow, arrow_paint_type, | 2423 AvatarMenuBubbleView::ShowBubble(anchor_view, arrow, arrow_paint_type, |
2422 views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bounds, browser()); | 2424 alignment, bounds, browser()); |
2423 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); | 2425 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ICON_AVATAR_BUBBLE); |
2424 } | 2426 } |
2425 } | 2427 } |
2426 | 2428 |
2427 void BrowserView::ShowPasswordGenerationBubble( | 2429 void BrowserView::ShowPasswordGenerationBubble( |
2428 const gfx::Rect& rect, | 2430 const gfx::Rect& rect, |
2429 const autofill::PasswordForm& form, | 2431 const autofill::PasswordForm& form, |
2430 autofill::PasswordGenerator* password_generator) { | 2432 autofill::PasswordGenerator* password_generator) { |
2431 // Create a rect in the content bounds that the bubble will point to. | 2433 // Create a rect in the content bounds that the bubble will point to. |
2432 gfx::Point origin(rect.origin()); | 2434 gfx::Point origin(rect.origin()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2545 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { | 2547 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { |
2546 gfx::Point icon_bottom( | 2548 gfx::Point icon_bottom( |
2547 toolbar_->location_bar()->GetLocationBarAnchorPoint()); | 2549 toolbar_->location_bar()->GetLocationBarAnchorPoint()); |
2548 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); | 2550 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); |
2549 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); | 2551 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); |
2550 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2552 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
2551 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2553 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
2552 } | 2554 } |
2553 return top_arrow_height; | 2555 return top_arrow_height; |
2554 } | 2556 } |
OLD | NEW |