| 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 "ui/views/widget/widget.h" | 5 #include "ui/views/widget/widget.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "ui/base/event.h" | 10 #include "ui/base/event.h" |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL; | 651 return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL; |
| 652 } | 652 } |
| 653 | 653 |
| 654 const FocusManager* Widget::GetFocusManager() const { | 654 const FocusManager* Widget::GetFocusManager() const { |
| 655 const Widget* toplevel_widget = GetTopLevelWidget(); | 655 const Widget* toplevel_widget = GetTopLevelWidget(); |
| 656 return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL; | 656 return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL; |
| 657 } | 657 } |
| 658 | 658 |
| 659 InputMethod* Widget::GetInputMethod() { | 659 InputMethod* Widget::GetInputMethod() { |
| 660 if (is_top_level()) { | 660 if (is_top_level()) { |
| 661 if (!input_method_.get()) | 661 if (!input_method_.get()) { |
| 662 input_method_.reset(native_widget_->CreateInputMethod()); | 662 input_method_.reset(native_widget_->CreateInputMethod()); |
| 663 if (input_method_.get()) |
| 664 input_method_->Init(this); |
| 665 } |
| 663 return input_method_.get(); | 666 return input_method_.get(); |
| 664 } else { | 667 } else { |
| 665 Widget* toplevel = GetTopLevelWidget(); | 668 Widget* toplevel = GetTopLevelWidget(); |
| 666 // If GetTopLevelWidget() returns itself which is not toplevel, | 669 // If GetTopLevelWidget() returns itself which is not toplevel, |
| 667 // the widget is detached from toplevel widget. | 670 // the widget is detached from toplevel widget. |
| 668 // TODO(oshima): Fix GetTopLevelWidget() to return NULL | 671 // TODO(oshima): Fix GetTopLevelWidget() to return NULL |
| 669 // if there is no toplevel. We probably need to add GetTopMostWidget() | 672 // if there is no toplevel. We probably need to add GetTopMostWidget() |
| 670 // to replace some use cases. | 673 // to replace some use cases. |
| 671 return (toplevel && toplevel != this) ? toplevel->GetInputMethod() : NULL; | 674 return (toplevel && toplevel != this) ? toplevel->GetInputMethod() : NULL; |
| 672 } | 675 } |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 if (bounds->height() < minimum_size.height()) | 1316 if (bounds->height() < minimum_size.height()) |
| 1314 bounds->set_height(minimum_size.height()); | 1317 bounds->set_height(minimum_size.height()); |
| 1315 } | 1318 } |
| 1316 return true; | 1319 return true; |
| 1317 } | 1320 } |
| 1318 return false; | 1321 return false; |
| 1319 } | 1322 } |
| 1320 | 1323 |
| 1321 void Widget::ReplaceInputMethod(InputMethod* input_method) { | 1324 void Widget::ReplaceInputMethod(InputMethod* input_method) { |
| 1322 input_method_.reset(input_method); | 1325 input_method_.reset(input_method); |
| 1323 input_method->set_delegate(native_widget_); | 1326 input_method->set_delegate(native_widget_->GetInputMethodDelegate()); |
| 1324 input_method->Init(this); | 1327 input_method->Init(this); |
| 1325 } | 1328 } |
| 1326 | 1329 |
| 1327 namespace internal { | 1330 namespace internal { |
| 1328 | 1331 |
| 1329 //////////////////////////////////////////////////////////////////////////////// | 1332 //////////////////////////////////////////////////////////////////////////////// |
| 1330 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1333 // internal::NativeWidgetPrivate, NativeWidget implementation: |
| 1331 | 1334 |
| 1332 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1335 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
| 1333 return this; | 1336 return this; |
| 1334 } | 1337 } |
| 1335 | 1338 |
| 1336 } // namespace internal | 1339 } // namespace internal |
| 1337 } // namespace views | 1340 } // namespace views |
| OLD | NEW |