| 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 "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/autofill/save_card_bubble_controller.h" | 8 #include "chrome/browser/ui/autofill/save_card_bubble_controller.h" |
| 9 #include "grit/components_strings.h" | 9 #include "grit/components_strings.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 controller_(controller), | 42 controller_(controller), |
| 43 save_button_(nullptr), | 43 save_button_(nullptr), |
| 44 cancel_button_(nullptr), | 44 cancel_button_(nullptr), |
| 45 learn_more_link_(nullptr) { | 45 learn_more_link_(nullptr) { |
| 46 DCHECK(controller); | 46 DCHECK(controller); |
| 47 views::BubbleDelegateView::CreateBubble(this); | 47 views::BubbleDelegateView::CreateBubble(this); |
| 48 } | 48 } |
| 49 | 49 |
| 50 SaveCardBubbleViews::~SaveCardBubbleViews() {} | 50 SaveCardBubbleViews::~SaveCardBubbleViews() {} |
| 51 | 51 |
| 52 void SaveCardBubbleViews::Show() { | 52 void SaveCardBubbleViews::Show(DisplayReason reason) { |
| 53 GetWidget()->Show(); | 53 ShowForReason(reason); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void SaveCardBubbleViews::Close() { | 56 void SaveCardBubbleViews::Hide() { |
| 57 GetWidget()->Close(); | |
| 58 } | |
| 59 | |
| 60 void SaveCardBubbleViews::ControllerGone() { | |
| 61 controller_ = nullptr; | 57 controller_ = nullptr; |
| 62 GetWidget()->Close(); | 58 Close(); |
| 63 } | 59 } |
| 64 | 60 |
| 65 views::View* SaveCardBubbleViews::GetInitiallyFocusedView() { | 61 views::View* SaveCardBubbleViews::GetInitiallyFocusedView() { |
| 66 return save_button_; | 62 return save_button_; |
| 67 } | 63 } |
| 68 | 64 |
| 69 base::string16 SaveCardBubbleViews::GetWindowTitle() const { | 65 base::string16 SaveCardBubbleViews::GetWindowTitle() const { |
| 70 return l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_CARD_BUBBLE_TITLE_LOCAL); | 66 return l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_CARD_BUBBLE_TITLE_LOCAL); |
| 71 } | 67 } |
| 72 | 68 |
| 73 bool SaveCardBubbleViews::ShouldShowWindowTitle() const { | 69 bool SaveCardBubbleViews::ShouldShowWindowTitle() const { |
| 74 return true; | 70 return true; |
| 75 } | 71 } |
| 76 | 72 |
| 77 void SaveCardBubbleViews::WindowClosing() { | 73 void SaveCardBubbleViews::WindowClosing() { |
| 78 if (controller_) | 74 if (controller_) |
| 79 controller_->OnBubbleClosed(); | 75 controller_->OnBubbleClosed(); |
| 80 } | 76 } |
| 81 | 77 |
| 82 void SaveCardBubbleViews::ButtonPressed(views::Button* sender, | 78 void SaveCardBubbleViews::ButtonPressed(views::Button* sender, |
| 83 const ui::Event& event) { | 79 const ui::Event& event) { |
| 84 if (sender == save_button_) { | 80 if (sender == save_button_) { |
| 85 controller_->OnSaveButton(); | 81 controller_->OnSaveButton(); |
| 86 } else { | 82 } else { |
| 87 DCHECK_EQ(sender, cancel_button_); | 83 DCHECK_EQ(sender, cancel_button_); |
| 88 controller_->OnCancelButton(); | 84 controller_->OnCancelButton(); |
| 89 } | 85 } |
| 90 GetWidget()->Close(); | 86 Close(); |
| 91 } | 87 } |
| 92 | 88 |
| 93 void SaveCardBubbleViews::LinkClicked(views::Link* source, int event_flags) { | 89 void SaveCardBubbleViews::LinkClicked(views::Link* source, int event_flags) { |
| 94 DCHECK_EQ(source, learn_more_link_); | 90 DCHECK_EQ(source, learn_more_link_); |
| 95 controller_->OnLearnMoreClicked(); | 91 controller_->OnLearnMoreClicked(); |
| 96 } | 92 } |
| 97 | 93 |
| 98 void SaveCardBubbleViews::Init() { | 94 void SaveCardBubbleViews::Init() { |
| 99 enum { | 95 enum { |
| 100 COLUMN_SET_ID_MESSAGE, | 96 COLUMN_SET_ID_MESSAGE, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 layout->AddView(cancel_button_); | 145 layout->AddView(cancel_button_); |
| 150 layout->AddView(save_button_); | 146 layout->AddView(save_button_); |
| 151 } | 147 } |
| 152 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 148 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 153 | 149 |
| 154 set_margins(gfx::Insets(1, 0, 1, 0)); | 150 set_margins(gfx::Insets(1, 0, 1, 0)); |
| 155 Layout(); | 151 Layout(); |
| 156 } | 152 } |
| 157 | 153 |
| 158 } // namespace autofill | 154 } // namespace autofill |
| OLD | NEW |