| 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 "chrome/app/chrome_command_ids.h" | 5 #include "chrome/app/chrome_command_ids.h" |
| 6 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" |
| 6 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/extensions/extension_webnavigation_api.h" | |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 10 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/common/context_menu_params.h" | 17 #include "content/public/common/context_menu_params.h" |
| 18 #include "net/base/mock_host_resolver.h" | 18 #include "net/base/mock_host_resolver.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 36 #define MAYBE_WebNavigationIFrame WebNavigationIFrame | 36 #define MAYBE_WebNavigationIFrame WebNavigationIFrame |
| 37 #define MAYBE_WebNavigationFailures WebNavigationFailures | 37 #define MAYBE_WebNavigationFailures WebNavigationFailures |
| 38 #define MAYBE_WebNavigationForwardBack WebNavigationForwardBack | 38 #define MAYBE_WebNavigationForwardBack WebNavigationForwardBack |
| 39 #define MAYBE_WebNavigationClientRedirect WebNavigationClientRedirect | 39 #define MAYBE_WebNavigationClientRedirect WebNavigationClientRedirect |
| 40 #define MAYBE_WebNavigationGetFrame WebNavigationGetFrame | 40 #define MAYBE_WebNavigationGetFrame WebNavigationGetFrame |
| 41 #define MAYBE_WebNavigationSimpleLoad WebNavigationSimpleLoad | 41 #define MAYBE_WebNavigationSimpleLoad WebNavigationSimpleLoad |
| 42 #define MAYBE_WebNavigationReferenceFragment WebNavigationReferenceFragment | 42 #define MAYBE_WebNavigationReferenceFragment WebNavigationReferenceFragment |
| 43 #define MAYBE_WebNavigationOpenTab WebNavigationOpenTab | 43 #define MAYBE_WebNavigationOpenTab WebNavigationOpenTab |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 namespace extensions { |
| 47 |
| 46 namespace { | 48 namespace { |
| 47 | 49 |
| 48 class TestRenderViewContextMenu : public RenderViewContextMenu { | 50 class TestRenderViewContextMenu : public RenderViewContextMenu { |
| 49 public: | 51 public: |
| 50 TestRenderViewContextMenu(WebContents* web_contents, | 52 TestRenderViewContextMenu(WebContents* web_contents, |
| 51 const content::ContextMenuParams& params) | 53 const content::ContextMenuParams& params) |
| 52 : RenderViewContextMenu(web_contents, params) { | 54 : RenderViewContextMenu(web_contents, params) { |
| 53 } | 55 } |
| 54 virtual ~TestRenderViewContextMenu() {} | 56 virtual ~TestRenderViewContextMenu() {} |
| 55 | 57 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 service->GetExtensionById(last_loaded_extension_id_, false); | 192 service->GetExtensionById(last_loaded_extension_id_, false); |
| 191 GURL url = extension->GetResourceURL("userAction/a.html"); | 193 GURL url = extension->GetResourceURL("userAction/a.html"); |
| 192 | 194 |
| 193 ui_test_utils::NavigateToURL(browser(), url); | 195 ui_test_utils::NavigateToURL(browser(), url); |
| 194 | 196 |
| 195 // This corresponds to "Open link in new tab". | 197 // This corresponds to "Open link in new tab". |
| 196 content::ContextMenuParams params; | 198 content::ContextMenuParams params; |
| 197 params.is_editable = false; | 199 params.is_editable = false; |
| 198 params.media_type = WebKit::WebContextMenuData::MediaTypeNone; | 200 params.media_type = WebKit::WebContextMenuData::MediaTypeNone; |
| 199 params.page_url = url; | 201 params.page_url = url; |
| 200 params.frame_id = | 202 params.frame_id = WebNavigationTabObserver::Get(tab)-> |
| 201 ExtensionWebNavigationTabObserver::Get(tab)-> | 203 frame_navigation_state().GetMainFrameID(); |
| 202 frame_navigation_state().GetMainFrameID(); | |
| 203 params.link_url = extension->GetResourceURL("userAction/b.html"); | 204 params.link_url = extension->GetResourceURL("userAction/b.html"); |
| 204 | 205 |
| 205 TestRenderViewContextMenu menu(tab, params); | 206 TestRenderViewContextMenu menu(tab, params); |
| 206 menu.Init(); | 207 menu.Init(); |
| 207 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 208 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
| 208 | 209 |
| 209 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 210 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 210 } | 211 } |
| 211 | 212 |
| 212 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationRequestOpenTab) { | 213 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationRequestOpenTab) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; | 312 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; |
| 312 mouse_event.x = 7; | 313 mouse_event.x = 7; |
| 313 mouse_event.y = 7; | 314 mouse_event.y = 7; |
| 314 mouse_event.clickCount = 1; | 315 mouse_event.clickCount = 1; |
| 315 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 316 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
| 316 mouse_event.type = WebKit::WebInputEvent::MouseUp; | 317 mouse_event.type = WebKit::WebInputEvent::MouseUp; |
| 317 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 318 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
| 318 | 319 |
| 319 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 320 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 320 } | 321 } |
| 322 |
| 323 } // namespace extensions |
| OLD | NEW |