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

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

Issue 19844003: Remove webkit/plugins/npapi. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove GetDefaultWindowParent Created 7 years, 5 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 "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"
11 #include "content/public/browser/browser_context.h" 11 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/plugin_service_filter.h" 12 #include "content/public/browser/plugin_service_filter.h"
13 #include "content/public/browser/resource_context.h" 13 #include "content/public/browser/resource_context.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "content/public/common/content_switches.h" 15 #include "content/public/common/content_switches.h"
16 #include "content/public/test/test_browser_thread.h" 16 #include "content/public/test/test_browser_thread.h"
17 #include "content/public/test/test_utils.h" 17 #include "content/public/test/test_utils.h"
18 #include "content/shell/shell.h" 18 #include "content/shell/shell.h"
19 #include "content/test/content_browser_test.h" 19 #include "content/test/content_browser_test.h"
20 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "webkit/plugins/npapi/plugin_utils.h"
22 21
23 namespace content { 22 namespace content {
24 23
25 const char kNPAPITestPluginMimeType[] = "application/vnd.npapi-test"; 24 const char kNPAPITestPluginMimeType[] = "application/vnd.npapi-test";
26 25
27 void OpenChannel(PluginProcessHost::Client* client) { 26 void OpenChannel(PluginProcessHost::Client* client) {
28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
29 // Start opening the channel 28 // Start opening the channel
30 PluginServiceImpl::GetInstance()->OpenChannelToNpapiPlugin( 29 PluginServiceImpl::GetInstance()->OpenChannelToNpapiPlugin(
31 0, 0, GURL(), GURL(), kNPAPITestPluginMimeType, client); 30 0, 0, GURL(), GURL(), kNPAPITestPluginMimeType, client);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // running under content_browsertests, these flags won't be needed. 152 // running under content_browsertests, these flags won't be needed.
154 // http://crbug.com/90448 153 // http://crbug.com/90448
155 // switches::kAlwaysAuthorizePlugins 154 // switches::kAlwaysAuthorizePlugins
156 command_line->AppendSwitch("always-authorize-plugins"); 155 command_line->AppendSwitch("always-authorize-plugins");
157 } 156 }
158 }; 157 };
159 158
160 // Try to open a channel to the test plugin. Minimal plugin process spawning 159 // Try to open a channel to the test plugin. Minimal plugin process spawning
161 // test for the PluginService interface. 160 // test for the PluginService interface.
162 IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) { 161 IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) {
163 if (!webkit::npapi::NPAPIPluginsSupported()) 162 if (!PluginServiceImpl::GetInstance()->NPAPIPluginsSupported())
164 return; 163 return;
165 MockPluginProcessHostClient mock_client(GetResourceContext(), false); 164 MockPluginProcessHostClient mock_client(GetResourceContext(), false);
166 BrowserThread::PostTask( 165 BrowserThread::PostTask(
167 BrowserThread::IO, FROM_HERE, 166 BrowserThread::IO, FROM_HERE,
168 base::Bind(&OpenChannel, &mock_client)); 167 base::Bind(&OpenChannel, &mock_client));
169 RunMessageLoop(); 168 RunMessageLoop();
170 } 169 }
171 170
172 IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToDeniedPlugin) { 171 IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToDeniedPlugin) {
173 if (!webkit::npapi::NPAPIPluginsSupported()) 172 if (!PluginServiceImpl::GetInstance()->NPAPIPluginsSupported())
174 return; 173 return;
175 MockPluginServiceFilter filter; 174 MockPluginServiceFilter filter;
176 PluginServiceImpl::GetInstance()->SetFilter(&filter); 175 PluginServiceImpl::GetInstance()->SetFilter(&filter);
177 MockPluginProcessHostClient mock_client(GetResourceContext(), true); 176 MockPluginProcessHostClient mock_client(GetResourceContext(), true);
178 BrowserThread::PostTask( 177 BrowserThread::PostTask(
179 BrowserThread::IO, FROM_HERE, 178 BrowserThread::IO, FROM_HERE,
180 base::Bind(&OpenChannel, &mock_client)); 179 base::Bind(&OpenChannel, &mock_client));
181 RunMessageLoop(); 180 RunMessageLoop();
182 } 181 }
183 182
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 private: 299 private:
301 bool set_plugin_info_called_; 300 bool set_plugin_info_called_;
302 bool on_found_plugin_process_host_called_; 301 bool on_found_plugin_process_host_called_;
303 PluginProcessHost* host_; 302 PluginProcessHost* host_;
304 303
305 DISALLOW_COPY_AND_ASSIGN(MockCanceledBeforeSentPluginProcessHostClient); 304 DISALLOW_COPY_AND_ASSIGN(MockCanceledBeforeSentPluginProcessHostClient);
306 }; 305 };
307 306
308 IN_PROC_BROWSER_TEST_F( 307 IN_PROC_BROWSER_TEST_F(
309 PluginServiceTest, CancelBeforeSentOpenChannelToPluginProcessHost) { 308 PluginServiceTest, CancelBeforeSentOpenChannelToPluginProcessHost) {
310 if (!webkit::npapi::NPAPIPluginsSupported()) 309 if (!PluginServiceImpl::GetInstance()->NPAPIPluginsSupported())
311 return; 310 return;
312 ::testing::StrictMock<MockCanceledBeforeSentPluginProcessHostClient> 311 ::testing::StrictMock<MockCanceledBeforeSentPluginProcessHostClient>
313 mock_client(GetResourceContext()); 312 mock_client(GetResourceContext());
314 BrowserThread::PostTask( 313 BrowserThread::PostTask(
315 BrowserThread::IO, FROM_HERE, 314 BrowserThread::IO, FROM_HERE,
316 base::Bind(&OpenChannel, &mock_client)); 315 base::Bind(&OpenChannel, &mock_client));
317 RunMessageLoop(); 316 RunMessageLoop();
318 EXPECT_TRUE(mock_client.get_resource_context_called()); 317 EXPECT_TRUE(mock_client.get_resource_context_called());
319 EXPECT_TRUE(mock_client.set_plugin_info_called()); 318 EXPECT_TRUE(mock_client.set_plugin_info_called());
320 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called()); 319 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 353
355 private: 354 private:
356 bool on_sent_plugin_channel_request_called_; 355 bool on_sent_plugin_channel_request_called_;
357 356
358 DISALLOW_COPY_AND_ASSIGN(MockCanceledAfterSentPluginProcessHostClient); 357 DISALLOW_COPY_AND_ASSIGN(MockCanceledAfterSentPluginProcessHostClient);
359 }; 358 };
360 359
361 // Should not attempt to open a channel, since it should be canceled early on. 360 // Should not attempt to open a channel, since it should be canceled early on.
362 IN_PROC_BROWSER_TEST_F( 361 IN_PROC_BROWSER_TEST_F(
363 PluginServiceTest, CancelAfterSentOpenChannelToPluginProcessHost) { 362 PluginServiceTest, CancelAfterSentOpenChannelToPluginProcessHost) {
364 if (!webkit::npapi::NPAPIPluginsSupported()) 363 if (!PluginServiceImpl::GetInstance()->NPAPIPluginsSupported())
365 return; 364 return;
366 ::testing::StrictMock<MockCanceledAfterSentPluginProcessHostClient> 365 ::testing::StrictMock<MockCanceledAfterSentPluginProcessHostClient>
367 mock_client(GetResourceContext()); 366 mock_client(GetResourceContext());
368 BrowserThread::PostTask( 367 BrowserThread::PostTask(
369 BrowserThread::IO, FROM_HERE, 368 BrowserThread::IO, FROM_HERE,
370 base::Bind(&OpenChannel, &mock_client)); 369 base::Bind(&OpenChannel, &mock_client));
371 RunMessageLoop(); 370 RunMessageLoop();
372 EXPECT_TRUE(mock_client.get_resource_context_called()); 371 EXPECT_TRUE(mock_client.get_resource_context_called());
373 EXPECT_TRUE(mock_client.set_plugin_info_called()); 372 EXPECT_TRUE(mock_client.set_plugin_info_called());
374 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called()); 373 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called());
375 EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called()); 374 EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called());
376 } 375 }
377 376
378 } // namespace content 377 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698