| 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 "base/location.h" |
| 5 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 6 #include "base/process/process.h" | 7 #include "base/process/process.h" |
| 8 #include "base/single_thread_task_runner.h" |
| 7 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/thread_task_runner_handle.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/apps/app_browsertest_util.h" | 13 #include "chrome/browser/apps/app_browsertest_util.h" |
| 11 #include "chrome/browser/chrome_content_browser_client.h" | 14 #include "chrome/browser/chrome_content_browser_client.h" |
| 12 #include "chrome/browser/lifetime/application_lifetime.h" | 15 #include "chrome/browser/lifetime/application_lifetime.h" |
| 13 #include "chrome/browser/prerender/prerender_link_manager.h" | 16 #include "chrome/browser/prerender/prerender_link_manager.h" |
| 14 #include "chrome/browser/prerender/prerender_link_manager_factory.h" | 17 #include "chrome/browser/prerender/prerender_link_manager_factory.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 19 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
| 17 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti
l.h" | 20 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti
l.h" |
| 18 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 21 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 menu_observer_(chrome::NOTIFICATION_RENDER_VIEW_CONTEXT_MENU_SHOWN, | 143 menu_observer_(chrome::NOTIFICATION_RENDER_VIEW_CONTEXT_MENU_SHOWN, |
| 141 base::Bind(&ContextMenuCallCountObserver::OnMenuShown, | 144 base::Bind(&ContextMenuCallCountObserver::OnMenuShown, |
| 142 base::Unretained(this))) { | 145 base::Unretained(this))) { |
| 143 } | 146 } |
| 144 ~ContextMenuCallCountObserver() {} | 147 ~ContextMenuCallCountObserver() {} |
| 145 | 148 |
| 146 bool OnMenuShown(const content::NotificationSource& source, | 149 bool OnMenuShown(const content::NotificationSource& source, |
| 147 const content::NotificationDetails& details) { | 150 const content::NotificationDetails& details) { |
| 148 ++num_times_shown_; | 151 ++num_times_shown_; |
| 149 auto context_menu = content::Source<RenderViewContextMenu>(source).ptr(); | 152 auto context_menu = content::Source<RenderViewContextMenu>(source).ptr(); |
| 150 base::MessageLoop::current()->PostTask( | 153 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 151 FROM_HERE, base::Bind(&RenderViewContextMenuBase::Cancel, | 154 FROM_HERE, base::Bind(&RenderViewContextMenuBase::Cancel, |
| 152 base::Unretained(context_menu))); | 155 base::Unretained(context_menu))); |
| 153 return true; | 156 return true; |
| 154 } | 157 } |
| 155 | 158 |
| 156 void Wait() { menu_observer_.Wait(); } | 159 void Wait() { menu_observer_.Wait(); } |
| 157 | 160 |
| 158 int num_times_shown() { return num_times_shown_; } | 161 int num_times_shown() { return num_times_shown_; } |
| 159 | 162 |
| 160 private: | 163 private: |
| (...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1933 MenuItem::List items_after_all_removal = GetItems(); | 1936 MenuItem::List items_after_all_removal = GetItems(); |
| 1934 ASSERT_EQ(0u, items_after_all_removal.size()); | 1937 ASSERT_EQ(0u, items_after_all_removal.size()); |
| 1935 } | 1938 } |
| 1936 | 1939 |
| 1937 // Called in the TestContextMenu test to cancel the context menu after its | 1940 // Called in the TestContextMenu test to cancel the context menu after its |
| 1938 // shown notification is received. | 1941 // shown notification is received. |
| 1939 static bool ContextMenuNotificationCallback( | 1942 static bool ContextMenuNotificationCallback( |
| 1940 const content::NotificationSource& source, | 1943 const content::NotificationSource& source, |
| 1941 const content::NotificationDetails& details) { | 1944 const content::NotificationDetails& details) { |
| 1942 auto context_menu = content::Source<RenderViewContextMenu>(source).ptr(); | 1945 auto context_menu = content::Source<RenderViewContextMenu>(source).ptr(); |
| 1943 base::MessageLoop::current()->PostTask( | 1946 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1944 FROM_HERE, base::Bind(&RenderViewContextMenuBase::Cancel, | 1947 FROM_HERE, base::Bind(&RenderViewContextMenuBase::Cancel, |
| 1945 base::Unretained(context_menu))); | 1948 base::Unretained(context_menu))); |
| 1946 return true; | 1949 return true; |
| 1947 } | 1950 } |
| 1948 | 1951 |
| 1949 IN_PROC_BROWSER_TEST_F(WebViewTest, ContextMenusAPI_PreventDefault) { | 1952 IN_PROC_BROWSER_TEST_F(WebViewTest, ContextMenusAPI_PreventDefault) { |
| 1950 LoadAppWithGuest("web_view/context_menus/basic"); | 1953 LoadAppWithGuest("web_view/context_menus/basic"); |
| 1951 | 1954 |
| 1952 content::WebContents* guest_web_contents = GetGuestWebContents(); | 1955 content::WebContents* guest_web_contents = GetGuestWebContents(); |
| 1953 content::WebContents* embedder = GetEmbedderWebContents(); | 1956 content::WebContents* embedder = GetEmbedderWebContents(); |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2626 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. | 2629 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
| 2627 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/post_message/basic")) | 2630 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/post_message/basic")) |
| 2628 << message_; | 2631 << message_; |
| 2629 } | 2632 } |
| 2630 | 2633 |
| 2631 // Tests that webviews do get garbage collected. | 2634 // Tests that webviews do get garbage collected. |
| 2632 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestGarbageCollect) { | 2635 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestGarbageCollect) { |
| 2633 TestHelper("testGarbageCollect", "web_view/shim", NO_TEST_SERVER); | 2636 TestHelper("testGarbageCollect", "web_view/shim", NO_TEST_SERVER); |
| 2634 GetGuestViewManager()->WaitForSingleViewGarbageCollected(); | 2637 GetGuestViewManager()->WaitForSingleViewGarbageCollected(); |
| 2635 } | 2638 } |
| OLD | NEW |