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

Side by Side Diff: chrome/browser/renderer_host/plugin_info_message_filter_unittest.cc

Issue 12209008: Follow-on fixes and naming changes for https://codereview.chromium.org/12086077/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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.h" 10 #include "base/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/common/render_messages.h" 13 #include "chrome/common/render_messages.h"
14 #include "content/public/browser/plugin_service.h" 14 #include "content/public/browser/plugin_service.h"
15 #include "content/public/browser/plugin_service_filter.h" 15 #include "content/public/browser/plugin_service_filter.h"
16 #include "content/public/test/test_browser_thread.h" 16 #include "content/public/test/test_browser_thread.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "webkit/plugins/npapi/mock_plugin_list.h" 19 #include "webkit/plugins/npapi/mock_plugin_list.h"
20 20
21 using content::PluginService; 21 using content::PluginService;
22 22
23 namespace { 23 namespace {
24 24
25 class FakePluginServiceFilter : public content::PluginServiceFilter { 25 class FakePluginServiceFilter : public content::PluginServiceFilter {
26 public: 26 public:
27 FakePluginServiceFilter() {} 27 FakePluginServiceFilter() {}
28 virtual ~FakePluginServiceFilter() {} 28 virtual ~FakePluginServiceFilter() {}
29 29
30 virtual bool IsPluginEnabled(int render_process_id, 30 virtual bool IsPluginAvailable(int render_process_id,
31 int render_view_id, 31 int render_view_id,
32 const void* context, 32 const void* context,
33 const GURL& url, 33 const GURL& url,
34 const GURL& policy_url, 34 const GURL& policy_url,
35 webkit::WebPluginInfo* plugin) OVERRIDE; 35 webkit::WebPluginInfo* plugin) OVERRIDE;
36 36
37 virtual bool CanLoadPlugin(int render_process_id, 37 virtual bool CanLoadPlugin(int render_process_id,
38 const FilePath& path) OVERRIDE; 38 const FilePath& path) OVERRIDE;
39 39
40 void set_plugin_enabled(const FilePath& plugin_path, bool enabled) { 40 void set_plugin_enabled(const FilePath& plugin_path, bool enabled) {
41 plugin_state_[plugin_path] = enabled; 41 plugin_state_[plugin_path] = enabled;
42 } 42 }
43 43
44 private: 44 private:
45 std::map<FilePath, bool> plugin_state_; 45 std::map<FilePath, bool> plugin_state_;
46 }; 46 };
47 47
48 bool FakePluginServiceFilter::IsPluginEnabled(int render_process_id, 48 bool FakePluginServiceFilter::IsPluginAvailable(int render_process_id,
49 int render_view_id, 49 int render_view_id,
50 const void* context, 50 const void* context,
51 const GURL& url, 51 const GURL& url,
52 const GURL& policy_url, 52 const GURL& policy_url,
53 webkit::WebPluginInfo* plugin) { 53 webkit::WebPluginInfo* plugin) {
54 std::map<FilePath, bool>::iterator it = plugin_state_.find(plugin->path); 54 std::map<FilePath, bool>::iterator it = plugin_state_.find(plugin->path);
55 if (it == plugin_state_.end()) { 55 if (it == plugin_state_.end()) {
56 ADD_FAILURE() << "No plug-in state for '" << plugin->path.value() << "'"; 56 ADD_FAILURE() << "No plug-in state for '" << plugin->path.value() << "'";
57 return false; 57 return false;
58 } 58 }
59 return it->second; 59 return it->second;
60 } 60 }
61 61
62 bool FakePluginServiceFilter::CanLoadPlugin(int render_process_id, 62 bool FakePluginServiceFilter::CanLoadPlugin(int render_process_id,
63 const FilePath& path) { 63 const FilePath& path) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 ChromeViewHostMsg_GetPluginInfo_Status status; 164 ChromeViewHostMsg_GetPluginInfo_Status status;
165 webkit::WebPluginInfo plugin; 165 webkit::WebPluginInfo plugin;
166 std::string actual_mime_type; 166 std::string actual_mime_type;
167 EXPECT_FALSE(context_.FindEnabledPlugin( 167 EXPECT_FALSE(context_.FindEnabledPlugin(
168 0, GURL(), GURL(), "baz/blurp", &status, &plugin, &actual_mime_type, 168 0, GURL(), GURL(), "baz/blurp", &status, &plugin, &actual_mime_type,
169 NULL)); 169 NULL));
170 EXPECT_EQ(ChromeViewHostMsg_GetPluginInfo_Status::kNotFound, status.value); 170 EXPECT_EQ(ChromeViewHostMsg_GetPluginInfo_Status::kNotFound, status.value);
171 EXPECT_EQ(FILE_PATH_LITERAL(""), plugin.path.value()); 171 EXPECT_EQ(FILE_PATH_LITERAL(""), plugin.path.value());
172 } 172 }
173 } 173 }
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_info_message_filter.cc ('k') | content/browser/plugin_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698