| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/profiles/avatar_menu_bubble_view.h" | 5 #include "chrome/browser/ui/views/profiles/avatar_menu_bubble_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 // AvatarMenuBubbleView ------------------------------------------------------- | 478 // AvatarMenuBubbleView ------------------------------------------------------- |
| 479 | 479 |
| 480 // static | 480 // static |
| 481 AvatarMenuBubbleView* AvatarMenuBubbleView::avatar_bubble_ = NULL; | 481 AvatarMenuBubbleView* AvatarMenuBubbleView::avatar_bubble_ = NULL; |
| 482 bool AvatarMenuBubbleView::close_on_deactivate_for_testing_ = true; | 482 bool AvatarMenuBubbleView::close_on_deactivate_for_testing_ = true; |
| 483 | 483 |
| 484 // static | 484 // static |
| 485 void AvatarMenuBubbleView::ShowBubble( | 485 void AvatarMenuBubbleView::ShowBubble( |
| 486 views::View* anchor_view, | 486 views::View* anchor_view, |
| 487 views::BubbleBorder::Arrow arrow, | 487 views::BubbleBorder::Arrow arrow, |
| 488 views::BubbleBorder::ArrowPaintType arrow_paint_type, |
| 488 views::BubbleBorder::BubbleAlignment border_alignment, | 489 views::BubbleBorder::BubbleAlignment border_alignment, |
| 489 const gfx::Rect& anchor_rect, | 490 const gfx::Rect& anchor_rect, |
| 490 Browser* browser) { | 491 Browser* browser) { |
| 491 if (IsShowing()) | 492 if (IsShowing()) |
| 492 return; | 493 return; |
| 493 | 494 |
| 494 DCHECK(chrome::IsCommandEnabled(browser, IDC_SHOW_AVATAR_MENU)); | 495 DCHECK(chrome::IsCommandEnabled(browser, IDC_SHOW_AVATAR_MENU)); |
| 495 avatar_bubble_ = new AvatarMenuBubbleView( | 496 avatar_bubble_ = new AvatarMenuBubbleView( |
| 496 anchor_view, arrow, anchor_rect, browser); | 497 anchor_view, arrow, anchor_rect, browser); |
| 497 views::BubbleDelegateView::CreateBubble(avatar_bubble_); | 498 views::BubbleDelegateView::CreateBubble(avatar_bubble_); |
| 498 avatar_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_); | 499 avatar_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_); |
| 499 avatar_bubble_->SetBackgroundColors(); | 500 avatar_bubble_->SetBackgroundColors(); |
| 500 avatar_bubble_->SetAlignment(border_alignment); | 501 avatar_bubble_->SetAlignment(border_alignment); |
| 502 avatar_bubble_->SetArrowPaintType(arrow_paint_type); |
| 501 avatar_bubble_->GetWidget()->Show(); | 503 avatar_bubble_->GetWidget()->Show(); |
| 502 } | 504 } |
| 503 | 505 |
| 504 // static | 506 // static |
| 505 bool AvatarMenuBubbleView::IsShowing() { | 507 bool AvatarMenuBubbleView::IsShowing() { |
| 506 return avatar_bubble_ != NULL; | 508 return avatar_bubble_ != NULL; |
| 507 } | 509 } |
| 508 | 510 |
| 509 // static | 511 // static |
| 510 void AvatarMenuBubbleView::Hide() { | 512 void AvatarMenuBubbleView::Hide() { |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 Layout(); | 803 Layout(); |
| 802 if (GetBubbleFrameView()) | 804 if (GetBubbleFrameView()) |
| 803 SizeToContents(); | 805 SizeToContents(); |
| 804 } | 806 } |
| 805 | 807 |
| 806 void AvatarMenuBubbleView::SetBackgroundColors() { | 808 void AvatarMenuBubbleView::SetBackgroundColors() { |
| 807 for (size_t i = 0; i < item_views_.size(); ++i) { | 809 for (size_t i = 0; i < item_views_.size(); ++i) { |
| 808 item_views_[i]->OnHighlightStateChanged(); | 810 item_views_[i]->OnHighlightStateChanged(); |
| 809 } | 811 } |
| 810 } | 812 } |
| OLD | NEW |