| 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 #include "mojo/views/native_widget_view_manager.h" | 5 #include "mojo/views/native_widget_view_manager.h" |
| 6 | 6 |
| 7 #include "mojo/aura/window_tree_host_mojo.h" | 7 #include "mojo/aura/window_tree_host_mojo.h" |
| 8 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" | 8 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/client/default_capture_client.h" | 10 #include "ui/aura/client/default_capture_client.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 aura::Window* root_; | 80 aura::Window* root_; |
| 81 scoped_ptr<ui::InputMethod> input_method_; | 81 scoped_ptr<ui::InputMethod> input_method_; |
| 82 | 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(MinimalInputEventFilter); | 83 DISALLOW_COPY_AND_ASSIGN(MinimalInputEventFilter); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 } // namespace | 86 } // namespace |
| 87 | 87 |
| 88 NativeWidgetViewManager::NativeWidgetViewManager( | 88 NativeWidgetViewManager::NativeWidgetViewManager( |
| 89 views::internal::NativeWidgetDelegate* delegate, Node* node) | 89 views::internal::NativeWidgetDelegate* delegate, View* view) |
| 90 : NativeWidgetAura(delegate), | 90 : NativeWidgetAura(delegate), |
| 91 node_(node) { | 91 view_(view) { |
| 92 node_->AddObserver(this); | 92 view_->AddObserver(this); |
| 93 window_tree_host_.reset(new WindowTreeHostMojo(node_, this)); | 93 window_tree_host_.reset(new WindowTreeHostMojo(view_, this)); |
| 94 window_tree_host_->InitHost(); | 94 window_tree_host_->InitHost(); |
| 95 | 95 |
| 96 ime_filter_.reset( | 96 ime_filter_.reset( |
| 97 new MinimalInputEventFilter(window_tree_host_->window())); | 97 new MinimalInputEventFilter(window_tree_host_->window())); |
| 98 | 98 |
| 99 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); | 99 focus_client_.reset(new wm::FocusController(new FocusRulesImpl)); |
| 100 | 100 |
| 101 aura::client::SetFocusClient(window_tree_host_->window(), | 101 aura::client::SetFocusClient(window_tree_host_->window(), |
| 102 focus_client_.get()); | 102 focus_client_.get()); |
| 103 aura::client::SetActivationClient(window_tree_host_->window(), | 103 aura::client::SetActivationClient(window_tree_host_->window(), |
| 104 focus_client_.get()); | 104 focus_client_.get()); |
| 105 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); | 105 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); |
| 106 | 106 |
| 107 aura::client::SetCaptureClient( | 107 aura::client::SetCaptureClient( |
| 108 window_tree_host_->window(), | 108 window_tree_host_->window(), |
| 109 new aura::client::DefaultCaptureClient(window_tree_host_->window())); | 109 new aura::client::DefaultCaptureClient(window_tree_host_->window())); |
| 110 } | 110 } |
| 111 | 111 |
| 112 NativeWidgetViewManager::~NativeWidgetViewManager() { | 112 NativeWidgetViewManager::~NativeWidgetViewManager() { |
| 113 if (node_) | 113 if (view_) |
| 114 node_->RemoveObserver(this); | 114 view_->RemoveObserver(this); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void NativeWidgetViewManager::InitNativeWidget( | 117 void NativeWidgetViewManager::InitNativeWidget( |
| 118 const views::Widget::InitParams& in_params) { | 118 const views::Widget::InitParams& in_params) { |
| 119 views::Widget::InitParams params(in_params); | 119 views::Widget::InitParams params(in_params); |
| 120 params.parent = window_tree_host_->window(); | 120 params.parent = window_tree_host_->window(); |
| 121 NativeWidgetAura::InitNativeWidget(params); | 121 NativeWidgetAura::InitNativeWidget(params); |
| 122 capture_client_.reset( | 122 capture_client_.reset( |
| 123 new wm::ScopedCaptureClient(window_tree_host_->window())); | 123 new wm::ScopedCaptureClient(window_tree_host_->window())); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void NativeWidgetViewManager::CompositorContentsChanged( | 126 void NativeWidgetViewManager::CompositorContentsChanged( |
| 127 const SkBitmap& bitmap) { | 127 const SkBitmap& bitmap) { |
| 128 if (node_) | 128 if (view_) |
| 129 node_->SetContents(bitmap); | 129 view_->SetContents(bitmap); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void NativeWidgetViewManager::OnNodeDestroyed(Node* node) { | 132 void NativeWidgetViewManager::OnViewDestroyed(View* view) { |
| 133 DCHECK_EQ(node, node_); | 133 DCHECK_EQ(view, view_); |
| 134 node->RemoveObserver(this); | 134 view->RemoveObserver(this); |
| 135 node_ = NULL; | 135 view_ = NULL; |
| 136 window_tree_host_.reset(); | 136 window_tree_host_.reset(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void NativeWidgetViewManager::OnNodeBoundsChanged(Node* node, | 139 void NativeWidgetViewManager::OnViewBoundsChanged(View* view, |
| 140 const gfx::Rect& old_bounds, | 140 const gfx::Rect& old_bounds, |
| 141 const gfx::Rect& new_bounds) { | 141 const gfx::Rect& new_bounds) { |
| 142 GetWidget()->SetBounds(gfx::Rect(node->bounds().size())); | 142 GetWidget()->SetBounds(gfx::Rect(view->bounds().size())); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void NativeWidgetViewManager::OnNodeInputEvent(Node* node, | 145 void NativeWidgetViewManager::OnViewInputEvent(View* view, |
| 146 const EventPtr& event) { | 146 const EventPtr& event) { |
| 147 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event> >()); | 147 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event> >()); |
| 148 if (ui_event) | 148 if (ui_event) |
| 149 window_tree_host_->SendEventToProcessor(ui_event.get()); | 149 window_tree_host_->SendEventToProcessor(ui_event.get()); |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace mojo | 152 } // namespace mojo |
| OLD | NEW |