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

Side by Side Diff: chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc

Issue 8253001: aura: Some changes in Window and Desktop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
« no previous file with comments | « no previous file | ui/aura/desktop.h » ('j') | ui/aura/desktop.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/virtual_keyboard/virtual_keyboard_manager.h" 5 #include "chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/extension_event_router.h" 9 #include "chrome/browser/extensions/extension_event_router.h"
10 #include "chrome/browser/extensions/extension_function_dispatcher.h" 10 #include "chrome/browser/extensions/extension_function_dispatcher.h"
(...skipping 19 matching lines...) Expand all
30 #include "ui/gfx/screen.h" 30 #include "ui/gfx/screen.h"
31 #include "views/ime/text_input_type_tracker.h" 31 #include "views/ime/text_input_type_tracker.h"
32 #include "views/widget/widget.h" 32 #include "views/widget/widget.h"
33 33
34 #if defined(OS_CHROMEOS) 34 #if defined(OS_CHROMEOS)
35 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 35 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
36 #include "chrome/browser/chromeos/input_method/virtual_keyboard_selector.h" 36 #include "chrome/browser/chromeos/input_method/virtual_keyboard_selector.h"
37 #endif 37 #endif
38 38
39 #if defined(USE_AURA) 39 #if defined(USE_AURA)
40 #include "ui/aura/desktop.h"
40 #include "ui/aura_shell/shell.h" 41 #include "ui/aura_shell/shell.h"
41 #include "ui/aura_shell/shell_window_ids.h" 42 #include "ui/aura_shell/shell_window_ids.h"
42 #endif 43 #endif
43 44
44 namespace { 45 namespace {
45 46
46 const int kDefaultKeyboardHeight = 300; 47 const int kDefaultKeyboardHeight = 300;
47 const int kKeyboardSlideDuration = 300; // In milliseconds 48 const int kKeyboardSlideDuration = 300; // In milliseconds
48 const char kOnTextInputTypeChanged[] = 49 const char kOnTextInputTypeChanged[] =
49 "experimental.input.onTextInputTypeChanged"; 50 "experimental.input.onTextInputTypeChanged";
(...skipping 16 matching lines...) Expand all
66 // TODO(sad): Is the default profile always going to be the one we want? 67 // TODO(sad): Is the default profile always going to be the one we want?
67 68
68 class KeyboardWidget 69 class KeyboardWidget
69 : public views::Widget, 70 : public views::Widget,
70 public ui::AnimationDelegate, 71 public ui::AnimationDelegate,
71 public TabContentsObserver, 72 public TabContentsObserver,
72 public ExtensionFunctionDispatcher::Delegate, 73 public ExtensionFunctionDispatcher::Delegate,
73 #if defined(OS_CHROMEOS) 74 #if defined(OS_CHROMEOS)
74 public chromeos::input_method::InputMethodManager::VirtualKeyboardObserver , 75 public chromeos::input_method::InputMethodManager::VirtualKeyboardObserver ,
75 #endif 76 #endif
77 #if defined(USE_AURA)
78 public aura::Desktop::Observer,
79 #endif
76 public NotificationObserver, 80 public NotificationObserver,
77 public views::Widget::Observer, 81 public views::Widget::Observer,
78 public views::TextInputTypeObserver { 82 public views::TextInputTypeObserver {
79 public: 83 public:
80 KeyboardWidget(); 84 KeyboardWidget();
81 virtual ~KeyboardWidget(); 85 virtual ~KeyboardWidget();
82 86
83 // Show the keyboard for the target widget. The events from the keyboard will 87 // Show the keyboard for the target widget. The events from the keyboard will
84 // be sent to |widget|. 88 // be sent to |widget|.
85 void ShowKeyboardForWidget(views::Widget* widget); 89 void ShowKeyboardForWidget(views::Widget* widget);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 virtual TabContents* GetAssociatedTabContents() const OVERRIDE; 123 virtual TabContents* GetAssociatedTabContents() const OVERRIDE;
120 124
121 #if defined(OS_CHROMEOS) 125 #if defined(OS_CHROMEOS)
122 // Overridden from input_method::InputMethodManager::VirtualKeyboardObserver. 126 // Overridden from input_method::InputMethodManager::VirtualKeyboardObserver.
123 virtual void VirtualKeyboardChanged( 127 virtual void VirtualKeyboardChanged(
124 chromeos::input_method::InputMethodManager* manager, 128 chromeos::input_method::InputMethodManager* manager,
125 const chromeos::input_method::VirtualKeyboard& virtual_keyboard, 129 const chromeos::input_method::VirtualKeyboard& virtual_keyboard,
126 const std::string& virtual_keyboard_layout); 130 const std::string& virtual_keyboard_layout);
127 #endif 131 #endif
128 132
133 #if defined(USE_AURA)
134 // Overridden from aura::Desktop::Observer.
135 virtual void OnDesktopResized(const gfx::Size& new_size) OVERRIDE;
136 #endif
137
129 // Overridden from NotificationObserver. 138 // Overridden from NotificationObserver.
130 virtual void Observe(int type, 139 virtual void Observe(int type,
131 const NotificationSource& source, 140 const NotificationSource& source,
132 const NotificationDetails& details) OVERRIDE; 141 const NotificationDetails& details) OVERRIDE;
133 142
134 // Overridden from views::Widget::Observer. 143 // Overridden from views::Widget::Observer.
135 virtual void OnWidgetClosing(Widget* widget) OVERRIDE; 144 virtual void OnWidgetClosing(Widget* widget) OVERRIDE;
136 virtual void OnWidgetVisibilityChanged(Widget* widget, bool visible) OVERRIDE; 145 virtual void OnWidgetVisibilityChanged(Widget* widget, bool visible) OVERRIDE;
137 virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE; 146 virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE;
138 147
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 NotificationService::AllSources()); 215 NotificationService::AllSources());
207 registrar_.Add(this, 216 registrar_.Add(this,
208 content::NOTIFICATION_APP_TERMINATING, 217 content::NOTIFICATION_APP_TERMINATING,
209 NotificationService::AllSources()); 218 NotificationService::AllSources());
210 219
211 #if defined(OS_CHROMEOS) 220 #if defined(OS_CHROMEOS)
212 chromeos::input_method::InputMethodManager* manager = 221 chromeos::input_method::InputMethodManager* manager =
213 chromeos::input_method::InputMethodManager::GetInstance(); 222 chromeos::input_method::InputMethodManager::GetInstance();
214 manager->AddVirtualKeyboardObserver(this); 223 manager->AddVirtualKeyboardObserver(this);
215 #endif 224 #endif
225
226 #if defined(USE_AURA)
227 aura::Desktop::GetInstance()->AddObserver(this);
228 #endif
216 } 229 }
217 230
218 KeyboardWidget::~KeyboardWidget() { 231 KeyboardWidget::~KeyboardWidget() {
219 if (target_) 232 if (target_)
220 target_->RemoveObserver(this); 233 target_->RemoveObserver(this);
221 views::TextInputTypeTracker::GetInstance()->RemoveTextInputTypeObserver(this); 234 views::TextInputTypeTracker::GetInstance()->RemoveTextInputTypeObserver(this);
222 #if defined(OS_CHROMEOS) 235 #if defined(OS_CHROMEOS)
223 chromeos::input_method::InputMethodManager* manager = 236 chromeos::input_method::InputMethodManager* manager =
224 chromeos::input_method::InputMethodManager::GetInstance(); 237 chromeos::input_method::InputMethodManager::GetInstance();
225 manager->RemoveVirtualKeyboardObserver(this); 238 manager->RemoveVirtualKeyboardObserver(this);
226 #endif 239 #endif
227 240
241 #if defined(USE_AURA)
242 aura::Desktop::GetInstance()->RemoveObserver(this);
243 #endif
228 // TODO(sad): Do anything else? 244 // TODO(sad): Do anything else?
229 } 245 }
230 246
231 void KeyboardWidget::ShowKeyboardForWidget(views::Widget* widget) { 247 void KeyboardWidget::ShowKeyboardForWidget(views::Widget* widget) {
232 if (target_ == widget && IsVisible() && !animation_->is_animating()) 248 if (target_ == widget && IsVisible() && !animation_->is_animating())
233 return; 249 return;
234 SetTarget(widget); 250 SetTarget(widget);
235 251
236 transform_.reset(new ui::InterpolatedTranslation( 252 transform_.reset(new ui::InterpolatedTranslation(
237 gfx::Point(0, keyboard_height_), gfx::Point())); 253 gfx::Point(0, keyboard_height_), gfx::Point()));
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 void KeyboardWidget::VirtualKeyboardChanged( 418 void KeyboardWidget::VirtualKeyboardChanged(
403 chromeos::input_method::InputMethodManager* manager, 419 chromeos::input_method::InputMethodManager* manager,
404 const chromeos::input_method::VirtualKeyboard& virtual_keyboard, 420 const chromeos::input_method::VirtualKeyboard& virtual_keyboard,
405 const std::string& virtual_keyboard_layout) { 421 const std::string& virtual_keyboard_layout) {
406 const GURL& url = virtual_keyboard.GetURLForLayout(virtual_keyboard_layout); 422 const GURL& url = virtual_keyboard.GetURLForLayout(virtual_keyboard_layout);
407 dom_view_->LoadURL(url); 423 dom_view_->LoadURL(url);
408 VLOG(1) << "VirtualKeyboardChanged: Switched to " << url.spec(); 424 VLOG(1) << "VirtualKeyboardChanged: Switched to " << url.spec();
409 } 425 }
410 #endif 426 #endif
411 427
428 #if defined(USE_AURA)
429 void KeyboardWidget::OnDesktopResized(const gfx::Size& new_size) {
430 ResetBounds();
431 }
432 #endif
433
412 void KeyboardWidget::Observe(int type, 434 void KeyboardWidget::Observe(int type,
413 const NotificationSource& source, 435 const NotificationSource& source,
414 const NotificationDetails& details) { 436 const NotificationDetails& details) {
415 switch (type) { 437 switch (type) {
416 case chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED: { 438 case chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED: {
417 // In case the keyboard hid itself and the focus is still in an editable 439 // In case the keyboard hid itself and the focus is still in an editable
418 // field, and the user touches the field, then we want to show the 440 // field, and the user touches the field, then we want to show the
419 // keyboard again. 441 // keyboard again.
420 views::Widget* widget = GetBrowserWidget(); 442 views::Widget* widget = GetBrowserWidget();
421 if (widget) 443 if (widget)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 545
524 void VirtualKeyboardManager::OnDesktopBoundsChanged( 546 void VirtualKeyboardManager::OnDesktopBoundsChanged(
525 const gfx::Rect& prev_bounds) { 547 const gfx::Rect& prev_bounds) {
526 keyboard_->ResetBounds(); 548 keyboard_->ResetBounds();
527 } 549 }
528 550
529 // static 551 // static
530 VirtualKeyboardManager* VirtualKeyboardManager::GetInstance() { 552 VirtualKeyboardManager* VirtualKeyboardManager::GetInstance() {
531 return Singleton<VirtualKeyboardManager>::get(); 553 return Singleton<VirtualKeyboardManager>::get();
532 } 554 }
OLDNEW
« no previous file with comments | « no previous file | ui/aura/desktop.h » ('j') | ui/aura/desktop.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698