| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/autofill/autofill_credit_card_bubble_views.h" | 5 #include "chrome/browser/ui/views/autofill/autofill_credit_card_bubble_views.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/autofill/autofill_credit_card_bubble_controller.h" | 7 #include "chrome/browser/ui/autofill/autofill_credit_card_bubble_controller.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
| 10 #include "chrome/browser/ui/views/frame/browser_view.h" | 10 #include "chrome/browser/ui/views/frame/browser_view.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
| 22 | 22 |
| 23 namespace autofill { | 23 namespace autofill { |
| 24 | 24 |
| 25 AutofillCreditCardBubbleViews::~AutofillCreditCardBubbleViews() {} | 25 AutofillCreditCardBubbleViews::~AutofillCreditCardBubbleViews() {} |
| 26 | 26 |
| 27 void AutofillCreditCardBubbleViews::Show() { | 27 void AutofillCreditCardBubbleViews::Show() { |
| 28 // TODO(dbeam): investigate why this steals focus from the web contents. | 28 // TODO(dbeam): investigate why this steals focus from the web contents. |
| 29 views::BubbleDelegateView::CreateBubble(this); | 29 views::BubbleDelegateView::CreateBubble(this); |
| 30 | 30 |
| 31 GetBubbleFrameView()->SetTitle(controller_->BubbleTitle()); | |
| 32 | |
| 33 GetWidget()->Show(); | 31 GetWidget()->Show(); |
| 34 SizeToContents(); | 32 SizeToContents(); |
| 35 } | 33 } |
| 36 | 34 |
| 37 void AutofillCreditCardBubbleViews::Hide() { | 35 void AutofillCreditCardBubbleViews::Hide() { |
| 38 GetWidget()->Close(); | 36 GetWidget()->Close(); |
| 39 } | 37 } |
| 40 | 38 |
| 41 bool AutofillCreditCardBubbleViews::IsHiding() const { | 39 bool AutofillCreditCardBubbleViews::IsHiding() const { |
| 42 return GetWidget() && GetWidget()->IsClosed(); | 40 return GetWidget() && GetWidget()->IsClosed(); |
| 43 } | 41 } |
| 44 | 42 |
| 43 string16 AutofillCreditCardBubbleViews::GetWindowTitle() const { |
| 44 return controller_->BubbleTitle(); |
| 45 } |
| 46 |
| 45 void AutofillCreditCardBubbleViews::Init() { | 47 void AutofillCreditCardBubbleViews::Init() { |
| 46 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, | 48 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, |
| 47 views::kRelatedControlVerticalSpacing)); | 49 views::kRelatedControlVerticalSpacing)); |
| 48 | 50 |
| 49 views::StyledLabel::RangeStyleInfo bold; | 51 views::StyledLabel::RangeStyleInfo bold; |
| 50 bold.font_style = gfx::Font::BOLD; | 52 bold.font_style = gfx::Font::BOLD; |
| 51 const std::vector<ui::Range>& ranges = controller_->BubbleTextRanges(); | 53 const std::vector<ui::Range>& ranges = controller_->BubbleTextRanges(); |
| 52 | 54 |
| 53 views::StyledLabel* contents = | 55 views::StyledLabel* contents = |
| 54 new views::StyledLabel(controller_->BubbleText(), NULL); | 56 new views::StyledLabel(controller_->BubbleText(), NULL); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 views::BubbleBorder::TOP_RIGHT), | 94 views::BubbleBorder::TOP_RIGHT), |
| 93 controller_(controller), | 95 controller_(controller), |
| 94 weak_ptr_factory_(this) { | 96 weak_ptr_factory_(this) { |
| 95 // Match bookmarks bubble view's anchor view insets and margins. | 97 // Match bookmarks bubble view's anchor view insets and margins. |
| 96 set_anchor_view_insets(gfx::Insets(7, 0, 7, 0)); | 98 set_anchor_view_insets(gfx::Insets(7, 0, 7, 0)); |
| 97 set_margins(gfx::Insets(0, 19, 18, 18)); | 99 set_margins(gfx::Insets(0, 19, 18, 18)); |
| 98 set_move_with_anchor(true); | 100 set_move_with_anchor(true); |
| 99 } | 101 } |
| 100 | 102 |
| 101 } // namespace autofill | 103 } // namespace autofill |
| OLD | NEW |