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

Side by Side Diff: chrome/browser/chromeos/login/language_switch_menu.cc

Issue 9693022: views: Rename MenuButtonDelegate::RunMenu to something more obvious. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: menu_button_listener.h Created 8 years, 9 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/chromeos/login/language_switch_menu.h" 5 #include "chrome/browser/chromeos/login/language_switch_menu.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // use may not be supported by the new locale (3rd parameter). 183 // use may not be supported by the new locale (3rd parameter).
184 input_method::InputMethodManager* manager = 184 input_method::InputMethodManager* manager =
185 input_method::InputMethodManager::GetInstance(); 185 input_method::InputMethodManager::GetInstance();
186 manager->EnableInputMethods( 186 manager->EnableInputMethods(
187 locale, input_method::kKeyboardLayoutsOnly, 187 locale, input_method::kKeyboardLayoutsOnly,
188 manager->GetInputMethodUtil()->GetHardwareInputMethodId()); 188 manager->GetInputMethodUtil()->GetHardwareInputMethodId());
189 } 189 }
190 } 190 }
191 191
192 //////////////////////////////////////////////////////////////////////////////// 192 ////////////////////////////////////////////////////////////////////////////////
193 // views::MenuButtonDelegate implementation. 193 // views::MenuButtonListener implementation.
194 194
195 void LanguageSwitchMenu::RunMenu(views::View* source, const gfx::Point& pt) { 195 void LanguageSwitchMenu::OnMenuButtonClicked(views::View* source,
196 const gfx::Point& point) {
196 DCHECK(menu_ != NULL); 197 DCHECK(menu_ != NULL);
197 views::MenuButton* button = static_cast<views::MenuButton*>(source); 198 views::MenuButton* button = static_cast<views::MenuButton*>(source);
198 199
199 // We align on the left edge of the button for non RTL case. 200 // We align on the left edge of the button for non RTL case.
200 // MenuButton passes in pt the lower left corner for RTL and the 201 // MenuButton passes in |point| the lower left corner for RTL and the
201 // lower right corner for non-RTL (with menu_offset applied). 202 // lower right corner for non-RTL (with menu_offset applied).
202 const int reverse_offset = button->width() + button->menu_offset().x() * 2; 203 const int reverse_offset = button->width() + button->menu_offset().x() * 2;
203 gfx::Point new_pt(pt); 204 gfx::Point new_pt(point);
204 if (base::i18n::IsRTL()) 205 if (base::i18n::IsRTL())
205 new_pt.set_x(pt.x() + reverse_offset); 206 new_pt.set_x(point.x() + reverse_offset);
206 else 207 else
207 new_pt.set_x(pt.x() - reverse_offset); 208 new_pt.set_x(point.x() - reverse_offset);
208 209
209 if (menu_runner_->RunMenuAt(button->GetWidget(), button, 210 if (menu_runner_->RunMenuAt(button->GetWidget(), button,
210 gfx::Rect(new_pt, gfx::Size()), views::MenuItemView::TOPLEFT, 211 gfx::Rect(new_pt, gfx::Size()), views::MenuItemView::TOPLEFT,
211 views::MenuRunner::HAS_MNEMONICS) == views::MenuRunner::MENU_DELETED) 212 views::MenuRunner::HAS_MNEMONICS) == views::MenuRunner::MENU_DELETED)
212 return; 213 return;
213 } 214 }
214 215
215 //////////////////////////////////////////////////////////////////////////////// 216 ////////////////////////////////////////////////////////////////////////////////
216 // views::MenuDelegate implementation. 217 // views::MenuDelegate implementation.
217 218
218 void LanguageSwitchMenu::ExecuteCommand(int command_id) { 219 void LanguageSwitchMenu::ExecuteCommand(int command_id) {
219 const std::string locale = language_list_->GetLocaleFromIndex(command_id); 220 const std::string locale = language_list_->GetLocaleFromIndex(command_id);
220 // Here, we should enable keyboard layouts associated with the locale so 221 // Here, we should enable keyboard layouts associated with the locale so
221 // that users can use those keyboard layouts on the login screen. 222 // that users can use those keyboard layouts on the login screen.
222 SwitchLanguageAndEnableKeyboardLayouts(locale); 223 SwitchLanguageAndEnableKeyboardLayouts(locale);
223 InitLanguageMenu(); 224 InitLanguageMenu();
224 225
225 #if defined(USE_AURA) 226 #if defined(USE_AURA)
226 NotifyLocaleChanged(ash::Shell::GetRootWindow()); 227 NotifyLocaleChanged(ash::Shell::GetRootWindow());
227 #else 228 #else
228 // Update all view hierarchies that the locale has changed. 229 // Update all view hierarchies that the locale has changed.
229 views::Widget::NotifyLocaleChanged(); 230 views::Widget::NotifyLocaleChanged();
230 #endif 231 #endif
231 } 232 }
232 233
233 } // namespace chromeos 234 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/language_switch_menu.h ('k') | chrome/browser/chromeos/notifications/balloon_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698