OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/save_card_bubble_views.h" | 5 #include "chrome/browser/ui/views/autofill/save_card_bubble_views.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 SaveCardBubbleViews::SaveCardBubbleViews(views::View* anchor_view, | 58 SaveCardBubbleViews::SaveCardBubbleViews(views::View* anchor_view, |
59 content::WebContents* web_contents, | 59 content::WebContents* web_contents, |
60 SaveCardBubbleController* controller) | 60 SaveCardBubbleController* controller) |
61 : LocationBarBubbleDelegateView(anchor_view, web_contents), | 61 : LocationBarBubbleDelegateView(anchor_view, web_contents), |
62 controller_(controller), | 62 controller_(controller), |
63 save_button_(nullptr), | 63 save_button_(nullptr), |
64 cancel_button_(nullptr), | 64 cancel_button_(nullptr), |
65 learn_more_link_(nullptr) { | 65 learn_more_link_(nullptr) { |
66 DCHECK(controller); | 66 DCHECK(controller); |
67 views::BubbleDelegateView::CreateBubble(this); | 67 views::BubbleDelegateView::CreateBubble(this); |
| 68 save_card_bubble_view_ = this; |
68 } | 69 } |
69 | 70 |
| 71 // static |
| 72 SaveCardBubbleViews* SaveCardBubbleViews::save_card_bubble_view_ = nullptr; |
| 73 |
70 SaveCardBubbleViews::~SaveCardBubbleViews() {} | 74 SaveCardBubbleViews::~SaveCardBubbleViews() {} |
71 | 75 |
72 void SaveCardBubbleViews::Show(DisplayReason reason) { | 76 void SaveCardBubbleViews::Show(DisplayReason reason) { |
73 ShowForReason(reason); | 77 ShowForReason(reason); |
74 } | 78 } |
75 | 79 |
| 80 // static |
| 81 void SaveCardBubbleViews::CloseBubble() { |
| 82 if (save_card_bubble_view_ && save_card_bubble_view_->controller_) |
| 83 save_card_bubble_view_->controller_->HideBubble(); |
| 84 } |
| 85 |
76 void SaveCardBubbleViews::Hide() { | 86 void SaveCardBubbleViews::Hide() { |
77 controller_ = nullptr; | 87 controller_ = nullptr; |
| 88 save_card_bubble_view_ = nullptr; |
78 Close(); | 89 Close(); |
79 } | 90 } |
80 | 91 |
81 views::View* SaveCardBubbleViews::GetInitiallyFocusedView() { | 92 views::View* SaveCardBubbleViews::GetInitiallyFocusedView() { |
82 return save_button_; | 93 return save_button_; |
83 } | 94 } |
84 | 95 |
85 base::string16 SaveCardBubbleViews::GetWindowTitle() const { | 96 base::string16 SaveCardBubbleViews::GetWindowTitle() const { |
86 return controller_->GetWindowTitle(); | 97 return controller_->GetWindowTitle(); |
87 } | 98 } |
88 | 99 |
89 bool SaveCardBubbleViews::ShouldShowWindowTitle() const { | 100 bool SaveCardBubbleViews::ShouldShowWindowTitle() const { |
90 return true; | 101 return true; |
91 } | 102 } |
92 | 103 |
93 void SaveCardBubbleViews::WindowClosing() { | 104 void SaveCardBubbleViews::WindowClosing() { |
94 if (controller_) | 105 if (controller_) |
95 controller_->OnBubbleClosed(); | 106 controller_->OnBubbleClosed(); |
| 107 save_card_bubble_view_ = nullptr; |
96 } | 108 } |
97 | 109 |
98 void SaveCardBubbleViews::ButtonPressed(views::Button* sender, | 110 void SaveCardBubbleViews::ButtonPressed(views::Button* sender, |
99 const ui::Event& event) { | 111 const ui::Event& event) { |
100 if (sender == save_button_) { | 112 if (sender == save_button_) { |
101 controller_->OnSaveButton(); | 113 controller_->OnSaveButton(); |
102 } else { | 114 } else { |
103 DCHECK_EQ(sender, cancel_button_); | 115 DCHECK_EQ(sender, cancel_button_); |
104 controller_->OnCancelButton(); | 116 controller_->OnCancelButton(); |
105 } | 117 } |
| 118 save_card_bubble_view_ = nullptr; |
106 Close(); | 119 Close(); |
107 } | 120 } |
108 | 121 |
109 void SaveCardBubbleViews::LinkClicked(views::Link* source, int event_flags) { | 122 void SaveCardBubbleViews::LinkClicked(views::Link* source, int event_flags) { |
110 DCHECK_EQ(source, learn_more_link_); | 123 DCHECK_EQ(source, learn_more_link_); |
111 controller_->OnLearnMoreClicked(); | 124 controller_->OnLearnMoreClicked(); |
112 } | 125 } |
113 | 126 |
114 void SaveCardBubbleViews::StyledLabelLinkClicked(views::StyledLabel* label, | 127 void SaveCardBubbleViews::StyledLabelLinkClicked(views::StyledLabel* label, |
115 const gfx::Range& range, | 128 const gfx::Range& range, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 void SaveCardBubbleViews::Init() { | 253 void SaveCardBubbleViews::Init() { |
241 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 254 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
242 AddChildView(CreateMainContentView().release()); | 255 AddChildView(CreateMainContentView().release()); |
243 if (!controller_->GetLegalMessageLines().empty()) | 256 if (!controller_->GetLegalMessageLines().empty()) |
244 AddChildView(CreateFootnoteView().release()); | 257 AddChildView(CreateFootnoteView().release()); |
245 | 258 |
246 set_margins(gfx::Insets(1, 0, 1, 0)); | 259 set_margins(gfx::Insets(1, 0, 1, 0)); |
247 } | 260 } |
248 | 261 |
249 } // namespace autofill | 262 } // namespace autofill |
OLD | NEW |