Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: chrome/browser/autofill/autofill_cc_infobar_win.cc

Issue 6262018: Cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/ui/views/event_utils.h" 7 #include "chrome/browser/ui/views/event_utils.h"
8 #include "chrome/browser/ui/views/infobars/infobars.h" 8 #include "chrome/browser/ui/views/infobars/infobars.h"
9 #include "chrome/browser/ui/views/infobars/infobar_text_button.h" 9 #include "chrome/browser/ui/views/infobars/infobar_text_button.h"
10 #include "grit/chromium_strings.h" 10 #include "grit/chromium_strings.h"
11 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
12 #include "grit/theme_resources.h" 12 #include "grit/theme_resources.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
15 #include "views/controls/button/text_button.h" 15 #include "views/controls/button/text_button.h"
16 #include "views/controls/link.h" 16 #include "views/controls/link.h"
17 17
18 class SaveCCInfoConfirmInfoBar : public AlertInfoBar, 18 class SaveCCInfoConfirmInfoBar : public ConfirmInfoBar,
19 public views::LinkController { 19 public views::LinkController {
20 public: 20 public:
21 explicit SaveCCInfoConfirmInfoBar(ConfirmInfoBarDelegate* delegate); 21 explicit SaveCCInfoConfirmInfoBar(ConfirmInfoBarDelegate* delegate);
22 virtual ~SaveCCInfoConfirmInfoBar(); 22 virtual ~SaveCCInfoConfirmInfoBar();
23 23
24 // Overridden from views::View: 24 // Overridden from views::View:
25 virtual void Layout(); 25 virtual void Layout();
26 26
27 // Overridden from views::LinkController: 27 // Overridden from views::LinkController:
28 virtual void LinkActivated(views::Link* source, int event_flags); 28 virtual void LinkActivated(views::Link* source, int event_flags);
(...skipping 21 matching lines...) Expand all
50 InfoBarTextButton* save_button_; 50 InfoBarTextButton* save_button_;
51 InfoBarTextButton* dont_save_button_; 51 InfoBarTextButton* dont_save_button_;
52 views::Link* link_; 52 views::Link* link_;
53 bool initialized_; 53 bool initialized_;
54 54
55 DISALLOW_COPY_AND_ASSIGN(SaveCCInfoConfirmInfoBar); 55 DISALLOW_COPY_AND_ASSIGN(SaveCCInfoConfirmInfoBar);
56 }; 56 };
57 57
58 SaveCCInfoConfirmInfoBar::SaveCCInfoConfirmInfoBar( 58 SaveCCInfoConfirmInfoBar::SaveCCInfoConfirmInfoBar(
59 ConfirmInfoBarDelegate* delegate) 59 ConfirmInfoBarDelegate* delegate)
60 : AlertInfoBar(delegate), 60 : ConfirmInfoBar(delegate),
61 initialized_(false) { 61 initialized_(false) {
62 save_button_ = InfoBarTextButton::Create(this, 62 save_button_ = InfoBarTextButton::Create(this,
63 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); 63 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK));
64 dont_save_button_ = InfoBarTextButton::Create(this, 64 dont_save_button_ = InfoBarTextButton::Create(this,
65 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); 65 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL));
66 66
67 // Set up the link. 67 // Set up the link.
68 link_ = new views::Link; 68 link_ = new views::Link;
69 link_->SetText(delegate->GetLinkText()); 69 link_->SetText(delegate->GetLinkText());
70 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 70 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
71 link_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); 71 link_->SetFont(rb.GetFont(ResourceBundle::MediumFont));
72 link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 72 link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
73 link_->SetController(this); 73 link_->SetController(this);
74 link_->MakeReadableOverBackgroundColor(background()->get_color()); 74 link_->MakeReadableOverBackgroundColor(background()->get_color());
75 } 75 }
76 76
77 SaveCCInfoConfirmInfoBar::~SaveCCInfoConfirmInfoBar() { 77 SaveCCInfoConfirmInfoBar::~SaveCCInfoConfirmInfoBar() {
78 if (!initialized_) { 78 if (!initialized_) {
79 delete save_button_; 79 delete save_button_;
80 delete dont_save_button_; 80 delete dont_save_button_;
81 delete link_; 81 delete link_;
82 } 82 }
83 } 83 }
84 84
85 void SaveCCInfoConfirmInfoBar::Layout() { 85 void SaveCCInfoConfirmInfoBar::Layout() {
86 // Layout the close button. 86 // Layout the close button.
87 InfoBar::Layout(); 87 InfoBar::Layout();
88 88
89 int available_width = AlertInfoBar::GetAvailableWidth(); 89 int available_width = ConfirmInfoBar::GetAvailableWidth();
90 90
91 // Now append the link to the label's right edge. 91 // Now append the link to the label's right edge.
92 link_->SetVisible(!link_->GetText().empty()); 92 link_->SetVisible(!link_->GetText().empty());
93 gfx::Size link_ps = link_->GetPreferredSize(); 93 gfx::Size link_ps = link_->GetPreferredSize();
94 int link_x = available_width - kButtonButtonSpacing - link_ps.width(); 94 int link_x = available_width - kButtonButtonSpacing - link_ps.width();
95 link_->SetBounds(link_x, OffsetY(this, link_ps), link_ps.width(), 95 link_->SetBounds(link_x, OffsetY(this, link_ps), link_ps.width(),
96 link_ps.height()); 96 link_ps.height());
97 available_width = link_x; 97 available_width = link_x;
98 98
99 // Layout the cancel and OK buttons. 99 // Layout the cancel and OK buttons.
100 gfx::Size save_ps = save_button_->GetPreferredSize(); 100 gfx::Size save_ps = save_button_->GetPreferredSize();
101 gfx::Size dont_save_ps = dont_save_button_->GetPreferredSize(); 101 gfx::Size dont_save_ps = dont_save_button_->GetPreferredSize();
102 102
103 // Layout the icon and label. 103 // Layout the icon and label.
104 AlertInfoBar::Layout(); 104 ConfirmInfoBar::Layout();
105 105
106 int save_x = label()->bounds().right() + kEndOfLabelSpacing; 106 int save_x = label()->bounds().right() + kEndOfLabelSpacing;
107 save_x = std::max(0, std::min(save_x, available_width - (save_ps.width() + 107 save_x = std::max(0, std::min(save_x, available_width - (save_ps.width() +
108 dont_save_ps.width() + kButtonButtonSpacing))); 108 dont_save_ps.width() + kButtonButtonSpacing)));
109 109
110 save_button_->SetVisible(true); 110 save_button_->SetVisible(true);
111 dont_save_button_->SetVisible(true); 111 dont_save_button_->SetVisible(true);
112 112
113 save_button_->SetBounds(save_x, OffsetY(this, save_ps), save_ps.width(), 113 save_button_->SetBounds(save_x, OffsetY(this, save_ps), save_ps.width(),
114 save_ps.height()); 114 save_ps.height());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 163
164 ConfirmInfoBarDelegate* SaveCCInfoConfirmInfoBar::GetDelegate() { 164 ConfirmInfoBarDelegate* SaveCCInfoConfirmInfoBar::GetDelegate() {
165 return delegate()->AsConfirmInfoBarDelegate(); 165 return delegate()->AsConfirmInfoBarDelegate();
166 } 166 }
167 167
168 InfoBar* CreateAutofillCcInfoBar(ConfirmInfoBarDelegate* delegate) { 168 InfoBar* CreateAutofillCcInfoBar(ConfirmInfoBarDelegate* delegate) {
169 DCHECK(delegate); 169 DCHECK(delegate);
170 return new SaveCCInfoConfirmInfoBar(delegate); 170 return new SaveCCInfoConfirmInfoBar(delegate);
171 } 171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698