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

Side by Side Diff: chrome/browser/ui/views/infobars/infobar_view.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/infobar_view.h" 5 #include "chrome/browser/ui/views/infobars/infobar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 void InfoBarView::ButtonPressed(views::Button* sender, 297 void InfoBarView::ButtonPressed(views::Button* sender,
298 const ui::Event& event) { 298 const ui::Event& event) {
299 if (!owner()) 299 if (!owner())
300 return; // We're closing; don't call anything, it might access the owner. 300 return; // We're closing; don't call anything, it might access the owner.
301 if (sender == close_button_) { 301 if (sender == close_button_) {
302 delegate()->InfoBarDismissed(); 302 delegate()->InfoBarDismissed();
303 RemoveSelf(); 303 RemoveSelf();
304 } 304 }
305 } 305 }
306 306
307 int InfoBarView::ContentMinimumWidth() { 307 int InfoBarView::ContentMinimumWidth() const {
308 return 0; 308 return 0;
309 } 309 }
310 310
311 int InfoBarView::StartX() const { 311 int InfoBarView::StartX() const {
312 // Ensure we don't return a value greater than EndX(), so children can safely 312 // Ensure we don't return a value greater than EndX(), so children can safely
313 // set something's width to "EndX() - StartX()" without risking that being 313 // set something's width to "EndX() - StartX()" without risking that being
314 // negative. 314 // negative.
315 return std::min(EndX(), (icon_ != NULL) ? 315 return std::min(EndX(), (icon_ != NULL) ?
316 (icon_->bounds().right() + kIconToLabelSpacing) : kEdgeItemPadding); 316 (icon_->bounds().right() + kIconToLabelSpacing) : kEdgeItemPadding);
317 } 317 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 396
397 void InfoBarView::GetAccessibleState(ui::AXViewState* state) { 397 void InfoBarView::GetAccessibleState(ui::AXViewState* state) {
398 state->name = l10n_util::GetStringUTF16( 398 state->name = l10n_util::GetStringUTF16(
399 (delegate()->GetInfoBarType() == 399 (delegate()->GetInfoBarType() ==
400 infobars::InfoBarDelegate::WARNING_TYPE) ? 400 infobars::InfoBarDelegate::WARNING_TYPE) ?
401 IDS_ACCNAME_INFOBAR_WARNING : IDS_ACCNAME_INFOBAR_PAGE_ACTION); 401 IDS_ACCNAME_INFOBAR_WARNING : IDS_ACCNAME_INFOBAR_PAGE_ACTION);
402 state->role = ui::AX_ROLE_ALERT; 402 state->role = ui::AX_ROLE_ALERT;
403 state->keyboard_shortcut = base::ASCIIToUTF16("Alt+Shift+A"); 403 state->keyboard_shortcut = base::ASCIIToUTF16("Alt+Shift+A");
404 } 404 }
405 405
406 gfx::Size InfoBarView::GetPreferredSize() { 406 gfx::Size InfoBarView::GetPreferredSize() const {
407 return gfx::Size( 407 return gfx::Size(
408 kEdgeItemPadding + (icon_ ? (icon_->width() + kIconToLabelSpacing) : 0) + 408 kEdgeItemPadding + (icon_ ? (icon_->width() + kIconToLabelSpacing) : 0) +
409 ContentMinimumWidth() + kBeforeCloseButtonSpacing + 409 ContentMinimumWidth() + kBeforeCloseButtonSpacing +
410 close_button_->width() + kEdgeItemPadding, 410 close_button_->width() + kEdgeItemPadding,
411 total_height()); 411 total_height());
412 } 412 }
413 413
414 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { 414 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) {
415 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); 415 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now);
416 416
417 // This will trigger some screen readers to read the entire contents of this 417 // This will trigger some screen readers to read the entire contents of this
418 // infobar. 418 // infobar.
419 if (focused_before && focused_now && !Contains(focused_before) && 419 if (focused_before && focused_now && !Contains(focused_before) &&
420 Contains(focused_now)) { 420 Contains(focused_now)) {
421 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); 421 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
422 } 422 }
423 } 423 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/infobars/infobar_view.h ('k') | chrome/browser/ui/views/infobars/translate_message_infobar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698