OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "chrome/browser/browser_thread.h" | 10 #include "chrome/browser/browser_thread.h" |
11 #include "chrome/browser/child_process_security_policy.h" | 11 #include "chrome/browser/child_process_security_policy.h" |
12 #include "chrome/common/chrome_plugin_lib.h" | |
13 #include "chrome/common/render_messages.h" | 12 #include "chrome/common/render_messages.h" |
14 #include "chrome/common/render_messages_params.h" | 13 #include "chrome/common/render_messages_params.h" |
15 #include "chrome/common/resource_response.h" | 14 #include "chrome/common/resource_response.h" |
16 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 15 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
17 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 16 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
18 #include "content/browser/renderer_host/resource_handler.h" | 17 #include "content/browser/renderer_host/resource_handler.h" |
19 #include "content/browser/renderer_host/resource_message_filter.h" | 18 #include "content/browser/renderer_host/resource_message_filter.h" |
20 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
21 #include "net/base/upload_data.h" | 20 #include "net/base/upload_data.h" |
22 #include "net/http/http_util.h" | 21 #include "net/http/http_util.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 ViewHostMsg_Resource_Request request; | 67 ViewHostMsg_Resource_Request request; |
69 request.method = std::string(method); | 68 request.method = std::string(method); |
70 request.url = url; | 69 request.url = url; |
71 request.first_party_for_cookies = url; // bypass third-party cookie blocking | 70 request.first_party_for_cookies = url; // bypass third-party cookie blocking |
72 request.load_flags = 0; | 71 request.load_flags = 0; |
73 request.origin_pid = 0; | 72 request.origin_pid = 0; |
74 request.resource_type = type; | 73 request.resource_type = type; |
75 request.request_context = 0; | 74 request.request_context = 0; |
76 request.appcache_host_id = appcache::kNoHostId; | 75 request.appcache_host_id = appcache::kNoHostId; |
77 request.download_to_file = false; | 76 request.download_to_file = false; |
78 request.host_renderer_id = -1; | |
79 request.host_render_view_id = -1; | |
80 return request; | 77 return request; |
81 } | 78 } |
82 | 79 |
83 // Spin up the message loop to kick off the request. | 80 // Spin up the message loop to kick off the request. |
84 static void KickOffRequest() { | 81 static void KickOffRequest() { |
85 MessageLoop::current()->RunAllPending(); | 82 MessageLoop::current()->RunAllPending(); |
86 } | 83 } |
87 | 84 |
88 // We may want to move this to a shared space if it is useful for something else | 85 // We may want to move this to a shared space if it is useful for something else |
89 class ResourceIPCAccumulator { | 86 class ResourceIPCAccumulator { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 if (!scheme_.empty()) | 182 if (!scheme_.empty()) |
186 net::URLRequest::RegisterProtocolFactory(scheme_, old_factory_); | 183 net::URLRequest::RegisterProtocolFactory(scheme_, old_factory_); |
187 | 184 |
188 DCHECK(test_fixture_ == this); | 185 DCHECK(test_fixture_ == this); |
189 test_fixture_ = NULL; | 186 test_fixture_ = NULL; |
190 | 187 |
191 host_.Shutdown(); | 188 host_.Shutdown(); |
192 | 189 |
193 ChildProcessSecurityPolicy::GetInstance()->Remove(0); | 190 ChildProcessSecurityPolicy::GetInstance()->Remove(0); |
194 | 191 |
195 // The plugin lib is automatically loaded during these test | |
196 // and we want a clean environment for other tests. | |
197 ChromePluginLib::UnloadAllPlugins(); | |
198 | |
199 // Flush the message loop to make Purify happy. | 192 // Flush the message loop to make Purify happy. |
200 message_loop_.RunAllPending(); | 193 message_loop_.RunAllPending(); |
201 } | 194 } |
202 | 195 |
203 // Creates a request using the current test object as the filter. | 196 // Creates a request using the current test object as the filter. |
204 void MakeTestRequest(int render_view_id, | 197 void MakeTestRequest(int render_view_id, |
205 int request_id, | 198 int request_id, |
206 const GURL& url); | 199 const GURL& url); |
207 | 200 |
208 // Generates a request using the given filter. This will probably be a | 201 // Generates a request using the given filter. This will probably be a |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 EXPECT_TRUE(request_info_->replace_extension_localization_templates()); | 1010 EXPECT_TRUE(request_info_->replace_extension_localization_templates()); |
1018 } | 1011 } |
1019 | 1012 |
1020 TEST_F(ApplyExtensionLocalizationFilterTest, GoodSchemeWrongResourceType) { | 1013 TEST_F(ApplyExtensionLocalizationFilterTest, GoodSchemeWrongResourceType) { |
1021 resource_type_ = ResourceType::MAIN_FRAME; | 1014 resource_type_ = ResourceType::MAIN_FRAME; |
1022 ResourceDispatcherHost::ApplyExtensionLocalizationFilter(*url_, | 1015 ResourceDispatcherHost::ApplyExtensionLocalizationFilter(*url_, |
1023 resource_type_, request_info_.get()); | 1016 resource_type_, request_info_.get()); |
1024 | 1017 |
1025 EXPECT_FALSE(request_info_->replace_extension_localization_templates()); | 1018 EXPECT_FALSE(request_info_->replace_extension_localization_templates()); |
1026 } | 1019 } |
OLD | NEW |