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

Side by Side Diff: chrome/browser/renderer_host/pepper/pepper_talk_host.cc

Issue 16271005: Implement pepper interface and plumbing for HRD's UI on ChromeOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed minor typo. Created 7 years, 6 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
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 "chrome/browser/renderer_host/pepper/pepper_talk_host.h" 5 #include "chrome/browser/renderer_host/pepper/pepper_talk_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/public/browser/browser_ppapi_host.h" 8 #include "content/public/browser/browser_ppapi_host.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/render_view_host.h" 10 #include "content/public/browser/render_view_host.h"
11 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
12 #include "ppapi/c/pp_errors.h" 12 #include "ppapi/c/pp_errors.h"
13 #include "ppapi/host/dispatch_host_message.h"
13 #include "ppapi/host/host_message_context.h" 14 #include "ppapi/host/host_message_context.h"
14 #include "ppapi/host/ppapi_host.h" 15 #include "ppapi/host/ppapi_host.h"
15 #include "ppapi/proxy/ppapi_messages.h" 16 #include "ppapi/proxy/ppapi_messages.h"
16 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
17 18
18 #if defined(USE_ASH) 19 #if defined(USE_ASH)
19 #include "ash/shell.h" 20 #include "ash/shell.h"
20 #include "ash/shell_window_ids.h" 21 #include "ash/shell_window_ids.h"
21 #include "chrome/browser/ui/simple_message_box.h" 22 #include "chrome/browser/ui/simple_message_box.h"
22 #include "ui/aura/window.h" 23 #include "ui/aura/window.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 weak_factory_(this), 69 weak_factory_(this),
69 browser_ppapi_host_(host) { 70 browser_ppapi_host_(host) {
70 } 71 }
71 72
72 PepperTalkHost::~PepperTalkHost() { 73 PepperTalkHost::~PepperTalkHost() {
73 } 74 }
74 75
75 int32_t PepperTalkHost::OnResourceMessageReceived( 76 int32_t PepperTalkHost::OnResourceMessageReceived(
76 const IPC::Message& msg, 77 const IPC::Message& msg,
77 ppapi::host::HostMessageContext* context) { 78 ppapi::host::HostMessageContext* context) {
78 // We only have one message with no parameters. 79 IPC_BEGIN_MESSAGE_MAP(PepperTalkHost, msg)
79 if (msg.type() != PpapiHostMsg_Talk_GetPermission::ID) 80 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Talk_RequestPermission,
80 return 0; 81 OnRequestPermission)
82 IPC_END_MESSAGE_MAP()
83 return PP_ERROR_FAILED;
Josh Horwich 2013/06/04 19:48:37 Curious - we used to return 0 here for unknown mes
dcaiafa 2013/06/04 22:38:15 I'm not an expert, but every other host in this di
84 }
85
86 int32_t PepperTalkHost::OnRequestPermission(
87 ppapi::host::HostMessageContext* context,
88 PP_TalkPermission permission) {
89 // TODO(dcaiafa): Implement support for other permission types.
90 if (permission != PP_TALKPERMISSION_SCREENCAST)
91 return PP_ERROR_BADARGUMENT;
81 92
82 int render_process_id = 0; 93 int render_process_id = 0;
83 int render_view_id = 0; 94 int render_view_id = 0;
84 browser_ppapi_host_->GetRenderViewIDsForInstance( 95 browser_ppapi_host_->GetRenderViewIDsForInstance(
85 pp_instance(), &render_process_id, &render_view_id); 96 pp_instance(), &render_process_id, &render_view_id);
86 97
87 content::BrowserThread::PostTaskAndReplyWithResult( 98 content::BrowserThread::PostTaskAndReplyWithResult(
88 content::BrowserThread::UI, FROM_HERE, 99 content::BrowserThread::UI, FROM_HERE,
89 base::Bind(&GetPermissionOnUIThread, render_process_id, render_view_id, 100 base::Bind(&GetPermissionOnUIThread, render_process_id, render_view_id,
90 context->MakeReplyMessageContext()), 101 context->MakeReplyMessageContext()),
91 base::Bind(&PepperTalkHost::GotTalkPermission, 102 base::Bind(&PepperTalkHost::GotTalkPermission,
92 weak_factory_.GetWeakPtr())); 103 weak_factory_.GetWeakPtr()));
93 return PP_OK_COMPLETIONPENDING; 104 return PP_OK_COMPLETIONPENDING;
94 } 105 }
95 106
96 void PepperTalkHost::GotTalkPermission( 107 void PepperTalkHost::GotTalkPermission(
97 ppapi::host::ReplyMessageContext reply) { 108 ppapi::host::ReplyMessageContext reply) {
98 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 109 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
99 host()->SendReply(reply, PpapiPluginMsg_Talk_GetPermissionReply()); 110 host()->SendReply(reply, PpapiPluginMsg_Talk_RequestPermissionReply());
100 } 111 }
101 112
102 } // namespace chrome 113 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698