Roll src/third_party/WebKit f298044:aa8346d (svn 202628:202629)
[chromium-blink-merge.git] / content / browser / pepper_flash_settings_helper_impl.cc
blob2524dbbdda039b73ca3e05d3310936248f2bd16d
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
3 // found in the LICENSE file.
5 #include "content/browser/pepper_flash_settings_helper_impl.h"
7 #include "base/files/file_path.h"
8 #include "content/browser/plugin_service_impl.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "ipc/ipc_channel_handle.h"
12 namespace content {
14 // static
15 scoped_refptr<PepperFlashSettingsHelper> PepperFlashSettingsHelper::Create() {
16 return new PepperFlashSettingsHelperImpl();
19 PepperFlashSettingsHelperImpl::PepperFlashSettingsHelperImpl() {
22 PepperFlashSettingsHelperImpl::~PepperFlashSettingsHelperImpl() {
25 void PepperFlashSettingsHelperImpl::OpenChannelToBroker(
26 const base::FilePath& path,
27 const OpenChannelCallback& callback) {
28 DCHECK_CURRENTLY_ON(BrowserThread::IO);
30 if (callback.is_null())
31 return;
32 if (!callback_.is_null())
33 callback.Run(false, IPC::ChannelHandle());
35 // Balanced in OnPpapiChannelOpened(). We need to keep this object around
36 // until then.
37 AddRef();
39 callback_ = callback;
40 PluginServiceImpl* plugin_service = PluginServiceImpl::GetInstance();
41 plugin_service->OpenChannelToPpapiBroker(0, path, this);
44 void PepperFlashSettingsHelperImpl::GetPpapiChannelInfo(
45 base::ProcessHandle* renderer_handle,
46 int* renderer_id) {
47 *renderer_handle = base::kNullProcessHandle;
48 *renderer_id = 0;
51 void PepperFlashSettingsHelperImpl::OnPpapiChannelOpened(
52 const IPC::ChannelHandle& channel_handle,
53 base::ProcessId /* plugin_pid */,
54 int /* plugin_child_id */) {
55 DCHECK_CURRENTLY_ON(BrowserThread::IO);
56 DCHECK(!callback_.is_null());
58 if (!channel_handle.name.empty())
59 callback_.Run(true, channel_handle);
60 else
61 callback_.Run(false, IPC::ChannelHandle());
63 callback_.Reset();
64 // Balance the AddRef() call in Initialize().
65 Release();
68 bool PepperFlashSettingsHelperImpl::OffTheRecord() {
69 return false;
72 } // namespace content