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

Side by Side Diff: chrome/browser/ui/views/infobars/confirm_infobar.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/infobars/confirm_infobar.h" 5 #include "chrome/browser/ui/views/infobars/confirm_infobar.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 8 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
9 #include "chrome/browser/ui/views/elevation_icon_setter.h" 9 #include "chrome/browser/ui/views/elevation_icon_setter.h"
10 #include "ui/base/window_open_disposition.h" 10 #include "ui/base/window_open_disposition.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 if (delegate->Accept()) 102 if (delegate->Accept())
103 RemoveSelf(); 103 RemoveSelf();
104 } else if ((cancel_button_ != NULL) && (sender == cancel_button_)) { 104 } else if ((cancel_button_ != NULL) && (sender == cancel_button_)) {
105 if (delegate->Cancel()) 105 if (delegate->Cancel())
106 RemoveSelf(); 106 RemoveSelf();
107 } else { 107 } else {
108 InfoBarView::ButtonPressed(sender, event); 108 InfoBarView::ButtonPressed(sender, event);
109 } 109 }
110 } 110 }
111 111
112 int ConfirmInfoBar::ContentMinimumWidth() { 112 int ConfirmInfoBar::ContentMinimumWidth() const {
113 return label_->GetMinimumSize().width() + link_->GetMinimumSize().width() + 113 return label_->GetMinimumSize().width() + link_->GetMinimumSize().width() +
114 NonLabelWidth(); 114 NonLabelWidth();
115 } 115 }
116 116
117 void ConfirmInfoBar::LinkClicked(views::Link* source, int event_flags) { 117 void ConfirmInfoBar::LinkClicked(views::Link* source, int event_flags) {
118 if (!owner()) 118 if (!owner())
119 return; // We're closing; don't call anything, it might access the owner. 119 return; // We're closing; don't call anything, it might access the owner.
120 DCHECK_EQ(link_, source); 120 DCHECK_EQ(link_, source);
121 if (GetDelegate()->LinkClicked(ui::DispositionFromEventFlags(event_flags))) 121 if (GetDelegate()->LinkClicked(ui::DispositionFromEventFlags(event_flags)))
122 RemoveSelf(); 122 RemoveSelf();
123 } 123 }
124 124
125 ConfirmInfoBarDelegate* ConfirmInfoBar::GetDelegate() { 125 ConfirmInfoBarDelegate* ConfirmInfoBar::GetDelegate() {
126 return delegate()->AsConfirmInfoBarDelegate(); 126 return delegate()->AsConfirmInfoBarDelegate();
127 } 127 }
128 128
129 int ConfirmInfoBar::NonLabelWidth() const { 129 int ConfirmInfoBar::NonLabelWidth() const {
130 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ? 130 int width = (label_->text().empty() || (!ok_button_ && !cancel_button_)) ?
131 0 : kEndOfLabelSpacing; 131 0 : kEndOfLabelSpacing;
132 if (ok_button_) 132 if (ok_button_)
133 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0); 133 width += ok_button_->width() + (cancel_button_ ? kButtonButtonSpacing : 0);
134 width += (cancel_button_ ? cancel_button_->width() : 0); 134 width += (cancel_button_ ? cancel_button_->width() : 0);
135 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing); 135 return width + ((link_->text().empty() || !width) ? 0 : kEndOfLabelSpacing);
136 } 136 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/infobars/confirm_infobar.h ('k') | chrome/browser/ui/views/infobars/extension_infobar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698