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

Side by Side Diff: chrome/browser/guestview/webview/plugin_permission_helper.cc

Issue 24576003: <webview>: Change how plugin load works inside guests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 2 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
(Empty)
1 // Copyright (c) 2013 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.
4
5 #include "chrome/browser/guestview/webview/plugin_permission_helper.h"
6
7 #include "chrome/browser/guestview/webview/webview_guest.h"
8 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
9 #include "chrome/common/render_messages.h"
10 #include "content/public/browser/render_process_host.h"
11 #include "content/public/browser/render_view_host.h"
12
13 using content::RenderViewHost;
14 using content::WebContents;
15
16 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PluginPermissionHelper);
Fady Samuel 2013/09/26 12:53:32 Not a code issue but I actually really like the pa
17
18 PluginPermissionHelper::PluginPermissionHelper(WebContents* contents)
19 : content::WebContentsObserver(contents),
20 weak_factory_(this) {
21 }
22
23 PluginPermissionHelper::~PluginPermissionHelper() {
24 }
25
26 bool PluginPermissionHelper::OnMessageReceived(const IPC::Message& message) {
27 IPC_BEGIN_MESSAGE_MAP(PluginPermissionHelper, message)
28 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedUnauthorizedPlugin,
29 OnBlockedUnauthorizedPlugin)
30 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CouldNotLoadPlugin,
31 OnCouldNotLoadPlugin)
32 IPC_MESSAGE_UNHANDLED(return false)
33 IPC_END_MESSAGE_MAP()
34
35 return true;
36 }
37
38 void PluginPermissionHelper::OnBlockedUnauthorizedPlugin(
39 const string16& name,
40 const std::string& identifier) {
41 const char kPluginName[] = "name";
42 const char kPluginIdentifier[] = "identifier";
43
44 GuestView* guest = GuestView::FromWebContents(web_contents());
45 if (!guest)
46 return;
47 WebViewGuest* webview = guest->AsWebView();
48 if (!webview)
Fady Samuel 2013/09/26 12:53:32 I suspect we'll use this pattern more frequently i
sadrul 2013/09/26 15:28:10 Good idea. Done.
49 return;
50
51 base::DictionaryValue info;
52 info.SetString(std::string(kPluginName), name);
53 info.SetString(std::string(kPluginIdentifier), identifier);
54 webview->RequestPermission(
55 BROWSER_PLUGIN_PERMISSION_TYPE_LOAD_PLUGIN,
56 info,
57 base::Bind(&PluginPermissionHelper::OnPermissionResponse,
58 weak_factory_.GetWeakPtr(),
59 identifier));
60 }
61
62 void PluginPermissionHelper::OnCouldNotLoadPlugin(
63 const base::FilePath& plugin_path) {
64 }
65
66 void PluginPermissionHelper::OnPermissionResponse(const std::string& identifier,
67 bool allow,
68 const std::string& input) {
69 if (allow) {
70 RenderViewHost* host = web_contents()->GetRenderViewHost();
71 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins(
72 host->GetProcess()->GetID());
73 host->Send(new ChromeViewMsg_LoadBlockedPlugins(
74 host->GetRoutingID(), identifier));
75 }
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698