OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/autofill/autofill_cc_infobar.h" | 5 #include "chrome/browser/autofill/autofill_cc_infobar.h" |
6 | 6 |
7 #include "chrome/browser/tab_contents/infobar_delegate.h" | 7 #include "chrome/browser/tab_contents/infobar_delegate.h" |
8 #include "chrome/browser/ui/views/event_utils.h" | 8 #include "chrome/browser/ui/views/event_utils.h" |
9 #include "chrome/browser/ui/views/infobars/confirm_infobar.h" | 9 #include "chrome/browser/ui/views/infobars/confirm_infobar.h" |
10 #include "chrome/browser/ui/views/infobars/infobar_text_button.h" | |
11 #include "grit/chromium_strings.h" | 10 #include "grit/chromium_strings.h" |
12 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
13 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
14 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
15 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
16 #include "views/controls/button/text_button.h" | 15 #include "views/controls/button/text_button.h" |
17 #include "views/controls/link.h" | 16 #include "views/controls/link.h" |
18 | 17 |
19 class SaveCCInfoConfirmInfoBar : public AlertInfoBar, | 18 class SaveCCInfoConfirmInfoBar : public AlertInfoBar, |
20 public views::LinkController { | 19 public views::LinkController { |
(...skipping 20 matching lines...) Expand all Loading... |
41 virtual int GetAvailableWidth() const; | 40 virtual int GetAvailableWidth() const; |
42 | 41 |
43 private: | 42 private: |
44 void Init(); | 43 void Init(); |
45 | 44 |
46 ConfirmInfoBarDelegate* GetDelegate(); | 45 ConfirmInfoBarDelegate* GetDelegate(); |
47 | 46 |
48 // The buttons are owned by InfoBar view from the moment they are added to its | 47 // The buttons are owned by InfoBar view from the moment they are added to its |
49 // hierarchy (Init() called), but we still need pointers to them to process | 48 // hierarchy (Init() called), but we still need pointers to them to process |
50 // messages from them. | 49 // messages from them. |
51 InfoBarTextButton* save_button_; | 50 views::TextButton* save_button_; |
52 InfoBarTextButton* dont_save_button_; | 51 views::TextButton* dont_save_button_; |
53 views::Link* link_; | 52 views::Link* link_; |
54 bool initialized_; | 53 bool initialized_; |
55 | 54 |
56 DISALLOW_COPY_AND_ASSIGN(SaveCCInfoConfirmInfoBar); | 55 DISALLOW_COPY_AND_ASSIGN(SaveCCInfoConfirmInfoBar); |
57 }; | 56 }; |
58 | 57 |
59 SaveCCInfoConfirmInfoBar::SaveCCInfoConfirmInfoBar( | 58 SaveCCInfoConfirmInfoBar::SaveCCInfoConfirmInfoBar( |
60 ConfirmInfoBarDelegate* delegate) | 59 ConfirmInfoBarDelegate* delegate) |
61 : AlertInfoBar(delegate), | 60 : AlertInfoBar(delegate), |
62 initialized_(false) { | 61 initialized_(false) { |
63 save_button_ = InfoBarTextButton::Create(this, | 62 save_button_ = CreateTextButton(this, |
64 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); | 63 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK), false); |
65 dont_save_button_ = InfoBarTextButton::Create(this, | 64 dont_save_button_ = CreateTextButton(this, |
66 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); | 65 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL), false); |
67 | 66 |
68 // Set up the link. | 67 // Set up the link. |
69 link_ = new views::Link; | 68 link_ = CreateLink(delegate->GetLinkText(), this, background()->get_color()); |
70 link_->SetText(delegate->GetLinkText()); | |
71 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
72 link_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); | |
73 link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | |
74 link_->SetController(this); | |
75 link_->MakeReadableOverBackgroundColor(background()->get_color()); | |
76 } | 69 } |
77 | 70 |
78 SaveCCInfoConfirmInfoBar::~SaveCCInfoConfirmInfoBar() { | 71 SaveCCInfoConfirmInfoBar::~SaveCCInfoConfirmInfoBar() { |
79 if (!initialized_) { | 72 if (!initialized_) { |
80 delete save_button_; | 73 delete save_button_; |
81 delete dont_save_button_; | 74 delete dont_save_button_; |
82 delete link_; | 75 delete link_; |
83 } | 76 } |
84 } | 77 } |
85 | 78 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 156 } |
164 | 157 |
165 ConfirmInfoBarDelegate* SaveCCInfoConfirmInfoBar::GetDelegate() { | 158 ConfirmInfoBarDelegate* SaveCCInfoConfirmInfoBar::GetDelegate() { |
166 return delegate()->AsConfirmInfoBarDelegate(); | 159 return delegate()->AsConfirmInfoBarDelegate(); |
167 } | 160 } |
168 | 161 |
169 InfoBar* CreateAutofillCcInfoBar(ConfirmInfoBarDelegate* delegate) { | 162 InfoBar* CreateAutofillCcInfoBar(ConfirmInfoBarDelegate* delegate) { |
170 DCHECK(delegate); | 163 DCHECK(delegate); |
171 return new SaveCCInfoConfirmInfoBar(delegate); | 164 return new SaveCCInfoConfirmInfoBar(delegate); |
172 } | 165 } |
OLD | NEW |