OLD | NEW |
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 public: | 115 public: |
116 PluginServiceTest() : InProcessBrowserTest() { } | 116 PluginServiceTest() : InProcessBrowserTest() { } |
117 | 117 |
118 virtual void SetUpCommandLine(CommandLine* command_line) { | 118 virtual void SetUpCommandLine(CommandLine* command_line) { |
119 #ifdef OS_MACOSX | 119 #ifdef OS_MACOSX |
120 FilePath browser_directory; | 120 FilePath browser_directory; |
121 PathService::Get(base::DIR_MODULE, &browser_directory); | 121 PathService::Get(base::DIR_MODULE, &browser_directory); |
122 command_line->AppendSwitchPath(switches::kExtraPluginDir, | 122 command_line->AppendSwitchPath(switches::kExtraPluginDir, |
123 browser_directory.AppendASCII("plugins")); | 123 browser_directory.AppendASCII("plugins")); |
124 #endif | 124 #endif |
| 125 // TODO(jam): since these plugin tests are running under Chrome, we need to |
| 126 // tell it to disable its security features for old plugins. Once this is |
| 127 // running under content_browsertests, these flags won't be needed. |
| 128 // http://crbug.com/90448 |
| 129 // switches::kAlwaysAuthorizePlugins |
| 130 command_line->AppendSwitch("always-authorize-plugins"); |
125 } | 131 } |
126 }; | 132 }; |
127 | 133 |
128 // Try to open a channel to the test plugin. Minimal plugin process spawning | 134 // Try to open a channel to the test plugin. Minimal plugin process spawning |
129 // test for the PluginService interface. | 135 // test for the PluginService interface. |
130 IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) { | 136 IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) { |
131 MockPluginProcessHostClient mock_client( | 137 MockPluginProcessHostClient mock_client( |
132 browser()->profile()->GetResourceContext()); | 138 browser()->profile()->GetResourceContext()); |
133 BrowserThread::PostTask( | 139 BrowserThread::PostTask( |
134 BrowserThread::IO, FROM_HERE, | 140 BrowserThread::IO, FROM_HERE, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 176 |
171 DISALLOW_COPY_AND_ASSIGN(MockCanceledPluginServiceClient); | 177 DISALLOW_COPY_AND_ASSIGN(MockCanceledPluginServiceClient); |
172 }; | 178 }; |
173 | 179 |
174 void QuitUIMessageLoopFromIOThread() { | 180 void QuitUIMessageLoopFromIOThread() { |
175 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 181 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
176 MessageLoop::QuitClosure()); | 182 MessageLoop::QuitClosure()); |
177 } | 183 } |
178 | 184 |
179 void OpenChannelAndThenCancel(PluginProcessHost::Client* client) { | 185 void OpenChannelAndThenCancel(PluginProcessHost::Client* client) { |
180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 186 OpenChannel(client); |
181 // Start opening the channel | |
182 PluginServiceImpl::GetInstance()->OpenChannelToNpapiPlugin( | |
183 0, 0, GURL(), GURL(), kNPAPITestPluginMimeType, client); | |
184 // Immediately cancel it. This is guaranteed to work since PluginService needs | 187 // Immediately cancel it. This is guaranteed to work since PluginService needs |
185 // to consult its filter on the FILE thread. | 188 // to consult its filter on the FILE thread. |
186 PluginServiceImpl::GetInstance()->CancelOpenChannelToNpapiPlugin(client); | 189 PluginServiceImpl::GetInstance()->CancelOpenChannelToNpapiPlugin(client); |
187 // Before we terminate the test, add a roundtrip through the FILE thread to | 190 // Before we terminate the test, add a roundtrip through the FILE thread to |
188 // make sure that it's had a chance to post back to the IO thread. Then signal | 191 // make sure that it's had a chance to post back to the IO thread. Then signal |
189 // the UI thread to stop and exit the test. | 192 // the UI thread to stop and exit the test. |
190 BrowserThread::PostTaskAndReply( | 193 BrowserThread::PostTaskAndReply( |
191 BrowserThread::FILE, FROM_HERE, | 194 BrowserThread::FILE, FROM_HERE, |
192 base::Bind(&base::DoNothing), | 195 base::Bind(&base::DoNothing), |
193 base::Bind(&QuitUIMessageLoopFromIOThread)); | 196 base::Bind(&QuitUIMessageLoopFromIOThread)); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 BrowserThread::IO, FROM_HERE, | 326 BrowserThread::IO, FROM_HERE, |
324 base::Bind(&OpenChannel, &mock_client)); | 327 base::Bind(&OpenChannel, &mock_client)); |
325 ui_test_utils::RunMessageLoop(); | 328 ui_test_utils::RunMessageLoop(); |
326 EXPECT_TRUE(mock_client.get_resource_context_called()); | 329 EXPECT_TRUE(mock_client.get_resource_context_called()); |
327 EXPECT_TRUE(mock_client.set_plugin_info_called()); | 330 EXPECT_TRUE(mock_client.set_plugin_info_called()); |
328 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called()); | 331 EXPECT_TRUE(mock_client.on_found_plugin_process_host_called()); |
329 EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called()); | 332 EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called()); |
330 } | 333 } |
331 | 334 |
332 } // namespace | 335 } // namespace |
OLD | NEW |