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

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

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 2 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 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <shellapi.h> 8 #include <shellapi.h>
9 #endif 9 #endif
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 const int InfoBar::kDefaultArrowTargetHeight = 9; 48 const int InfoBar::kDefaultArrowTargetHeight = 9;
49 const int InfoBar::kMaximumArrowTargetHeight = 24; 49 const int InfoBar::kMaximumArrowTargetHeight = 24;
50 const int InfoBar::kDefaultArrowTargetHalfWidth = kDefaultArrowTargetHeight; 50 const int InfoBar::kDefaultArrowTargetHalfWidth = kDefaultArrowTargetHeight;
51 const int InfoBar::kMaximumArrowTargetHalfWidth = 14; 51 const int InfoBar::kMaximumArrowTargetHalfWidth = 14;
52 const int InfoBar::kDefaultBarTargetHeight = 36; 52 const int InfoBar::kDefaultBarTargetHeight = 36;
53 53
54 const int InfoBarView::kButtonButtonSpacing = 10; 54 const int InfoBarView::kButtonButtonSpacing = 10;
55 const int InfoBarView::kEndOfLabelSpacing = 16; 55 const int InfoBarView::kEndOfLabelSpacing = 16;
56 const int InfoBarView::kHorizontalPadding = 6; 56 const int InfoBarView::kHorizontalPadding = 6;
57 57
58 InfoBarView::InfoBarView(InfoBarService* owner, InfoBarDelegate* delegate) 58 InfoBarView::InfoBarView(scoped_ptr<InfoBarDelegate> delegate)
59 : InfoBar(owner, delegate), 59 : InfoBar(delegate.Pass()),
60 views::ExternalFocusTracker(this, NULL), 60 views::ExternalFocusTracker(this, NULL),
61 icon_(NULL), 61 icon_(NULL),
62 close_button_(NULL) { 62 close_button_(NULL) {
63 set_owned_by_client(); // InfoBar deletes itself at the appropriate time. 63 set_owned_by_client(); // InfoBar deletes itself at the appropriate time.
64 set_background(new InfoBarBackground(InfoBar::delegate()->GetInfoBarType())); 64 set_background(new InfoBarBackground(InfoBar::delegate()->GetInfoBarType()));
65 } 65 }
66 66
67 InfoBarView::~InfoBarView() { 67 InfoBarView::~InfoBarView() {
68 // We should have closed any open menus in PlatformSpecificHide(), then 68 // We should have closed any open menus in PlatformSpecificHide(), then
69 // subclasses' RunMenu() functions should have prevented opening any new ones 69 // subclasses' RunMenu() functions should have prevented opening any new ones
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 #endif 345 #endif
346 } 346 }
347 347
348 void InfoBarView::PlatformSpecificOnHeightsRecalculated() { 348 void InfoBarView::PlatformSpecificOnHeightsRecalculated() {
349 // Ensure that notifying our container of our size change will result in a 349 // Ensure that notifying our container of our size change will result in a
350 // re-layout. 350 // re-layout.
351 InvalidateLayout(); 351 InvalidateLayout();
352 } 352 }
353 353
354 void InfoBarView::GetAccessibleState(ui::AccessibleViewState* state) { 354 void InfoBarView::GetAccessibleState(ui::AccessibleViewState* state) {
355 if (delegate()) { 355 state->name = l10n_util::GetStringUTF16(
356 state->name = l10n_util::GetStringUTF16( 356 (delegate()->GetInfoBarType() == InfoBarDelegate::WARNING_TYPE) ?
357 (delegate()->GetInfoBarType() == InfoBarDelegate::WARNING_TYPE) ? 357 IDS_ACCNAME_INFOBAR_WARNING : IDS_ACCNAME_INFOBAR_PAGE_ACTION);
358 IDS_ACCNAME_INFOBAR_WARNING : IDS_ACCNAME_INFOBAR_PAGE_ACTION);
359 }
360 state->role = ui::AccessibilityTypes::ROLE_ALERT; 358 state->role = ui::AccessibilityTypes::ROLE_ALERT;
361 } 359 }
362 360
363 gfx::Size InfoBarView::GetPreferredSize() { 361 gfx::Size InfoBarView::GetPreferredSize() {
364 return gfx::Size(0, total_height()); 362 return gfx::Size(0, total_height());
365 } 363 }
366 364
367 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { 365 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) {
368 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); 366 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now);
369 367
370 // This will trigger some screen readers to read the entire contents of this 368 // This will trigger some screen readers to read the entire contents of this
371 // infobar. 369 // infobar.
372 if (focused_before && focused_now && !Contains(focused_before) && 370 if (focused_before && focused_now && !Contains(focused_before) &&
373 Contains(focused_now)) { 371 Contains(focused_now)) {
374 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_ALERT, true); 372 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_ALERT, true);
375 } 373 }
376 } 374 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698