OLD | NEW |
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 "chrome/browser/plugins/plugin_info_message_filter.h" | 5 #include "chrome/browser/plugins/plugin_info_message_filter.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 class FakePluginServiceFilter : public content::PluginServiceFilter { | 34 class FakePluginServiceFilter : public content::PluginServiceFilter { |
35 public: | 35 public: |
36 FakePluginServiceFilter() {} | 36 FakePluginServiceFilter() {} |
37 virtual ~FakePluginServiceFilter() {} | 37 virtual ~FakePluginServiceFilter() {} |
38 | 38 |
39 virtual bool IsPluginAvailable(int render_process_id, | 39 virtual bool IsPluginAvailable(int render_process_id, |
40 int render_view_id, | 40 int render_view_id, |
41 const void* context, | 41 const void* context, |
42 const GURL& url, | 42 const GURL& url, |
43 const GURL& policy_url, | 43 const GURL& policy_url, |
44 content::WebPluginInfo* plugin) OVERRIDE; | 44 content::WebPluginInfo* plugin) override; |
45 | 45 |
46 virtual bool CanLoadPlugin(int render_process_id, | 46 virtual bool CanLoadPlugin(int render_process_id, |
47 const base::FilePath& path) OVERRIDE; | 47 const base::FilePath& path) override; |
48 | 48 |
49 void set_plugin_enabled(const base::FilePath& plugin_path, bool enabled) { | 49 void set_plugin_enabled(const base::FilePath& plugin_path, bool enabled) { |
50 plugin_state_[plugin_path] = enabled; | 50 plugin_state_[plugin_path] = enabled; |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 std::map<base::FilePath, bool> plugin_state_; | 54 std::map<base::FilePath, bool> plugin_state_; |
55 }; | 55 }; |
56 | 56 |
57 bool FakePluginServiceFilter::IsPluginAvailable( | 57 bool FakePluginServiceFilter::IsPluginAvailable( |
(...skipping 20 matching lines...) Expand all Loading... |
78 } // namespace | 78 } // namespace |
79 | 79 |
80 class PluginInfoMessageFilterTest : public ::testing::Test { | 80 class PluginInfoMessageFilterTest : public ::testing::Test { |
81 public: | 81 public: |
82 PluginInfoMessageFilterTest() : | 82 PluginInfoMessageFilterTest() : |
83 foo_plugin_path_(FILE_PATH_LITERAL("/path/to/foo")), | 83 foo_plugin_path_(FILE_PATH_LITERAL("/path/to/foo")), |
84 bar_plugin_path_(FILE_PATH_LITERAL("/path/to/bar")), | 84 bar_plugin_path_(FILE_PATH_LITERAL("/path/to/bar")), |
85 context_(0, &profile_) { | 85 context_(0, &profile_) { |
86 } | 86 } |
87 | 87 |
88 virtual void SetUp() OVERRIDE { | 88 virtual void SetUp() override { |
89 content::WebPluginInfo foo_plugin(base::ASCIIToUTF16("Foo Plug-in"), | 89 content::WebPluginInfo foo_plugin(base::ASCIIToUTF16("Foo Plug-in"), |
90 foo_plugin_path_, | 90 foo_plugin_path_, |
91 base::ASCIIToUTF16("1"), | 91 base::ASCIIToUTF16("1"), |
92 base::ASCIIToUTF16("The Foo plug-in.")); | 92 base::ASCIIToUTF16("The Foo plug-in.")); |
93 content::WebPluginMimeType mime_type; | 93 content::WebPluginMimeType mime_type; |
94 mime_type.mime_type = "foo/bar"; | 94 mime_type.mime_type = "foo/bar"; |
95 foo_plugin.mime_types.push_back(mime_type); | 95 foo_plugin.mime_types.push_back(mime_type); |
96 foo_plugin.type = content::WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS; | 96 foo_plugin.type = content::WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS; |
97 PluginService::GetInstance()->Init(); | 97 PluginService::GetInstance()->Init(); |
98 PluginService::GetInstance()->RegisterInternalPlugin(foo_plugin, false); | 98 PluginService::GetInstance()->RegisterInternalPlugin(foo_plugin, false); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 TestingPrefServiceSyncable* prefs = profile()->GetTestingPrefService(); | 259 TestingPrefServiceSyncable* prefs = profile()->GetTestingPrefService(); |
260 prefs->SetManagedPref(prefs::kManagedDefaultPluginsSetting, | 260 prefs->SetManagedPref(prefs::kManagedDefaultPluginsSetting, |
261 new base::FundamentalValue(CONTENT_SETTING_BLOCK)); | 261 new base::FundamentalValue(CONTENT_SETTING_BLOCK)); |
262 | 262 |
263 // All plugins should be blocked now. | 263 // All plugins should be blocked now. |
264 VerifyPluginContentSetting(host, "foo", CONTENT_SETTING_BLOCK, true, true); | 264 VerifyPluginContentSetting(host, "foo", CONTENT_SETTING_BLOCK, true, true); |
265 VerifyPluginContentSetting(host, "bar", CONTENT_SETTING_BLOCK, true, true); | 265 VerifyPluginContentSetting(host, "bar", CONTENT_SETTING_BLOCK, true, true); |
266 VerifyPluginContentSetting(unmatched_host, "bar", CONTENT_SETTING_BLOCK, | 266 VerifyPluginContentSetting(unmatched_host, "bar", CONTENT_SETTING_BLOCK, |
267 true, true); | 267 true, true); |
268 } | 268 } |
OLD | NEW |