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

Side by Side Diff: content/browser/plugin_service_impl_browsertest.cc

Issue 637183002: Replace FINAL and OVERRIDE with their C++11 counterparts in content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased the patch Created 6 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 (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 "content/browser/plugin_service_impl.h" 5 #include "content/browser/plugin_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 30 matching lines...) Expand all
41 set_plugin_info_called_(false), 41 set_plugin_info_called_(false),
42 expect_fail_(expect_fail) { 42 expect_fail_(expect_fail) {
43 } 43 }
44 44
45 virtual ~MockPluginProcessHostClient() { 45 virtual ~MockPluginProcessHostClient() {
46 if (channel_) 46 if (channel_)
47 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, channel_); 47 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, channel_);
48 } 48 }
49 49
50 // PluginProcessHost::Client implementation. 50 // PluginProcessHost::Client implementation.
51 virtual int ID() OVERRIDE { return 42; } 51 virtual int ID() override { return 42; }
52 virtual bool OffTheRecord() OVERRIDE { return false; } 52 virtual bool OffTheRecord() override { return false; }
53 virtual ResourceContext* GetResourceContext() OVERRIDE { 53 virtual ResourceContext* GetResourceContext() override {
54 return context_; 54 return context_;
55 } 55 }
56 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE {} 56 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) override {}
57 virtual void OnSentPluginChannelRequest() OVERRIDE {} 57 virtual void OnSentPluginChannelRequest() override {}
58 58
59 virtual void OnChannelOpened(const IPC::ChannelHandle& handle) OVERRIDE { 59 virtual void OnChannelOpened(const IPC::ChannelHandle& handle) override {
60 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); 60 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
61 ASSERT_TRUE(set_plugin_info_called_); 61 ASSERT_TRUE(set_plugin_info_called_);
62 ASSERT_TRUE(!channel_); 62 ASSERT_TRUE(!channel_);
63 channel_ = IPC::Channel::CreateClient(handle, this).release(); 63 channel_ = IPC::Channel::CreateClient(handle, this).release();
64 ASSERT_TRUE(channel_->Connect()); 64 ASSERT_TRUE(channel_->Connect());
65 } 65 }
66 66
67 virtual void SetPluginInfo(const WebPluginInfo& info) OVERRIDE { 67 virtual void SetPluginInfo(const WebPluginInfo& info) override {
68 ASSERT_TRUE(info.mime_types.size()); 68 ASSERT_TRUE(info.mime_types.size());
69 ASSERT_EQ(kNPAPITestPluginMimeType, info.mime_types[0].mime_type); 69 ASSERT_EQ(kNPAPITestPluginMimeType, info.mime_types[0].mime_type);
70 set_plugin_info_called_ = true; 70 set_plugin_info_called_ = true;
71 } 71 }
72 72
73 virtual void OnError() OVERRIDE { 73 virtual void OnError() override {
74 Fail(); 74 Fail();
75 } 75 }
76 76
77 // IPC::Listener implementation. 77 // IPC::Listener implementation.
78 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { 78 virtual bool OnMessageReceived(const IPC::Message& message) override {
79 Fail(); 79 Fail();
80 return false; 80 return false;
81 } 81 }
82 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE { 82 virtual void OnChannelConnected(int32 peer_pid) override {
83 if (expect_fail_) 83 if (expect_fail_)
84 FAIL(); 84 FAIL();
85 QuitMessageLoop(); 85 QuitMessageLoop();
86 } 86 }
87 virtual void OnChannelError() OVERRIDE { 87 virtual void OnChannelError() override {
88 Fail(); 88 Fail();
89 } 89 }
90 #if defined(OS_POSIX) 90 #if defined(OS_POSIX)
91 virtual void OnChannelDenied() OVERRIDE { 91 virtual void OnChannelDenied() override {
92 Fail(); 92 Fail();
93 } 93 }
94 virtual void OnChannelListenError() OVERRIDE { 94 virtual void OnChannelListenError() override {
95 Fail(); 95 Fail();
96 } 96 }
97 #endif 97 #endif
98 98
99 private: 99 private:
100 void Fail() { 100 void Fail() {
101 if (!expect_fail_) 101 if (!expect_fail_)
102 FAIL(); 102 FAIL();
103 QuitMessageLoop(); 103 QuitMessageLoop();
104 } 104 }
(...skipping 13 matching lines...) Expand all
118 class MockPluginServiceFilter : public content::PluginServiceFilter { 118 class MockPluginServiceFilter : public content::PluginServiceFilter {
119 public: 119 public:
120 MockPluginServiceFilter() {} 120 MockPluginServiceFilter() {}
121 121
122 virtual bool IsPluginAvailable( 122 virtual bool IsPluginAvailable(
123 int render_process_id, 123 int render_process_id,
124 int render_view_id, 124 int render_view_id,
125 const void* context, 125 const void* context,
126 const GURL& url, 126 const GURL& url,
127 const GURL& policy_url, 127 const GURL& policy_url,
128 WebPluginInfo* plugin) OVERRIDE { return true; } 128 WebPluginInfo* plugin) override { return true; }
129 129
130 virtual bool CanLoadPlugin( 130 virtual bool CanLoadPlugin(
131 int render_process_id, 131 int render_process_id,
132 const base::FilePath& path) OVERRIDE { return false; } 132 const base::FilePath& path) override { return false; }
133 }; 133 };
134 134
135 class PluginServiceTest : public ContentBrowserTest { 135 class PluginServiceTest : public ContentBrowserTest {
136 public: 136 public:
137 PluginServiceTest() {} 137 PluginServiceTest() {}
138 138
139 ResourceContext* GetResourceContext() { 139 ResourceContext* GetResourceContext() {
140 return shell()->web_contents()->GetBrowserContext()->GetResourceContext(); 140 return shell()->web_contents()->GetBrowserContext()->GetResourceContext();
141 } 141 }
142 142
143 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 143 virtual void SetUpCommandLine(CommandLine* command_line) override {
144 #if defined(OS_MACOSX) 144 #if defined(OS_MACOSX)
145 base::FilePath browser_directory; 145 base::FilePath browser_directory;
146 PathService::Get(base::DIR_MODULE, &browser_directory); 146 PathService::Get(base::DIR_MODULE, &browser_directory);
147 command_line->AppendSwitchPath(switches::kExtraPluginDir, 147 command_line->AppendSwitchPath(switches::kExtraPluginDir,
148 browser_directory.AppendASCII("plugins")); 148 browser_directory.AppendASCII("plugins"));
149 #endif 149 #endif
150 // TODO(jam): since these plugin tests are running under Chrome, we need to 150 // TODO(jam): since these plugin tests are running under Chrome, we need to
151 // tell it to disable its security features for old plugins. Once this is 151 // tell it to disable its security features for old plugins. Once this is
152 // running under content_browsertests, these flags won't be needed. 152 // running under content_browsertests, these flags won't be needed.
153 // http://crbug.com/90448 153 // http://crbug.com/90448
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 public: 186 public:
187 MockCanceledPluginServiceClient(ResourceContext* context) 187 MockCanceledPluginServiceClient(ResourceContext* context)
188 : context_(context), 188 : context_(context),
189 get_resource_context_called_(false) { 189 get_resource_context_called_(false) {
190 } 190 }
191 191
192 virtual ~MockCanceledPluginServiceClient() {} 192 virtual ~MockCanceledPluginServiceClient() {}
193 193
194 // Client implementation. 194 // Client implementation.
195 MOCK_METHOD0(ID, int()); 195 MOCK_METHOD0(ID, int());
196 virtual ResourceContext* GetResourceContext() OVERRIDE { 196 virtual ResourceContext* GetResourceContext() override {
197 get_resource_context_called_ = true; 197 get_resource_context_called_ = true;
198 return context_; 198 return context_;
199 } 199 }
200 MOCK_METHOD0(OffTheRecord, bool()); 200 MOCK_METHOD0(OffTheRecord, bool());
201 MOCK_METHOD1(OnFoundPluginProcessHost, void(PluginProcessHost* host)); 201 MOCK_METHOD1(OnFoundPluginProcessHost, void(PluginProcessHost* host));
202 MOCK_METHOD0(OnSentPluginChannelRequest, void()); 202 MOCK_METHOD0(OnSentPluginChannelRequest, void());
203 MOCK_METHOD1(OnChannelOpened, void(const IPC::ChannelHandle& handle)); 203 MOCK_METHOD1(OnChannelOpened, void(const IPC::ChannelHandle& handle));
204 MOCK_METHOD1(SetPluginInfo, void(const WebPluginInfo& info)); 204 MOCK_METHOD1(SetPluginInfo, void(const WebPluginInfo& info));
205 MOCK_METHOD0(OnError, void()); 205 MOCK_METHOD0(OnError, void());
206 206
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 MockCanceledBeforeSentPluginProcessHostClient( 250 MockCanceledBeforeSentPluginProcessHostClient(
251 ResourceContext* context) 251 ResourceContext* context)
252 : MockCanceledPluginServiceClient(context), 252 : MockCanceledPluginServiceClient(context),
253 set_plugin_info_called_(false), 253 set_plugin_info_called_(false),
254 on_found_plugin_process_host_called_(false), 254 on_found_plugin_process_host_called_(false),
255 host_(NULL) {} 255 host_(NULL) {}
256 256
257 virtual ~MockCanceledBeforeSentPluginProcessHostClient() {} 257 virtual ~MockCanceledBeforeSentPluginProcessHostClient() {}
258 258
259 // Client implementation. 259 // Client implementation.
260 virtual void SetPluginInfo(const WebPluginInfo& info) OVERRIDE { 260 virtual void SetPluginInfo(const WebPluginInfo& info) override {
261 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 261 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
262 ASSERT_TRUE(info.mime_types.size()); 262 ASSERT_TRUE(info.mime_types.size());
263 ASSERT_EQ(kNPAPITestPluginMimeType, info.mime_types[0].mime_type); 263 ASSERT_EQ(kNPAPITestPluginMimeType, info.mime_types[0].mime_type);
264 set_plugin_info_called_ = true; 264 set_plugin_info_called_ = true;
265 } 265 }
266 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE { 266 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) override {
267 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 267 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
268 set_on_found_plugin_process_host_called(); 268 set_on_found_plugin_process_host_called();
269 set_host(host); 269 set_host(host);
270 // This gets called right before we request the plugin<=>renderer channel, 270 // This gets called right before we request the plugin<=>renderer channel,
271 // so we have to post a task to cancel it. 271 // so we have to post a task to cancel it.
272 base::MessageLoop::current()->PostTask( 272 base::MessageLoop::current()->PostTask(
273 FROM_HERE, 273 FROM_HERE,
274 base::Bind(&PluginProcessHost::CancelPendingRequest, 274 base::Bind(&PluginProcessHost::CancelPendingRequest,
275 base::Unretained(host), 275 base::Unretained(host),
276 this)); 276 this));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 : public MockCanceledBeforeSentPluginProcessHostClient { 323 : public MockCanceledBeforeSentPluginProcessHostClient {
324 public: 324 public:
325 MockCanceledAfterSentPluginProcessHostClient( 325 MockCanceledAfterSentPluginProcessHostClient(
326 ResourceContext* context) 326 ResourceContext* context)
327 : MockCanceledBeforeSentPluginProcessHostClient(context), 327 : MockCanceledBeforeSentPluginProcessHostClient(context),
328 on_sent_plugin_channel_request_called_(false) {} 328 on_sent_plugin_channel_request_called_(false) {}
329 virtual ~MockCanceledAfterSentPluginProcessHostClient() {} 329 virtual ~MockCanceledAfterSentPluginProcessHostClient() {}
330 330
331 // Client implementation. 331 // Client implementation.
332 332
333 virtual int ID() OVERRIDE { return 42; } 333 virtual int ID() override { return 42; }
334 virtual bool OffTheRecord() OVERRIDE { return false; } 334 virtual bool OffTheRecord() override { return false; }
335 335
336 // We override this guy again since we don't want to cancel yet. 336 // We override this guy again since we don't want to cancel yet.
337 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) OVERRIDE { 337 virtual void OnFoundPluginProcessHost(PluginProcessHost* host) override {
338 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 338 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
339 set_on_found_plugin_process_host_called(); 339 set_on_found_plugin_process_host_called();
340 set_host(host); 340 set_host(host);
341 } 341 }
342 342
343 virtual void OnSentPluginChannelRequest() OVERRIDE { 343 virtual void OnSentPluginChannelRequest() override {
344 on_sent_plugin_channel_request_called_ = true; 344 on_sent_plugin_channel_request_called_ = true;
345 host()->CancelSentRequest(this); 345 host()->CancelSentRequest(this);
346 BrowserThread::PostTask( 346 BrowserThread::PostTask(
347 BrowserThread::UI, FROM_HERE, base::MessageLoop::QuitClosure()); 347 BrowserThread::UI, FROM_HERE, base::MessageLoop::QuitClosure());
348 } 348 }
349 349
350 bool on_sent_plugin_channel_request_called() const { 350 bool on_sent_plugin_channel_request_called() const {
351 return on_sent_plugin_channel_request_called_; 351 return on_sent_plugin_channel_request_called_;
352 } 352 }
353 353
(...skipping 14 matching lines...) Expand all
368 BrowserThread::IO, FROM_HERE, 368 BrowserThread::IO, FROM_HERE,
369 base::Bind(&OpenChannel, &mock_client)); 369 base::Bind(&OpenChannel, &mock_client));
370 RunMessageLoop(); 370 RunMessageLoop();
371 EXPECT_TRUE(mock_client.get_resource_context_called()); 371 EXPECT_TRUE(mock_client.get_resource_context_called());
372 EXPECT_TRUE(mock_client.set_plugin_info_called()); 372 EXPECT_TRUE(mock_client.set_plugin_info_called());
373 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called()); 373 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called());
374 EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called()); 374 EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called());
375 } 375 }
376 376
377 } // namespace content 377 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/plugin_service_impl.h ('k') | content/browser/power_monitor_message_broadcaster.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698