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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "content/browser/renderer_host/overscroll_controller_delegate.h" | 36 #include "content/browser/renderer_host/overscroll_controller_delegate.h" |
37 #include "content/browser/renderer_host/render_view_host_factory.h" | 37 #include "content/browser/renderer_host/render_view_host_factory.h" |
38 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 38 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
39 #include "content/browser/renderer_host/render_widget_host_impl.h" | 39 #include "content/browser/renderer_host/render_widget_host_impl.h" |
40 #include "content/browser/renderer_host/resize_lock.h" | 40 #include "content/browser/renderer_host/resize_lock.h" |
41 #include "content/browser/web_contents/web_contents_view_aura.h" | 41 #include "content/browser/web_contents/web_contents_view_aura.h" |
42 #include "content/common/host_shared_bitmap_manager.h" | 42 #include "content/common/host_shared_bitmap_manager.h" |
43 #include "content/common/input/input_event_utils.h" | 43 #include "content/common/input/input_event_utils.h" |
44 #include "content/common/input/synthetic_web_input_event_builders.h" | 44 #include "content/common/input/synthetic_web_input_event_builders.h" |
45 #include "content/common/input_messages.h" | 45 #include "content/common/input_messages.h" |
46 #include "content/common/text_input_state.h" | |
47 #include "content/common/view_messages.h" | 46 #include "content/common/view_messages.h" |
48 #include "content/public/browser/render_widget_host_view.h" | 47 #include "content/public/browser/render_widget_host_view.h" |
49 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 48 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
50 #include "content/public/browser/web_contents_view_delegate.h" | 49 #include "content/public/browser/web_contents_view_delegate.h" |
51 #include "content/public/common/context_menu_params.h" | 50 #include "content/public/common/context_menu_params.h" |
52 #include "content/public/test/mock_render_process_host.h" | 51 #include "content/public/test/mock_render_process_host.h" |
53 #include "content/public/test/test_browser_context.h" | 52 #include "content/public/test/test_browser_context.h" |
54 #include "content/test/test_render_view_host.h" | 53 #include "content/test/test_render_view_host.h" |
55 #include "content/test/test_web_contents.h" | 54 #include "content/test/test_web_contents.h" |
56 #include "ipc/ipc_test_sink.h" | 55 #include "ipc/ipc_test_sink.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 OverscrollMode current_mode_; | 147 OverscrollMode current_mode_; |
149 OverscrollMode completed_mode_; | 148 OverscrollMode completed_mode_; |
150 float delta_x_; | 149 float delta_x_; |
151 float delta_y_; | 150 float delta_y_; |
152 | 151 |
153 DISALLOW_COPY_AND_ASSIGN(TestOverscrollDelegate); | 152 DISALLOW_COPY_AND_ASSIGN(TestOverscrollDelegate); |
154 }; | 153 }; |
155 | 154 |
156 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { | 155 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { |
157 public: | 156 public: |
158 MockRenderWidgetHostDelegate() | 157 MockRenderWidgetHostDelegate() : rwh_(nullptr) {} |
159 : rwh_(nullptr), text_input_state_(new TextInputState()) {} | |
160 ~MockRenderWidgetHostDelegate() override {} | 158 ~MockRenderWidgetHostDelegate() override {} |
161 const NativeWebKeyboardEvent* last_event() const { return last_event_.get(); } | 159 const NativeWebKeyboardEvent* last_event() const { return last_event_.get(); } |
162 void set_widget_host(RenderWidgetHostImpl* rwh) { rwh_ = rwh; } | 160 void set_widget_host(RenderWidgetHostImpl* rwh) { rwh_ = rwh; } |
163 | 161 |
164 protected: | 162 protected: |
165 // RenderWidgetHostDelegate: | 163 // RenderWidgetHostDelegate: |
166 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 164 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
167 bool* is_keyboard_shortcut) override { | 165 bool* is_keyboard_shortcut) override { |
168 last_event_.reset(new NativeWebKeyboardEvent(event)); | 166 last_event_.reset(new NativeWebKeyboardEvent(event)); |
169 return true; | 167 return true; |
170 } | 168 } |
171 | |
172 const TextInputState* GetTextInputState() override { | |
173 return text_input_state_.get(); | |
174 } | |
175 | |
176 void Cut() override {} | 169 void Cut() override {} |
177 void Copy() override {} | 170 void Copy() override {} |
178 void Paste() override {} | 171 void Paste() override {} |
179 void SelectAll() override {} | 172 void SelectAll() override {} |
180 void SendScreenRects() override { | 173 void SendScreenRects() override { |
181 if (rwh_) | 174 if (rwh_) |
182 rwh_->SendScreenRects(); | 175 rwh_->SendScreenRects(); |
183 } | 176 } |
184 | 177 |
185 private: | 178 private: |
186 std::unique_ptr<NativeWebKeyboardEvent> last_event_; | 179 std::unique_ptr<NativeWebKeyboardEvent> last_event_; |
187 RenderWidgetHostImpl* rwh_; | 180 RenderWidgetHostImpl* rwh_; |
188 std::unique_ptr<TextInputState> text_input_state_; | |
189 | 181 |
190 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHostDelegate); | 182 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHostDelegate); |
191 }; | 183 }; |
192 | 184 |
193 // Simple observer that keeps track of changes to a window for tests. | 185 // Simple observer that keeps track of changes to a window for tests. |
194 class TestWindowObserver : public aura::WindowObserver { | 186 class TestWindowObserver : public aura::WindowObserver { |
195 public: | 187 public: |
196 explicit TestWindowObserver(aura::Window* window_to_observe) | 188 explicit TestWindowObserver(aura::Window* window_to_observe) |
197 : window_(window_to_observe) { | 189 : window_(window_to_observe) { |
198 window_->AddObserver(this); | 190 window_->AddObserver(this); |
(...skipping 4284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4483 view()->OnGestureEvent(&gesture_event); | 4475 view()->OnGestureEvent(&gesture_event); |
4484 | 4476 |
4485 EXPECT_TRUE(delegate->context_menu_request_received()); | 4477 EXPECT_TRUE(delegate->context_menu_request_received()); |
4486 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); | 4478 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); |
4487 #endif | 4479 #endif |
4488 | 4480 |
4489 RenderViewHostFactory::set_is_real_render_view_host(false); | 4481 RenderViewHostFactory::set_is_real_render_view_host(false); |
4490 } | 4482 } |
4491 | 4483 |
4492 } // namespace content | 4484 } // namespace content |
OLD | NEW |