Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: ppapi/proxy/ppb_talk_private_proxy.cc

Issue 9683003: Aura: Show dialog box asking user's permisssion for screen sharing for gtalk (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ppapi/proxy/ppb_talk_private_proxy.h" 5 #include "ppapi/proxy/ppb_talk_private_proxy.h"
6 6
7 #include "ipc/ipc_message_macros.h" 7 #include "ipc/ipc_message_macros.h"
8 #include "ppapi/c/pp_errors.h" 8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/proxy/plugin_dispatcher.h" 9 #include "ppapi/proxy/plugin_dispatcher.h"
10 #include "ppapi/proxy/plugin_globals.h" 10 #include "ppapi/proxy/plugin_globals.h"
11 #include "ppapi/proxy/plugin_proxy_delegate.h" 11 #include "ppapi/proxy/plugin_proxy_delegate.h"
12 #include "ppapi/proxy/ppapi_messages.h" 12 #include "ppapi/proxy/ppapi_messages.h"
13 #include "ppapi/shared_impl/resource.h" 13 #include "ppapi/shared_impl/resource.h"
14 #include "ppapi/shared_impl/tracked_callback.h" 14 #include "ppapi/shared_impl/tracked_callback.h"
15 #include "ppapi/thunk/enter.h" 15 #include "ppapi/thunk/enter.h"
16 #include "ppapi/thunk/ppb_talk_private_api.h" 16 #include "ppapi/thunk/ppb_talk_private_api.h"
17 17
18 namespace ppapi { 18 namespace ppapi {
19 namespace proxy { 19 namespace proxy {
20 20
21 namespace { 21 namespace {
22 22
23 class Talk : public Resource, public thunk::PPB_Talk_Private_API { 23 class Talk : public Resource, public thunk::PPB_Talk_Private_API {
24 public: 24 public:
25 Talk(PP_Instance instance) : Resource(OBJECT_IS_PROXY, instance) { 25 Talk(PP_Instance instance, int renderer_id)
26 : Resource(OBJECT_IS_PROXY, instance),
27 renderer_id_(renderer_id) {
26 } 28 }
27 29
28 // Resource overrides. 30 // Resource overrides.
29 thunk::PPB_Talk_Private_API* AsPPB_Talk_Private_API() { return this; } 31 thunk::PPB_Talk_Private_API* AsPPB_Talk_Private_API() { return this; }
30 32
31 // PPB_Talk_API implementation. 33 // PPB_Talk_API implementation.
32 int32_t GetPermission(const PP_CompletionCallback& callback) { 34 int32_t GetPermission(const PP_CompletionCallback& callback) {
33 if (TrackedCallback::IsPending(callback_)) 35 if (TrackedCallback::IsPending(callback_))
34 return PP_ERROR_INPROGRESS; 36 return PP_ERROR_INPROGRESS;
35 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( 37 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(
36 pp_instance()); 38 pp_instance());
37 if (!dispatcher) 39 if (!dispatcher)
38 return PP_ERROR_FAILED; 40 return PP_ERROR_FAILED;
39 41
40 callback_ = new TrackedCallback(this, callback); 42 callback_ = new TrackedCallback(this, callback);
41 43
42 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( 44 if (PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser(
43 new PpapiHostMsg_PPBTalk_GetPermission( 45 new PpapiHostMsg_PPBTalk_GetPermission(
44 API_ID_PPB_TALK, 46 API_ID_PPB_TALK,
45 dispatcher->plugin_dispatcher_id(), 47 dispatcher->plugin_dispatcher_id(),
46 pp_resource())); 48 pp_resource(),
47 return PP_OK_COMPLETIONPENDING; 49 renderer_id_)))
50 return PP_OK_COMPLETIONPENDING;
51 return PP_ERROR_FAILED;
52 }
53
54 int GetRendererId() {
55 // Plugin side does not implement this method.
56 NOTREACHED();
57 return 0;
48 } 58 }
49 59
50 void GotCompletion(int32_t result) { 60 void GotCompletion(int32_t result) {
51 TrackedCallback::ClearAndRun(&callback_, result); 61 TrackedCallback::ClearAndRun(&callback_, result);
52 } 62 }
53 63
54 private: 64 private:
55 scoped_refptr<TrackedCallback> callback_; 65 scoped_refptr<TrackedCallback> callback_;
66 int renderer_id_;
56 67
57 DISALLOW_COPY_AND_ASSIGN(Talk); 68 DISALLOW_COPY_AND_ASSIGN(Talk);
58 }; 69 };
59 70
60 } // namespace 71 } // namespace
61 72
62 PPB_Talk_Private_Proxy::PPB_Talk_Private_Proxy(Dispatcher* dispatcher) 73 PPB_Talk_Private_Proxy::PPB_Talk_Private_Proxy(Dispatcher* dispatcher)
63 : InterfaceProxy(dispatcher) { 74 : InterfaceProxy(dispatcher) {
64 } 75 }
65 76
66 // static 77 // static
67 PP_Resource PPB_Talk_Private_Proxy::CreateProxyResource(PP_Instance instance) { 78 PP_Resource PPB_Talk_Private_Proxy::CreateProxyResource(PP_Instance instance) {
68 return (new Talk(instance))->GetReference(); 79 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
80 if (!dispatcher)
81 return 0;
82
83 int renderer_id;
84 dispatcher->Send(new PpapiHostMsg_PPBTalk_GetRendererId(API_ID_PPB_TALK,
85 instance, &renderer_id));
86 return (new Talk(instance, renderer_id))->GetReference();
69 } 87 }
70 88
71 bool PPB_Talk_Private_Proxy::OnMessageReceived(const IPC::Message& msg) { 89 bool PPB_Talk_Private_Proxy::OnMessageReceived(const IPC::Message& msg) {
72 bool handled = true; 90 bool handled = true;
73 IPC_BEGIN_MESSAGE_MAP(PPB_Talk_Private_Proxy, msg) 91 IPC_BEGIN_MESSAGE_MAP(PPB_Talk_Private_Proxy, msg)
74 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTalk_GetPermissionACK, 92 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTalk_GetPermissionACK,
75 OnMsgGetPermissionACK) 93 OnMsgGetPermissionACK)
94 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTalk_GetRendererId, OnMsgGetRendererId)
76 IPC_MESSAGE_UNHANDLED(handled = false); 95 IPC_MESSAGE_UNHANDLED(handled = false);
77 IPC_END_MESSAGE_MAP(); 96 IPC_END_MESSAGE_MAP();
78 return handled; 97 return handled;
79 } 98 }
80 99
81 void PPB_Talk_Private_Proxy::OnMsgGetPermissionACK(uint32 /* dispatcher_id */, 100 void PPB_Talk_Private_Proxy::OnMsgGetPermissionACK(uint32 /* dispatcher_id */,
82 PP_Resource resource, 101 PP_Resource resource,
83 int32_t result) { 102 int32_t result) {
84 thunk::EnterResourceNoLock<thunk::PPB_Talk_Private_API> enter( 103 thunk::EnterResourceNoLock<thunk::PPB_Talk_Private_API> enter(
85 resource, false); 104 resource, false);
86 if (enter.succeeded()) 105 if (enter.succeeded())
87 static_cast<Talk*>(enter.object())->GotCompletion(result); 106 static_cast<Talk*>(enter.object())->GotCompletion(result);
88 } 107 }
89 108
109 void PPB_Talk_Private_Proxy::OnMsgGetRendererId(PP_Instance instance,
110 int* renderer_id) {
111 thunk::EnterResourceCreation enter(instance);
112 if (enter.succeeded()) {
113 PP_Resource resource = enter.functions()->CreateTalk(instance);
114 thunk::EnterResourceNoLock<thunk::PPB_Talk_Private_API> enter1(
115 resource, false);
116 if (enter1.succeeded())
117 *renderer_id = enter1.object()->GetRendererId();
118 }
119 }
120
90 } // namespace proxy 121 } // namespace proxy
91 } // namespace ppapi 122 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698