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 "extensions/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 CanDownload(
24 content::RenderViewHost* render_view_host,
26 const std::string& request_method,
27 const base::Callback<void(bool)>& callback) OVERRIDE;
28 virtual void RequestPointerLockPermission(
30 bool last_unlocked_by_target,
31 const base::Callback<void(bool)>& callback) OVERRIDE;
32 virtual void RequestGeolocationPermission(
34 const GURL& requesting_frame,
36 const base::Callback<void(bool)>& callback) OVERRIDE;
37 virtual void CancelGeolocationPermissionRequest(int bridge_id) OVERRIDE;
38 virtual void RequestFileSystemPermission(
40 bool allowed_by_default,
41 const base::Callback<void(bool)>& callback) OVERRIDE;
42 virtual void FileSystemAccessedAsync(
43 int render_process_id,
47 bool blocked_by_policy) OVERRIDE;
48 virtual void FileSystemAccessedSync(
49 int render_process_id,
52 bool blocked_by_policy,
53 IPC::Message* reply_msg) OVERRIDE;
54 #if defined(ENABLE_PLUGINS)
55 // content::WebContentsObserver implementation.
56 virtual bool OnMessageReceived(
57 const IPC::Message& message,
58 content::RenderFrameHost* render_frame_host) OVERRIDE;
59 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
60 #endif // defined(ENABLE_PLUGINS)
63 #if defined(ENABLE_PLUGINS)
65 void OnBlockedUnauthorizedPlugin(const base::string16& name,
66 const std::string& identifier);
67 void OnCouldNotLoadPlugin(const base::FilePath& plugin_path);
68 void OnBlockedOutdatedPlugin(int placeholder_id,
69 const std::string& identifier);
70 void OnNPAPINotSupported(const std::string& identifier);
71 void OnOpenAboutPlugins();
72 #if defined(ENABLE_PLUGIN_INSTALLATION)
73 void OnFindMissingPlugin(int placeholder_id, const std::string& mime_type);
75 void OnRemovePluginPlaceholderHost(int placeholder_id);
76 #endif // defined(ENABLE_PLUGIN_INSTALLATION)
78 void OnPermissionResponse(const std::string& identifier,
80 const std::string& user_input);
81 #endif // defined(ENABLE_PLUGINS)
83 void OnGeolocationPermissionResponse(
86 const base::Callback<void(bool)>& callback,
88 const std::string& user_input);
90 void OnFileSystemPermissionResponse(
91 const base::Callback<void(bool)>& callback,
93 const std::string& user_input);
95 void OnDownloadPermissionResponse(
96 const base::Callback<void(bool)>& callback,
98 const std::string& user_input);
100 void OnPointerLockPermissionResponse(
101 const base::Callback<void(bool)>& callback,
103 const std::string& user_input);
105 // Bridge IDs correspond to a geolocation request. This method will remove
106 // the bookkeeping for a particular geolocation request associated with the
107 // provided |bridge_id|. It returns the request ID of the geolocation request.
108 int RemoveBridgeID(int bridge_id);
110 void FileSystemAccessedAsyncResponse(int render_process_id,
116 void FileSystemAccessedSyncResponse(int render_process_id,
119 IPC::Message* reply_msg,
122 extensions::WebViewGuest* web_view_guest() {
123 return web_view_permission_helper()->web_view_guest();
126 std::map<int, int> bridge_id_to_request_id_map_;
128 base::WeakPtrFactory<ChromeWebViewPermissionHelperDelegate> weak_factory_;
130 DISALLOW_COPY_AND_ASSIGN(ChromeWebViewPermissionHelperDelegate);
133 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_PERMISSION_HELPER_DELEGATE_H_