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

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 {
20 public: 19 public:
21 explicit SaveCCInfoConfirmInfoBar(ConfirmInfoBarDelegate* delegate); 20 explicit SaveCCInfoConfirmInfoBar(ConfirmInfoBarDelegate* delegate);
22 virtual ~SaveCCInfoConfirmInfoBar(); 21 virtual ~SaveCCInfoConfirmInfoBar();
23 22
24 // Overridden from views::View: 23 // Overridden from views::View:
25 virtual void Layout(); 24 virtual void Layout();
26 25
27 // Overridden from views::LinkController: 26 // Overridden from views::LinkController:
28 virtual void LinkActivated(views::Link* source, int event_flags); 27 virtual void LinkActivated(views::Link* source, int event_flags);
29 28
(...skipping 20 matching lines...) Expand all
50 InfoBarTextButton* save_button_; 49 InfoBarTextButton* save_button_;
51 InfoBarTextButton* dont_save_button_; 50 InfoBarTextButton* dont_save_button_;
52 views::Link* link_; 51 views::Link* link_;
53 bool initialized_; 52 bool initialized_;
54 53
55 DISALLOW_COPY_AND_ASSIGN(SaveCCInfoConfirmInfoBar); 54 DISALLOW_COPY_AND_ASSIGN(SaveCCInfoConfirmInfoBar);
56 }; 55 };
57 56
58 SaveCCInfoConfirmInfoBar::SaveCCInfoConfirmInfoBar( 57 SaveCCInfoConfirmInfoBar::SaveCCInfoConfirmInfoBar(
59 ConfirmInfoBarDelegate* delegate) 58 ConfirmInfoBarDelegate* delegate)
60 : AlertInfoBar(delegate), 59 : ConfirmInfoBar(delegate),
61 initialized_(false) { 60 initialized_(false) {
62 save_button_ = InfoBarTextButton::Create(this, 61 save_button_ = InfoBarTextButton::Create(this,
63 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); 62 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK));
64 dont_save_button_ = InfoBarTextButton::Create(this, 63 dont_save_button_ = InfoBarTextButton::Create(this,
65 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); 64 delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL));
66 65
67 // Set up the link. 66 // Set up the link.
68 link_ = new views::Link; 67 link_ = new views::Link;
69 link_->SetText(delegate->GetLinkText()); 68 link_->SetText(delegate->GetLinkText());
70 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 69 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
71 link_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); 70 link_->SetFont(rb.GetFont(ResourceBundle::MediumFont));
72 link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 71 link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
73 link_->SetController(this); 72 link_->SetController(this);
74 link_->MakeReadableOverBackgroundColor(background()->get_color()); 73 link_->MakeReadableOverBackgroundColor(background()->get_color());
75 } 74 }
76 75
77 SaveCCInfoConfirmInfoBar::~SaveCCInfoConfirmInfoBar() { 76 SaveCCInfoConfirmInfoBar::~SaveCCInfoConfirmInfoBar() {
78 if (!initialized_) { 77 if (!initialized_) {
79 delete save_button_; 78 delete save_button_;
80 delete dont_save_button_; 79 delete dont_save_button_;
81 delete link_; 80 delete link_;
82 } 81 }
83 } 82 }
84 83
85 void SaveCCInfoConfirmInfoBar::Layout() { 84 void SaveCCInfoConfirmInfoBar::Layout() {
86 // Layout the close button. 85 // Layout the close button.
87 InfoBar::Layout(); 86 InfoBar::Layout();
88 87
89 int available_width = AlertInfoBar::GetAvailableWidth(); 88 int available_width = ConfirmInfoBar::GetAvailableWidth();
90 89
91 // Now append the link to the label's right edge. 90 // Now append the link to the label's right edge.
92 link_->SetVisible(!link_->GetText().empty()); 91 link_->SetVisible(!link_->GetText().empty());
93 gfx::Size link_ps = link_->GetPreferredSize(); 92 gfx::Size link_ps = link_->GetPreferredSize();
94 int link_x = available_width - kButtonButtonSpacing - link_ps.width(); 93 int link_x = available_width - kButtonButtonSpacing - link_ps.width();
95 link_->SetBounds(link_x, OffsetY(this, link_ps), link_ps.width(), 94 link_->SetBounds(link_x, OffsetY(this, link_ps), link_ps.width(),
96 link_ps.height()); 95 link_ps.height());
97 available_width = link_x; 96 available_width = link_x;
98 97
99 // Layout the cancel and OK buttons. 98 // Layout the cancel and OK buttons.
100 gfx::Size save_ps = save_button_->GetPreferredSize(); 99 gfx::Size save_ps = save_button_->GetPreferredSize();
101 gfx::Size dont_save_ps = dont_save_button_->GetPreferredSize(); 100 gfx::Size dont_save_ps = dont_save_button_->GetPreferredSize();
102 101
103 // Layout the icon and label. 102 // Layout the icon and label.
104 AlertInfoBar::Layout(); 103 ConfirmInfoBar::Layout();
105 104
106 int save_x = label()->bounds().right() + kEndOfLabelSpacing; 105 int save_x = label()->bounds().right() + kEndOfLabelSpacing;
107 save_x = std::max(0, std::min(save_x, available_width - (save_ps.width() + 106 save_x = std::max(0, std::min(save_x, available_width - (save_ps.width() +
108 dont_save_ps.width() + kButtonButtonSpacing))); 107 dont_save_ps.width() + kButtonButtonSpacing)));
109 108
110 save_button_->SetVisible(true); 109 save_button_->SetVisible(true);
111 dont_save_button_->SetVisible(true); 110 dont_save_button_->SetVisible(true);
112 111
113 save_button_->SetBounds(save_x, OffsetY(this, save_ps), save_ps.width(), 112 save_button_->SetBounds(save_x, OffsetY(this, save_ps), save_ps.width(),
114 save_ps.height()); 113 save_ps.height());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 161 }
163 162
164 ConfirmInfoBarDelegate* SaveCCInfoConfirmInfoBar::GetDelegate() { 163 ConfirmInfoBarDelegate* SaveCCInfoConfirmInfoBar::GetDelegate() {
165 return delegate()->AsConfirmInfoBarDelegate(); 164 return delegate()->AsConfirmInfoBarDelegate();
166 } 165 }
167 166
168 InfoBar* CreateAutofillCcInfoBar(ConfirmInfoBarDelegate* delegate) { 167 InfoBar* CreateAutofillCcInfoBar(ConfirmInfoBarDelegate* delegate) {
169 DCHECK(delegate); 168 DCHECK(delegate);
170 return new SaveCCInfoConfirmInfoBar(delegate); 169 return new SaveCCInfoConfirmInfoBar(delegate);
171 } 170 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_cc_infobar_delegate.cc ('k') | chrome/browser/automation/testing_automation_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698