| 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 "chrome/renderer/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/render_messages.h" | 16 #include "chrome/common/render_messages.h" |
| 17 #include "chrome/renderer/searchbox/searchbox.h" | 17 #include "chrome/renderer/searchbox/searchbox.h" |
| 18 #include "chrome/test/base/chrome_render_view_test.h" | 18 #include "chrome/test/base/chrome_render_view_test.h" |
| 19 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
| 20 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
| 21 #include "content/public/child/url_loader_throttle.h" |
| 21 #include "content/public/common/content_constants.h" | 22 #include "content/public/common/content_constants.h" |
| 22 #include "content/public/renderer/render_frame.h" | 23 #include "content/public/renderer/render_frame.h" |
| 23 #include "content/public/renderer/render_view.h" | 24 #include "content/public/renderer/render_view.h" |
| 24 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
| 25 #include "content/public/test/mock_render_thread.h" | 26 #include "content/public/test/mock_render_thread.h" |
| 26 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
| 27 #include "ipc/ipc_listener.h" | 28 #include "ipc/ipc_listener.h" |
| 28 #include "ipc/ipc_sender.h" | 29 #include "ipc/ipc_sender.h" |
| 29 #include "ipc/ipc_test_sink.h" | 30 #include "ipc/ipc_test_sink.h" |
| 30 #include "net/dns/mock_host_resolver.h" | 31 #include "net/dns/mock_host_resolver.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 LoadHTML(kHtmlWithIframe); | 92 LoadHTML(kHtmlWithIframe); |
| 92 | 93 |
| 93 ChromeContentRendererClient client; | 94 ChromeContentRendererClient client; |
| 94 | 95 |
| 95 // Create a thumbnail URL containing the correct render view ID and an | 96 // Create a thumbnail URL containing the correct render view ID and an |
| 96 // arbitrary instant restricted ID. | 97 // arbitrary instant restricted ID. |
| 97 GURL thumbnail_url(base::StringPrintf( | 98 GURL thumbnail_url(base::StringPrintf( |
| 98 "chrome-search:/thumb/%i/1", | 99 "chrome-search:/thumb/%i/1", |
| 99 render_frame->GetRenderView()->GetRoutingID())); | 100 render_frame->GetRenderView()->GetRoutingID())); |
| 100 | 101 |
| 102 std::vector<std::unique_ptr<content::URLLoaderThrottle>> throttles; |
| 101 GURL result; | 103 GURL result; |
| 102 // Make sure the SearchBox rewrites a thumbnail request from the main frame. | 104 // Make sure the SearchBox rewrites a thumbnail request from the main frame. |
| 103 EXPECT_TRUE(client.WillSendRequest(GetMainFrame(), ui::PAGE_TRANSITION_LINK, | 105 EXPECT_TRUE(client.WillSendRequest(GetMainFrame(), ui::PAGE_TRANSITION_LINK, |
| 104 blink::WebURL(thumbnail_url), &result)); | 106 blink::WebURL(thumbnail_url), &throttles, |
| 107 &result)); |
| 105 | 108 |
| 106 // Make sure the SearchBox rewrites a thumbnail request from the iframe. | 109 // Make sure the SearchBox rewrites a thumbnail request from the iframe. |
| 107 blink::WebFrame* child_frame = GetMainFrame()->FirstChild(); | 110 blink::WebFrame* child_frame = GetMainFrame()->FirstChild(); |
| 108 ASSERT_TRUE(child_frame); | 111 ASSERT_TRUE(child_frame); |
| 109 ASSERT_TRUE(child_frame->IsWebLocalFrame()); | 112 ASSERT_TRUE(child_frame->IsWebLocalFrame()); |
| 110 blink::WebLocalFrame* local_child = | 113 blink::WebLocalFrame* local_child = |
| 111 static_cast<blink::WebLocalFrame*>(child_frame); | 114 static_cast<blink::WebLocalFrame*>(child_frame); |
| 112 EXPECT_TRUE(client.WillSendRequest(local_child, ui::PAGE_TRANSITION_LINK, | 115 EXPECT_TRUE(client.WillSendRequest(local_child, ui::PAGE_TRANSITION_LINK, |
| 113 blink::WebURL(thumbnail_url), &result)); | 116 blink::WebURL(thumbnail_url), &throttles, |
| 117 &result)); |
| 114 } | 118 } |
| 115 | 119 |
| 116 // The tests below examine Youtube requests that use the Flash API and ensure | 120 // The tests below examine Youtube requests that use the Flash API and ensure |
| 117 // that the requests have been modified to instead use HTML5. The tests also | 121 // that the requests have been modified to instead use HTML5. The tests also |
| 118 // check the MIME type of the request to ensure that it is "text/html". | 122 // check the MIME type of the request to ensure that it is "text/html". |
| 119 namespace { | 123 namespace { |
| 120 | 124 |
| 121 struct FlashEmbedsTestData { | 125 struct FlashEmbedsTestData { |
| 122 std::string name; | 126 std::string name; |
| 123 std::string host; | 127 std::string host; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 "http://" + GetParam().host + ":" + port + GetParam().path; | 240 "http://" + GetParam().host + ":" + port + GetParam().path; |
| 237 EXPECT_TRUE(ExecuteScript(web_contents, | 241 EXPECT_TRUE(ExecuteScript(web_contents, |
| 238 "appendDataEmbedToDOM('" + video_url + "','" + GetParam().type + "');")); | 242 "appendDataEmbedToDOM('" + video_url + "','" + GetParam().type + "');")); |
| 239 WaitForYouTubeRequest(); | 243 WaitForYouTubeRequest(); |
| 240 } | 244 } |
| 241 | 245 |
| 242 INSTANTIATE_TEST_CASE_P( | 246 INSTANTIATE_TEST_CASE_P( |
| 243 FlashEmbeds, | 247 FlashEmbeds, |
| 244 ChromeContentRendererClientBrowserTest, | 248 ChromeContentRendererClientBrowserTest, |
| 245 ::testing::ValuesIn(kFlashEmbedsTestData)); | 249 ::testing::ValuesIn(kFlashEmbedsTestData)); |
| OLD | NEW |