1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_PERMISSION_HELPER_DELEGATE_H_
6 #define CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_PERMISSION_HELPER_DELEGATE_H_
8 #include "chrome/browser/guest_view/web_view/web_view_permission_helper.h"
9 #include "extensions/browser/guest_view/web_view/web_view_permission_helper_delegate.h"
11 namespace extensions {
15 class ChromeWebViewPermissionHelperDelegate :
16 public extensions::WebViewPermissionHelperDelegate {
18 explicit ChromeWebViewPermissionHelperDelegate(
19 extensions::WebViewPermissionHelper* web_view_permission_helper);
20 virtual ~ChromeWebViewPermissionHelperDelegate();
22 // WebViewPermissionHelperDelegate implementation.
23 virtual void RequestMediaAccessPermission(
24 content::WebContents* source,
25 const content::MediaStreamRequest& request,
26 const content::MediaResponseCallback& callback) OVERRIDE;
27 virtual void CanDownload(
28 content::RenderViewHost* render_view_host,
30 const std::string& request_method,
31 const base::Callback<void(bool)>& callback) OVERRIDE;
32 virtual void RequestPointerLockPermission(
34 bool last_unlocked_by_target,
35 const base::Callback<void(bool)>& callback) OVERRIDE;
36 virtual void RequestGeolocationPermission(
38 const GURL& requesting_frame,
40 const base::Callback<void(bool)>& callback) OVERRIDE;
41 virtual void CancelGeolocationPermissionRequest(int bridge_id) OVERRIDE;
42 virtual void RequestFileSystemPermission(
44 bool allowed_by_default,
45 const base::Callback<void(bool)>& callback) OVERRIDE;
46 virtual void FileSystemAccessedAsync(
47 int render_process_id,
51 bool blocked_by_policy) OVERRIDE;
52 virtual void FileSystemAccessedSync(
53 int render_process_id,
56 bool blocked_by_policy,
57 IPC::Message* reply_msg) OVERRIDE;
58 #if defined(ENABLE_PLUGINS)
59 // content::WebContentsObserver implementation.
60 virtual bool OnMessageReceived(
61 const IPC::Message& message,
62 content::RenderFrameHost* render_frame_host) OVERRIDE;
63 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
64 #endif // defined(ENABLE_PLUGINS)
67 #if defined(ENABLE_PLUGINS)
69 void OnBlockedUnauthorizedPlugin(const base::string16& name,
70 const std::string& identifier);
71 void OnCouldNotLoadPlugin(const base::FilePath& plugin_path);
72 void OnBlockedOutdatedPlugin(int placeholder_id,
73 const std::string& identifier);
74 void OnNPAPINotSupported(const std::string& identifier);
75 void OnOpenAboutPlugins();
76 #if defined(ENABLE_PLUGIN_INSTALLATION)
77 void OnFindMissingPlugin(int placeholder_id, const std::string& mime_type);
79 void OnRemovePluginPlaceholderHost(int placeholder_id);
80 #endif // defined(ENABLE_PLUGIN_INSTALLATION)
82 void OnPermissionResponse(const std::string& identifier,
84 const std::string& user_input);
85 #endif // defined(ENABLE_PLUGINS)
87 void OnGeolocationPermissionResponse(
90 const base::Callback<void(bool)>& callback,
92 const std::string& user_input);
94 void OnFileSystemPermissionResponse(
95 const base::Callback<void(bool)>& callback,
97 const std::string& user_input);
99 void OnMediaPermissionResponse(
100 const content::MediaStreamRequest& request,
101 const content::MediaResponseCallback& callback,
103 const std::string& user_input);
105 void OnDownloadPermissionResponse(
106 const base::Callback<void(bool)>& callback,
108 const std::string& user_input);
110 void OnPointerLockPermissionResponse(
111 const base::Callback<void(bool)>& callback,
113 const std::string& user_input);
115 // Bridge IDs correspond to a geolocation request. This method will remove
116 // the bookkeeping for a particular geolocation request associated with the
117 // provided |bridge_id|. It returns the request ID of the geolocation request.
118 int RemoveBridgeID(int bridge_id);
120 void FileSystemAccessedAsyncResponse(int render_process_id,
126 void FileSystemAccessedSyncResponse(int render_process_id,
129 IPC::Message* reply_msg,
132 extensions::WebViewGuest* web_view_guest() {
133 return web_view_permission_helper_->web_view_guest();
136 extensions::WebViewPermissionHelper* web_view_permission_helper_;
138 std::map<int, int> bridge_id_to_request_id_map_;
140 base::WeakPtrFactory<ChromeWebViewPermissionHelperDelegate> weak_factory_;
142 DISALLOW_COPY_AND_ASSIGN(ChromeWebViewPermissionHelperDelegate);
145 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_PERMISSION_HELPER_DELEGATE_H_