| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "ui/views/cocoa/bridged_native_widget.h" | 5 #import "ui/views/cocoa/bridged_native_widget.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/base/ime/input_method.h" | 8 #include "ui/base/ime/input_method.h" |
| 9 #include "ui/base/ime/input_method_factory.h" | 9 #include "ui/base/ime/input_method_factory.h" |
| 10 #include "ui/base/ui_base_switches_util.h" | 10 #include "ui/base/ui_base_switches_util.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // floating around in Cocoa libraries at this point. However, references to | 38 // floating around in Cocoa libraries at this point. However, references to |
| 39 // the old views::View will be gone, so any method calls will become no-ops. | 39 // the old views::View will be gone, so any method calls will become no-ops. |
| 40 | 40 |
| 41 if (view) { | 41 if (view) { |
| 42 bridged_view_.reset([[BridgedContentView alloc] initWithView:view]); | 42 bridged_view_.reset([[BridgedContentView alloc] initWithView:view]); |
| 43 // Objective C initializers can return nil. However, if |view| is non-NULL | 43 // Objective C initializers can return nil. However, if |view| is non-NULL |
| 44 // this should be treated as an error and caught early. | 44 // this should be treated as an error and caught early. |
| 45 CHECK(bridged_view_); | 45 CHECK(bridged_view_); |
| 46 } | 46 } |
| 47 [window_ setContentView:bridged_view_]; | 47 [window_ setContentView:bridged_view_]; |
| 48 [window_ makeFirstResponder:bridged_view_]; |
| 48 } | 49 } |
| 49 | 50 |
| 50 InputMethod* BridgedNativeWidget::CreateInputMethod() { | 51 InputMethod* BridgedNativeWidget::CreateInputMethod() { |
| 51 if (switches::IsTextInputFocusManagerEnabled()) | 52 if (switches::IsTextInputFocusManagerEnabled()) |
| 52 return new NullInputMethod(); | 53 return new NullInputMethod(); |
| 53 | 54 |
| 54 return new InputMethodBridge(this, GetHostInputMethod(), true); | 55 return new InputMethodBridge(this, GetHostInputMethod(), true); |
| 55 } | 56 } |
| 56 | 57 |
| 57 ui::InputMethod* BridgedNativeWidget::GetHostInputMethod() { | 58 ui::InputMethod* BridgedNativeWidget::GetHostInputMethod() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 69 void BridgedNativeWidget::DispatchKeyEventPostIME(const ui::KeyEvent& key) { | 70 void BridgedNativeWidget::DispatchKeyEventPostIME(const ui::KeyEvent& key) { |
| 70 // Mac key events don't go through this, but some unit tests that use | 71 // Mac key events don't go through this, but some unit tests that use |
| 71 // MockInputMethod do. | 72 // MockInputMethod do. |
| 72 Widget* widget = [bridged_view_ hostedView]->GetWidget(); | 73 Widget* widget = [bridged_view_ hostedView]->GetWidget(); |
| 73 widget->OnKeyEvent(const_cast<ui::KeyEvent*>(&key)); | 74 widget->OnKeyEvent(const_cast<ui::KeyEvent*>(&key)); |
| 74 if (!key.handled() && widget->GetFocusManager()) | 75 if (!key.handled() && widget->GetFocusManager()) |
| 75 widget->GetFocusManager()->OnKeyEvent(key); | 76 widget->GetFocusManager()->OnKeyEvent(key); |
| 76 } | 77 } |
| 77 | 78 |
| 78 } // namespace views | 79 } // namespace views |
| OLD | NEW |