Chromium Code Reviews| 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/browser/search/iframe_source.h" | 5 #include "chrome/browser/search/iframe_source.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "chrome/browser/search/instant_io_context.h" | 12 #include "chrome/browser/search/instant_io_context.h" |
| 13 #include "chrome/grit/browser_resources.h" | 13 #include "chrome/grit/browser_resources.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/resource_request_info.h" | 15 #include "content/public/browser/resource_request_info.h" |
| 16 #include "content/public/common/previews_state.h" | |
| 16 #include "content/public/test/mock_resource_context.h" | 17 #include "content/public/test/mock_resource_context.h" |
| 17 #include "content/public/test/test_browser_thread_bundle.h" | 18 #include "content/public/test/test_browser_thread_bundle.h" |
| 18 #include "ipc/ipc_message.h" | 19 #include "ipc/ipc_message.h" |
| 19 #include "net/base/request_priority.h" | 20 #include "net/base/request_priority.h" |
| 20 #include "net/url_request/url_request.h" | 21 #include "net/url_request/url_request.h" |
| 21 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
| 22 #include "net/url_request/url_request_test_util.h" | 23 #include "net/url_request/url_request_test_util.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 25 | 26 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 std::unique_ptr<net::URLRequest> request( | 95 std::unique_ptr<net::URLRequest> request( |
| 95 resource_context_.GetRequestContext()->CreateRequest( | 96 resource_context_.GetRequestContext()->CreateRequest( |
| 96 GURL(url), net::DEFAULT_PRIORITY, NULL)); | 97 GURL(url), net::DEFAULT_PRIORITY, NULL)); |
| 97 content::ResourceRequestInfo::AllocateForTesting( | 98 content::ResourceRequestInfo::AllocateForTesting( |
| 98 request.get(), | 99 request.get(), |
| 99 content::RESOURCE_TYPE_SUB_FRAME, | 100 content::RESOURCE_TYPE_SUB_FRAME, |
| 100 &resource_context_, | 101 &resource_context_, |
| 101 render_process_id, | 102 render_process_id, |
| 102 MSG_ROUTING_NONE, | 103 MSG_ROUTING_NONE, |
| 103 MSG_ROUTING_NONE, | 104 MSG_ROUTING_NONE, |
| 104 false, // is_main_frame | 105 false, // is_main_frame |
| 105 false, // parent_is_main_frame | 106 false, // parent_is_main_frame |
| 106 true, // allow_download | 107 true, // allow_download |
| 107 false, // is_async | 108 false, // is_async |
| 108 false); // is_using_lofi | 109 content::PREVIEWS_OFF); // previews_state |
|
Nico
2017/01/09 22:35:03
ditto
megjablon
2017/01/10 22:30:01
Done.
| |
| 109 return request; | 110 return request; |
| 110 } | 111 } |
| 111 | 112 |
| 112 void SendResource(int resource_id) { | 113 void SendResource(int resource_id) { |
| 113 source()->SendResource(resource_id, callback_); | 114 source()->SendResource(resource_id, callback_); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void SendJSWithOrigin(int resource_id) { | 117 void SendJSWithOrigin(int resource_id) { |
| 117 source()->SendJSWithOrigin( | 118 source()->SendJSWithOrigin( |
| 118 resource_id, content::ResourceRequestInfo::WebContentsGetter(), | 119 resource_id, content::ResourceRequestInfo::WebContentsGetter(), |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 source()->set_origin(kInstantOrigin); | 190 source()->set_origin(kInstantOrigin); |
| 190 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS); | 191 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS); |
| 191 EXPECT_FALSE(response_string().empty()); | 192 EXPECT_FALSE(response_string().empty()); |
| 192 source()->set_origin(kNonInstantOrigin); | 193 source()->set_origin(kNonInstantOrigin); |
| 193 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS); | 194 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS); |
| 194 EXPECT_FALSE(response_string().empty()); | 195 EXPECT_FALSE(response_string().empty()); |
| 195 source()->set_origin(std::string()); | 196 source()->set_origin(std::string()); |
| 196 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS); | 197 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS); |
| 197 EXPECT_TRUE(response_string().empty()); | 198 EXPECT_TRUE(response_string().empty()); |
| 198 } | 199 } |
| OLD | NEW |