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/chromeos/status/accessibility_menu_button.h" | 5 #include "chrome/browser/chromeos/status/accessibility_menu_button.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 9 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
10 #include "chrome/browser/chromeos/status/status_area_bubble.h" | 10 #include "chrome/browser/chromeos/status/status_area_bubble.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 g_browser_process->local_state(), this); | 45 g_browser_process->local_state(), this); |
46 SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed( | 46 SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed( |
47 IDR_STATUSBAR_ACCESSIBILITY)); | 47 IDR_STATUSBAR_ACCESSIBILITY)); |
48 Update(); | 48 Update(); |
49 } | 49 } |
50 | 50 |
51 AccessibilityMenuButton::~AccessibilityMenuButton() { | 51 AccessibilityMenuButton::~AccessibilityMenuButton() { |
52 } | 52 } |
53 | 53 |
54 //////////////////////////////////////////////////////////////////////////////// | 54 //////////////////////////////////////////////////////////////////////////////// |
55 // views::MenuButtonDelegate implementation: | 55 // views::MenuButtonListener implementation: |
56 | 56 |
57 void AccessibilityMenuButton::RunMenu(views::View* source, | 57 void AccessibilityMenuButton::OnMenuButtonClicked(views::View* source, |
58 const gfx::Point& pt) { | 58 const gfx::Point& point) { |
59 PrepareMenu(); | 59 PrepareMenu(); |
60 | 60 |
61 gfx::Point screen_location; | 61 gfx::Point screen_location; |
62 views::View::ConvertPointToScreen(source, &screen_location); | 62 views::View::ConvertPointToScreen(source, &screen_location); |
63 gfx::Rect bounds(screen_location, source->size()); | 63 gfx::Rect bounds(screen_location, source->size()); |
64 CHECK(menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(), | 64 CHECK(menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(), |
65 this, bounds, views::MenuItemView::TOPRIGHT, | 65 this, bounds, views::MenuItemView::TOPRIGHT, |
66 0) == | 66 0) == views::MenuRunner::NORMAL_EXIT); |
67 views::MenuRunner::NORMAL_EXIT); | |
68 } | 67 } |
69 | 68 |
70 //////////////////////////////////////////////////////////////////////////////// | 69 //////////////////////////////////////////////////////////////////////////////// |
71 // views::MenuDelegate implementation | 70 // views::MenuDelegate implementation |
72 | 71 |
73 void AccessibilityMenuButton::ExecuteCommand(int id) { | 72 void AccessibilityMenuButton::ExecuteCommand(int id) { |
74 switch (id) { | 73 switch (id) { |
75 case MENU_ITEM_DISABLE_SPOKEN_FEEDBACK: | 74 case MENU_ITEM_DISABLE_SPOKEN_FEEDBACK: |
76 accessibility::EnableSpokenFeedback(false, NULL); | 75 accessibility::EnableSpokenFeedback(false, NULL); |
77 break; | 76 break; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 views::MenuItemView* menu = new views::MenuItemView(this); | 127 views::MenuItemView* menu = new views::MenuItemView(this); |
129 if (accessibility_enabled_.GetValue()) | 128 if (accessibility_enabled_.GetValue()) |
130 menu->AppendMenuItemWithLabel( | 129 menu->AppendMenuItemWithLabel( |
131 MENU_ITEM_DISABLE_SPOKEN_FEEDBACK, | 130 MENU_ITEM_DISABLE_SPOKEN_FEEDBACK, |
132 l10n_util::GetStringUTF16(IDS_STATUSBAR_DISABLE_SPOKEN_FEEDBACK)); | 131 l10n_util::GetStringUTF16(IDS_STATUSBAR_DISABLE_SPOKEN_FEEDBACK)); |
133 // |menu_runner_| takes the ownership of |menu| | 132 // |menu_runner_| takes the ownership of |menu| |
134 menu_runner_.reset(new views::MenuRunner(menu)); | 133 menu_runner_.reset(new views::MenuRunner(menu)); |
135 } | 134 } |
136 | 135 |
137 } // namespace chromeos | 136 } // namespace chromeos |
OLD | NEW |