OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <queue> | 5 #include <queue> |
6 #include <set> | 6 #include <set> |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 base::Bind(&ContextMenuCallCountObserver::OnMenuShown, | 158 base::Bind(&ContextMenuCallCountObserver::OnMenuShown, |
159 base::Unretained(this))) { | 159 base::Unretained(this))) { |
160 } | 160 } |
161 ~ContextMenuCallCountObserver() {} | 161 ~ContextMenuCallCountObserver() {} |
162 | 162 |
163 bool OnMenuShown(const content::NotificationSource& source, | 163 bool OnMenuShown(const content::NotificationSource& source, |
164 const content::NotificationDetails& details) { | 164 const content::NotificationDetails& details) { |
165 ++num_times_shown_; | 165 ++num_times_shown_; |
166 auto* context_menu = content::Source<RenderViewContextMenu>(source).ptr(); | 166 auto* context_menu = content::Source<RenderViewContextMenu>(source).ptr(); |
167 base::ThreadTaskRunnerHandle::Get()->PostTask( | 167 base::ThreadTaskRunnerHandle::Get()->PostTask( |
168 FROM_HERE, base::Bind(&RenderViewContextMenuBase::Cancel, | 168 FROM_HERE, base::BindOnce(&RenderViewContextMenuBase::Cancel, |
169 base::Unretained(context_menu))); | 169 base::Unretained(context_menu))); |
170 return true; | 170 return true; |
171 } | 171 } |
172 | 172 |
173 void Wait() { menu_observer_.Wait(); } | 173 void Wait() { menu_observer_.Wait(); } |
174 | 174 |
175 int num_times_shown() { return num_times_shown_; } | 175 int num_times_shown() { return num_times_shown_; } |
176 | 176 |
177 private: | 177 private: |
178 int num_times_shown_; | 178 int num_times_shown_; |
179 content::WindowedNotificationObserver menu_observer_; | 179 content::WindowedNotificationObserver menu_observer_; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 mouse_event_.SetType(blink::WebInputEvent::kMouseDown); | 303 mouse_event_.SetType(blink::WebInputEvent::kMouseDown); |
304 mouse_event_.SetPositionInWidget(point.x(), point.y()); | 304 mouse_event_.SetPositionInWidget(point.x(), point.y()); |
305 const gfx::Rect offset = web_contents_->GetContainerBounds(); | 305 const gfx::Rect offset = web_contents_->GetContainerBounds(); |
306 mouse_event_.SetPositionInScreen(point.x() + offset.x(), | 306 mouse_event_.SetPositionInScreen(point.x() + offset.x(), |
307 point.y() + offset.y()); | 307 point.y() + offset.y()); |
308 mouse_event_.click_count = 1; | 308 mouse_event_.click_count = 1; |
309 web_contents_->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( | 309 web_contents_->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( |
310 mouse_event_); | 310 mouse_event_); |
311 | 311 |
312 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 312 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
313 FROM_HERE, base::Bind(&LeftMouseClick::SendMouseUp, | 313 FROM_HERE, |
314 base::Unretained(this)), | 314 base::BindOnce(&LeftMouseClick::SendMouseUp, base::Unretained(this)), |
315 base::TimeDelta::FromMilliseconds(duration_ms)); | 315 base::TimeDelta::FromMilliseconds(duration_ms)); |
316 } | 316 } |
317 | 317 |
318 // Wait for click completed. | 318 // Wait for click completed. |
319 void Wait() { | 319 void Wait() { |
320 if (click_completed_) | 320 if (click_completed_) |
321 return; | 321 return; |
322 message_loop_runner_ = new content::MessageLoopRunner; | 322 message_loop_runner_ = new content::MessageLoopRunner; |
323 message_loop_runner_->Run(); | 323 message_loop_runner_->Run(); |
324 message_loop_runner_ = nullptr; | 324 message_loop_runner_ = nullptr; |
(...skipping 1877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2202 ASSERT_EQ(0u, items_after_all_removal.size()); | 2202 ASSERT_EQ(0u, items_after_all_removal.size()); |
2203 } | 2203 } |
2204 | 2204 |
2205 // Called in the TestContextMenu test to cancel the context menu after its | 2205 // Called in the TestContextMenu test to cancel the context menu after its |
2206 // shown notification is received. | 2206 // shown notification is received. |
2207 static bool ContextMenuNotificationCallback( | 2207 static bool ContextMenuNotificationCallback( |
2208 const content::NotificationSource& source, | 2208 const content::NotificationSource& source, |
2209 const content::NotificationDetails& details) { | 2209 const content::NotificationDetails& details) { |
2210 auto* context_menu = content::Source<RenderViewContextMenu>(source).ptr(); | 2210 auto* context_menu = content::Source<RenderViewContextMenu>(source).ptr(); |
2211 base::ThreadTaskRunnerHandle::Get()->PostTask( | 2211 base::ThreadTaskRunnerHandle::Get()->PostTask( |
2212 FROM_HERE, base::Bind(&RenderViewContextMenuBase::Cancel, | 2212 FROM_HERE, base::BindOnce(&RenderViewContextMenuBase::Cancel, |
2213 base::Unretained(context_menu))); | 2213 base::Unretained(context_menu))); |
2214 return true; | 2214 return true; |
2215 } | 2215 } |
2216 | 2216 |
2217 IN_PROC_BROWSER_TEST_P(WebViewTest, ContextMenusAPI_PreventDefault) { | 2217 IN_PROC_BROWSER_TEST_P(WebViewTest, ContextMenusAPI_PreventDefault) { |
2218 LoadAppWithGuest("web_view/context_menus/basic"); | 2218 LoadAppWithGuest("web_view/context_menus/basic"); |
2219 | 2219 |
2220 content::WebContents* guest_web_contents = GetGuestWebContents(); | 2220 content::WebContents* guest_web_contents = GetGuestWebContents(); |
2221 content::WebContents* embedder = GetEmbedderWebContents(); | 2221 content::WebContents* embedder = GetEmbedderWebContents(); |
2222 ASSERT_TRUE(embedder); | 2222 ASSERT_TRUE(embedder); |
2223 | 2223 |
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4125 ClosingChromeSignInShouldNotCrash) { | 4125 ClosingChromeSignInShouldNotCrash) { |
4126 GURL signin_url{"chrome://chrome-signin"}; | 4126 GURL signin_url{"chrome://chrome-signin"}; |
4127 | 4127 |
4128 AddTabAtIndex(0, signin_url, ui::PAGE_TRANSITION_TYPED); | 4128 AddTabAtIndex(0, signin_url, ui::PAGE_TRANSITION_TYPED); |
4129 AddTabAtIndex(1, signin_url, ui::PAGE_TRANSITION_TYPED); | 4129 AddTabAtIndex(1, signin_url, ui::PAGE_TRANSITION_TYPED); |
4130 WaitForWebViewInDom(); | 4130 WaitForWebViewInDom(); |
4131 | 4131 |
4132 chrome::CloseTab(browser()); | 4132 chrome::CloseTab(browser()); |
4133 } | 4133 } |
4134 #endif | 4134 #endif |
OLD | NEW |