browser_ppapi_host.h revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_PUBLIC_BROWSER_BROWSER_PPAPI_HOST_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_PUBLIC_BROWSER_BROWSER_PPAPI_HOST_H_
7a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
81320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/callback_forward.h"
9a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#include "base/process.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/render_view_host.h"
12f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "googleurl/src/gurl.h"
13a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#include "ppapi/c/pp_instance.h"
143551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace IPC {
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ChannelProxy;
17a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochstruct ChannelHandle;
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Sender;
19a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch}
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
21a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochnamespace net {
22a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochclass HostResolver;
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ppapi {
26a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochclass PpapiPermissions;
27a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochnamespace host {
28a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochclass PpapiHost;
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
31a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace content {
33a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Interface that allows components in the embedder app to talk to the
35a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// PpapiHost in the browser process.
36a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch//
37a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// There will be one of these objects in the browser per plugin process. It
38a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// lives entirely on the I/O thread.
39a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochclass CONTENT_EXPORT BrowserPpapiHost {
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Creates a browser host and sets up an out-of-process proxy for an external
421320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // pepper plugin process.
431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  static BrowserPpapiHost* CreateExternalPluginProcess(
441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      IPC::Sender* sender,
451320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      ppapi::PpapiPermissions permissions,
461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      base::ProcessHandle plugin_child_process,
471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      IPC::ChannelProxy* channel,
481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      net::HostResolver* host_resolver,
491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      int render_process_id,
501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      int render_view_id,
511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      const base::FilePath& profile_directory);
521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual ~BrowserPpapiHost() {}
541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Returns the PpapiHost object.
561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual ppapi::host::PpapiHost* GetPpapiHost() = 0;
571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
581320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Returns the handle to the plugin process.
591320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual base::ProcessHandle GetPluginProcessHandle() const = 0;
601320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
611320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Returns true if the given PP_Instance is valid.
621320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool IsValidInstance(PP_Instance instance) const = 0;
631320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
641320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Retrieves the process/view Ids associated with the RenderView containing
651320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // the given instance and returns true on success. If the instance is
661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // invalid, the ids will be 0 and false will be returned.
671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  //
681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // When a resource is created, the PP_Instance should already have been
691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // validated, and the resource hosts will be deleted when the resource is
701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // destroyed. So it should not generally be necessary to check for errors
711320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // from this function except as a last-minute sanity check if you convert the
721320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // IDs to a RenderView/ProcessHost on the UI thread.
73a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  virtual bool GetRenderViewIDsForInstance(PP_Instance instance,
74                                           int* render_process_id,
75                                           int* render_view_id) const = 0;
76
77  // Returns the name of the plugin.
78  virtual const std::string& GetPluginName() = 0;
79
80  // Returns the user's profile data directory.
81  virtual const base::FilePath& GetProfileDataDirectory() = 0;
82
83  // Get the Document/Plugin URLs for the given PP_Instance.
84  virtual GURL GetDocumentURLForInstance(PP_Instance instance) = 0;
85  virtual GURL GetPluginURLForInstance(PP_Instance instance) = 0;
86};
87
88}  // namespace content
89
90#endif  // CONTENT_PUBLIC_BROWSER_BROWSER_PPAPI_HOST_H_
91