OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/avatar_menu_bubble_view.h" | 5 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 layout->AddView(signout_button_); | 470 layout->AddView(signout_button_); |
471 layout->AddView(manage_button_); | 471 layout->AddView(manage_button_); |
472 SetLayoutManager(layout); | 472 SetLayoutManager(layout); |
473 } | 473 } |
474 | 474 |
475 | 475 |
476 // AvatarMenuBubbleView ------------------------------------------------------- | 476 // AvatarMenuBubbleView ------------------------------------------------------- |
477 | 477 |
478 // static | 478 // static |
479 AvatarMenuBubbleView* AvatarMenuBubbleView::avatar_bubble_ = NULL; | 479 AvatarMenuBubbleView* AvatarMenuBubbleView::avatar_bubble_ = NULL; |
480 bool AvatarMenuBubbleView::close_on_deactivate_ = true; | 480 bool AvatarMenuBubbleView::close_on_deactivate_for_testing_ = true; |
481 | 481 |
482 // static | 482 // static |
483 void AvatarMenuBubbleView::ShowBubble( | 483 void AvatarMenuBubbleView::ShowBubble( |
484 views::View* anchor_view, | 484 views::View* anchor_view, |
485 views::BubbleBorder::Arrow arrow, | 485 views::BubbleBorder::Arrow arrow, |
486 views::BubbleBorder::BubbleAlignment border_alignment, | 486 views::BubbleBorder::BubbleAlignment border_alignment, |
487 const gfx::Rect& anchor_rect, | 487 const gfx::Rect& anchor_rect, |
488 Browser* browser) { | 488 Browser* browser) { |
489 if (IsShowing()) | 489 if (IsShowing()) |
490 return; | 490 return; |
491 | 491 |
492 DCHECK(chrome::IsCommandEnabled(browser, IDC_SHOW_AVATAR_MENU)); | 492 DCHECK(chrome::IsCommandEnabled(browser, IDC_SHOW_AVATAR_MENU)); |
493 avatar_bubble_ = new AvatarMenuBubbleView( | 493 avatar_bubble_ = new AvatarMenuBubbleView( |
494 anchor_view, arrow, anchor_rect, browser); | 494 anchor_view, arrow, anchor_rect, browser); |
495 views::BubbleDelegateView::CreateBubble(avatar_bubble_); | 495 views::BubbleDelegateView::CreateBubble(avatar_bubble_); |
496 avatar_bubble_->set_close_on_deactivate(close_on_deactivate_); | 496 avatar_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_); |
497 avatar_bubble_->SetBackgroundColors(); | 497 avatar_bubble_->SetBackgroundColors(); |
498 avatar_bubble_->SetAlignment(border_alignment); | 498 avatar_bubble_->SetAlignment(border_alignment); |
499 avatar_bubble_->GetWidget()->Show(); | 499 avatar_bubble_->GetWidget()->Show(); |
500 } | 500 } |
501 | 501 |
502 // static | 502 // static |
503 bool AvatarMenuBubbleView::IsShowing() { | 503 bool AvatarMenuBubbleView::IsShowing() { |
504 return avatar_bubble_ != NULL; | 504 return avatar_bubble_ != NULL; |
505 } | 505 } |
506 | 506 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 Layout(); | 804 Layout(); |
805 if (GetBubbleFrameView()) | 805 if (GetBubbleFrameView()) |
806 SizeToContents(); | 806 SizeToContents(); |
807 } | 807 } |
808 | 808 |
809 void AvatarMenuBubbleView::SetBackgroundColors() { | 809 void AvatarMenuBubbleView::SetBackgroundColors() { |
810 for (size_t i = 0; i < item_views_.size(); ++i) { | 810 for (size_t i = 0; i < item_views_.size(); ++i) { |
811 item_views_[i]->OnHighlightStateChanged(); | 811 item_views_[i]->OnHighlightStateChanged(); |
812 } | 812 } |
813 } | 813 } |
OLD | NEW |