Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1022)

Side by Side Diff: content/browser/loader/mime_sniffing_resource_handler_unittest.cc

Issue 2378573005: [HBD] Blanket BLOCK on all non-HTTP(s) and non-FILE URLs for Flash. (Closed)
Patch Set: Done, though it's insane Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/loader/mime_sniffing_resource_handler.h" 5 #include "content/browser/loader/mime_sniffing_resource_handler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "content/browser/loader/intercepting_resource_handler.h" 17 #include "content/browser/loader/intercepting_resource_handler.h"
18 #include "content/browser/loader/resource_dispatcher_host_impl.h" 18 #include "content/browser/loader/resource_dispatcher_host_impl.h"
19 #include "content/public/browser/resource_controller.h" 19 #include "content/public/browser/resource_controller.h"
20 #include "content/public/browser/resource_dispatcher_host_delegate.h" 20 #include "content/public/browser/resource_dispatcher_host_delegate.h"
21 #include "content/public/browser/resource_request_info.h" 21 #include "content/public/browser/resource_request_info.h"
22 #include "content/public/common/resource_response.h" 22 #include "content/public/common/resource_response.h"
23 #include "content/public/common/webplugininfo.h" 23 #include "content/public/common/webplugininfo.h"
24 #include "content/public/test/test_browser_thread_bundle.h" 24 #include "content/public/test/test_browser_thread_bundle.h"
25 #include "content/public/test/test_utils.h" 25 #include "content/public/test/test_utils.h"
26 #include "content/test/fake_plugin_service.h" 26 #include "content/test/fake_plugin_service.h"
27 #include "net/url_request/url_request_context.h" 27 #include "net/url_request/url_request_context.h"
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
29 #include "url/gurl.h" 29 #include "url/gurl.h"
30 #include "url/origin.h"
30 31
31 namespace content { 32 namespace content {
32 33
33 namespace { 34 namespace {
34 35
35 class TestResourceHandler : public ResourceHandler { 36 class TestResourceHandler : public ResourceHandler {
36 public: 37 public:
37 TestResourceHandler(bool response_started_succeeds, 38 TestResourceHandler(bool response_started_succeeds,
38 bool defer_on_response_started, 39 bool defer_on_response_started,
39 bool will_read_succeeds, 40 bool will_read_succeeds,
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // If |is_plugin_stale| is true, GetPluginInfo will indicate the plugins are 203 // If |is_plugin_stale| is true, GetPluginInfo will indicate the plugins are
203 // stale until GetPlugins is called. 204 // stale until GetPlugins is called.
204 TestFakePluginService(bool plugin_available, bool is_plugin_stale) 205 TestFakePluginService(bool plugin_available, bool is_plugin_stale)
205 : plugin_available_(plugin_available), 206 : plugin_available_(plugin_available),
206 is_plugin_stale_(is_plugin_stale) {} 207 is_plugin_stale_(is_plugin_stale) {}
207 208
208 bool GetPluginInfo(int render_process_id, 209 bool GetPluginInfo(int render_process_id,
209 int render_frame_id, 210 int render_frame_id,
210 ResourceContext* context, 211 ResourceContext* context,
211 const GURL& url, 212 const GURL& url,
212 const GURL& page_url, 213 const url::Origin& page_url,
213 const std::string& mime_type, 214 const std::string& mime_type,
214 bool allow_wildcard, 215 bool allow_wildcard,
215 bool* is_stale, 216 bool* is_stale,
216 WebPluginInfo* info, 217 WebPluginInfo* info,
217 std::string* actual_mime_type) override { 218 std::string* actual_mime_type) override {
218 *is_stale = is_plugin_stale_; 219 *is_stale = is_plugin_stale_;
219 if (!is_plugin_stale_ || !plugin_available_) 220 if (!is_plugin_stale_ || !plugin_available_)
220 return false; 221 return false;
221 info->type = WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN; 222 info->type = WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN;
222 info->path = base::FilePath::FromUTF8Unsafe( 223 info->path = base::FilePath::FromUTF8Unsafe(
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 // mime sniffing is disabled and the wrapped resource handler returns false 1063 // mime sniffing is disabled and the wrapped resource handler returns false
1063 // on OnResponseStarted. 1064 // on OnResponseStarted.
1064 EXPECT_FALSE( 1065 EXPECT_FALSE(
1065 mime_sniffing_handler->OnResponseStarted(response.get(), &defer)); 1066 mime_sniffing_handler->OnResponseStarted(response.get(), &defer));
1066 1067
1067 // Process all messages to ensure proper test teardown. 1068 // Process all messages to ensure proper test teardown.
1068 content::RunAllPendingInMessageLoop(); 1069 content::RunAllPendingInMessageLoop();
1069 } 1070 }
1070 1071
1071 } // namespace content 1072 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698