summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/host_dispatcher.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-17 23:59:39 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-17 23:59:39 +0000
commit4deeb43f8b7c1b21d3545228db86de2c73c9fd43 (patch)
tree9b44b6a5908d3948eb74d41f1dc69433c5a963d7 /ppapi/proxy/host_dispatcher.cc
parentc2a6aa323905a384677df735ccaa68ac700b1587 (diff)
downloadchromium_src-4deeb43f8b7c1b21d3545228db86de2c73c9fd43.zip
chromium_src-4deeb43f8b7c1b21d3545228db86de2c73c9fd43.tar.gz
chromium_src-4deeb43f8b7c1b21d3545228db86de2c73c9fd43.tar.bz2
Implement proxying for FileRef and FileChooser.
This also changes the FileRef interface to remove the Query function, since there is no close function, there's no way to cancel the current request, which makes memory management of the info structure very difficult. Review URL: http://codereview.chromium.org/6519057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75331 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/host_dispatcher.cc')
-rw-r--r--ppapi/proxy/host_dispatcher.cc47
1 files changed, 36 insertions, 11 deletions
diff --git a/ppapi/proxy/host_dispatcher.cc b/ppapi/proxy/host_dispatcher.cc
index 5572e91..aa972b5 100644
--- a/ppapi/proxy/host_dispatcher.cc
+++ b/ppapi/proxy/host_dispatcher.cc
@@ -94,17 +94,7 @@ bool HostDispatcher::OnMessageReceived(const IPC::Message& msg) {
if (!info ||
(info->is_trusted && disallow_trusted_interfaces()))
return true;
-
- const void* local_interface = GetLocalInterface(info->name);
- if (!local_interface) {
- // This should always succeed since the browser should support the stuff
- // the proxy does. If this happens, something is out of sync.
- NOTREACHED();
- return true;
- }
-
- proxy = info->create_proxy(this, local_interface);
- target_proxies_[info->id].reset(proxy);
+ proxy = CreatePPBInterfaceProxy(info);
}
return proxy->OnMessageReceived(msg);
@@ -142,6 +132,26 @@ const void* HostDispatcher::GetProxiedInterface(const std::string& interface) {
return NULL;
}
+InterfaceProxy* HostDispatcher::GetOrCreatePPBInterfaceProxy(
+ InterfaceID id) {
+ InterfaceProxy* proxy = target_proxies_[id].get();
+ if (!proxy) {
+ const InterfaceProxy::Info* info = GetPPBInterfaceInfo(id);
+ if (!info)
+ return NULL;
+
+ // Sanity check. This function won't normally be called for trusted
+ // interfaces, but in case somebody does this, we don't want to then give
+ // the plugin the ability to call that trusted interface (since the
+ // checking occurs at proxy-creation time).
+ if (info->is_trusted && disallow_trusted_interfaces())
+ return NULL;
+
+ proxy = CreatePPBInterfaceProxy(info);
+ }
+ return proxy;
+}
+
const PPB_Proxy_Private* HostDispatcher::GetPPBProxy() {
if (!ppb_proxy_) {
ppb_proxy_ = reinterpret_cast<const PPB_Proxy_Private*>(
@@ -150,6 +160,21 @@ const PPB_Proxy_Private* HostDispatcher::GetPPBProxy() {
return ppb_proxy_;
}
+InterfaceProxy* HostDispatcher::CreatePPBInterfaceProxy(
+ const InterfaceProxy::Info* info) {
+ const void* local_interface = GetLocalInterface(info->name);
+ if (!local_interface) {
+ // This should always succeed since the browser should support the stuff
+ // the proxy does. If this happens, something is out of sync.
+ NOTREACHED();
+ return NULL;
+ }
+
+ InterfaceProxy* proxy = info->create_proxy(this, local_interface);
+ target_proxies_[info->id].reset(proxy);
+ return proxy;
+}
+
} // namespace proxy
} // namespace pp