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

Side by Side Diff: chrome/browser/chromeos/status/accessibility_menu_button.cc

Issue 8438064: Separate StatusAreaView from StatusAreaViewChromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_util.h" 9 #include "chrome/browser/chromeos/accessibility_util.h"
10 #include "chrome/browser/chromeos/status/status_area_bubble.h" 10 #include "chrome/browser/chromeos/status/status_area_bubble.h"
11 #include "chrome/browser/chromeos/view_ids.h"
11 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
12 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
13 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
14 #include "content/public/browser/notification_details.h" 15 #include "content/public/browser/notification_details.h"
15 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
16 #include "grit/theme_resources.h" 17 #include "grit/theme_resources.h"
17 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/image/image.h" 20 #include "ui/gfx/image/image.h"
20 #include "views/controls/image_view.h" 21 #include "views/controls/image_view.h"
21 #include "views/controls/menu/menu_item_view.h" 22 #include "views/controls/menu/menu_item_view.h"
22 #include "views/controls/menu/menu_runner.h" 23 #include "views/controls/menu/menu_runner.h"
23 #include "views/widget/widget.h" 24 #include "views/widget/widget.h"
24 25
25 namespace { 26 namespace {
26 27
27 enum MenuItemID { 28 enum MenuItemID {
28 MENU_ITEM_DISABLE_SPOKEN_FEEDBACK, 29 MENU_ITEM_DISABLE_SPOKEN_FEEDBACK,
29 }; 30 };
30 31
31 } // namespace 32 } // namespace
32 33
33 namespace chromeos { 34 namespace chromeos {
34 35
35 //////////////////////////////////////////////////////////////////////////////// 36 ////////////////////////////////////////////////////////////////////////////////
36 // AccessibilityMenuButton 37 // AccessibilityMenuButton
37 38
38 AccessibilityMenuButton::AccessibilityMenuButton(StatusAreaHost* host) 39 AccessibilityMenuButton::AccessibilityMenuButton(
39 : StatusAreaButton(host, this) { 40 StatusAreaButton::Delegate* delegate,
41 StatusAreaViewChromeos::ScreenMode screen_mode)
42 : StatusAreaButton(delegate, this),
43 screen_mode_(screen_mode) {
44 set_id(VIEW_ID_STATUS_BUTTON_ACCESSIBILITY);
40 accessibility_enabled_.Init(prefs::kAccessibilityEnabled, 45 accessibility_enabled_.Init(prefs::kAccessibilityEnabled,
41 g_browser_process->local_state(), this); 46 g_browser_process->local_state(), this);
42 SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed( 47 SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed(
43 IDR_STATUSBAR_ACCESSIBILITY)); 48 IDR_STATUSBAR_ACCESSIBILITY));
44 Update(); 49 Update();
45 } 50 }
46 51
47 AccessibilityMenuButton::~AccessibilityMenuButton() { 52 AccessibilityMenuButton::~AccessibilityMenuButton() {
48 } 53 }
49 54
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 int type, 88 int type,
84 const content::NotificationSource& source, 89 const content::NotificationSource& source,
85 const content::NotificationDetails& details) { 90 const content::NotificationDetails& details) {
86 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 91 if (type == chrome::NOTIFICATION_PREF_CHANGED) {
87 Update(); 92 Update();
88 const std::string path = 93 const std::string path =
89 *static_cast<content::Details<std::string> >(details).ptr(); 94 *static_cast<content::Details<std::string> >(details).ptr();
90 // Show a bubble when accessibility is turned on at the login screen. 95 // Show a bubble when accessibility is turned on at the login screen.
91 if (path == prefs::kAccessibilityEnabled) { 96 if (path == prefs::kAccessibilityEnabled) {
92 if (accessibility_enabled_.GetValue() && 97 if (accessibility_enabled_.GetValue() &&
93 host_->GetScreenMode() == StatusAreaHost::kWebUILoginMode) { 98 screen_mode_ == StatusAreaViewChromeos::LOGIN_MODE_WEBUI) {
94 views::ImageView* icon_view = new views::ImageView; 99 views::ImageView* icon_view = new views::ImageView;
95 const gfx::Image& image = ResourceBundle::GetSharedInstance(). 100 const gfx::Image& image = ResourceBundle::GetSharedInstance().
96 GetImageNamed(IDR_ACCESSIBILITY_ICON); 101 GetImageNamed(IDR_ACCESSIBILITY_ICON);
97 icon_view->SetImage(image.ToSkBitmap()); 102 icon_view->SetImage(image.ToSkBitmap());
98 bubble_controller_.reset( 103 bubble_controller_.reset(
99 StatusAreaBubbleController::ShowBubbleUnderViewForAWhile( 104 StatusAreaBubbleController::ShowBubbleUnderViewForAWhile(
100 this, new StatusAreaBubbleContentView( 105 this, new StatusAreaBubbleContentView(
101 icon_view, 106 icon_view,
102 l10n_util::GetStringUTF16( 107 l10n_util::GetStringUTF16(
103 IDS_STATUSBAR_ACCESSIBILITY_TURNED_ON_BUBBLE)))); 108 IDS_STATUSBAR_ACCESSIBILITY_TURNED_ON_BUBBLE))));
(...skipping 19 matching lines...) Expand all
123 views::MenuItemView* menu = new views::MenuItemView(this); 128 views::MenuItemView* menu = new views::MenuItemView(this);
124 if (accessibility_enabled_.GetValue()) 129 if (accessibility_enabled_.GetValue())
125 menu->AppendMenuItemWithLabel( 130 menu->AppendMenuItemWithLabel(
126 MENU_ITEM_DISABLE_SPOKEN_FEEDBACK, 131 MENU_ITEM_DISABLE_SPOKEN_FEEDBACK,
127 l10n_util::GetStringUTF16(IDS_STATUSBAR_DISABLE_SPOKEN_FEEDBACK)); 132 l10n_util::GetStringUTF16(IDS_STATUSBAR_DISABLE_SPOKEN_FEEDBACK));
128 // |menu_runner_| takes the ownership of |menu| 133 // |menu_runner_| takes the ownership of |menu|
129 menu_runner_.reset(new views::MenuRunner(menu)); 134 menu_runner_.reset(new views::MenuRunner(menu));
130 } 135 }
131 136
132 } // namespace chromeos 137 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698