OLD | NEW |
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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 const infobars::InfoBarContainer* infobar_container = container(); | 300 const infobars::InfoBarContainer* infobar_container = container(); |
301 return infobar_container ? infobar_container->delegate() : NULL; | 301 return infobar_container ? infobar_container->delegate() : NULL; |
302 } | 302 } |
303 | 303 |
304 void InfoBarView::RunMenuAt(ui::MenuModel* menu_model, | 304 void InfoBarView::RunMenuAt(ui::MenuModel* menu_model, |
305 views::MenuButton* button, | 305 views::MenuButton* button, |
306 views::MenuAnchorPosition anchor) { | 306 views::MenuAnchorPosition anchor) { |
307 DCHECK(owner()); // We'd better not open any menus while we're closing. | 307 DCHECK(owner()); // We'd better not open any menus while we're closing. |
308 gfx::Point screen_point; | 308 gfx::Point screen_point; |
309 views::View::ConvertPointToScreen(button, &screen_point); | 309 views::View::ConvertPointToScreen(button, &screen_point); |
310 menu_runner_.reset(new views::MenuRunner(menu_model)); | 310 menu_runner_.reset( |
| 311 new views::MenuRunner(menu_model, views::MenuRunner::HAS_MNEMONICS)); |
311 // Ignore the result since we don't need to handle a deleted menu specially. | 312 // Ignore the result since we don't need to handle a deleted menu specially. |
312 ignore_result(menu_runner_->RunMenuAt( | 313 ignore_result(menu_runner_->RunMenuAt(GetWidget(), |
313 GetWidget(), button, gfx::Rect(screen_point, button->size()), anchor, | 314 button, |
314 ui::MENU_SOURCE_NONE, views::MenuRunner::HAS_MNEMONICS)); | 315 gfx::Rect(screen_point, button->size()), |
| 316 anchor, |
| 317 ui::MENU_SOURCE_NONE)); |
315 } | 318 } |
316 | 319 |
317 // static | 320 // static |
318 void InfoBarView::AssignWidthsSorted(Labels* labels, int available_width) { | 321 void InfoBarView::AssignWidthsSorted(Labels* labels, int available_width) { |
319 if (labels->empty()) | 322 if (labels->empty()) |
320 return; | 323 return; |
321 gfx::Size back_label_size(labels->back()->GetPreferredSize()); | 324 gfx::Size back_label_size(labels->back()->GetPreferredSize()); |
322 back_label_size.set_width( | 325 back_label_size.set_width( |
323 std::min(back_label_size.width(), | 326 std::min(back_label_size.width(), |
324 available_width / static_cast<int>(labels->size()))); | 327 available_width / static_cast<int>(labels->size()))); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { | 386 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { |
384 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); | 387 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); |
385 | 388 |
386 // This will trigger some screen readers to read the entire contents of this | 389 // This will trigger some screen readers to read the entire contents of this |
387 // infobar. | 390 // infobar. |
388 if (focused_before && focused_now && !Contains(focused_before) && | 391 if (focused_before && focused_now && !Contains(focused_before) && |
389 Contains(focused_now)) { | 392 Contains(focused_now)) { |
390 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 393 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
391 } | 394 } |
392 } | 395 } |
OLD | NEW |