| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_ = new IPC::Channel(handle, IPC::Channel::MODE_CLIENT, this); | 63 channel_ = new IPC::Channel(handle, IPC::Channel::MODE_CLIENT, this); |
| 64 ASSERT_TRUE(channel_->Connect()); | 64 ASSERT_TRUE(channel_->Connect()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 virtual void SetPluginInfo(const webkit::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. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 webkit::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 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 webkit::WebPluginInfo& info)); | 204 MOCK_METHOD1(SetPluginInfo, void(const WebPluginInfo& info)); |
| 205 MOCK_METHOD0(OnError, void()); | 205 MOCK_METHOD0(OnError, void()); |
| 206 | 206 |
| 207 bool get_resource_context_called() const { | 207 bool get_resource_context_called() const { |
| 208 return get_resource_context_called_; | 208 return get_resource_context_called_; |
| 209 } | 209 } |
| 210 | 210 |
| 211 private: | 211 private: |
| 212 ResourceContext* context_; | 212 ResourceContext* context_; |
| 213 bool get_resource_context_called_; | 213 bool get_resource_context_called_; |
| 214 | 214 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 webkit::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, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |