OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_PERMISSION_HELPER_H_ | 5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_PERMISSION_HELPER_H_ |
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_PERMISSION_HELPER_H_ | 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_PERMISSION_HELPER_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/metrics/user_metrics_action.h" | 9 #include "base/metrics/user_metrics_action.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 class WebViewPermissionHelperDelegate; | 21 class WebViewPermissionHelperDelegate; |
22 | 22 |
23 // WebViewPermissionHelper manages <webview> permission requests. This helper | 23 // WebViewPermissionHelper manages <webview> permission requests. This helper |
24 // class is owned by WebViewGuest. Its purpose is to request permission for | 24 // class is owned by WebViewGuest. Its purpose is to request permission for |
25 // various operations from the <webview> embedder, and reply back via callbacks | 25 // various operations from the <webview> embedder, and reply back via callbacks |
26 // to the callers on a response from the embedder. | 26 // to the callers on a response from the embedder. |
27 class WebViewPermissionHelper | 27 class WebViewPermissionHelper |
28 : public content::WebContentsObserver { | 28 : public content::WebContentsObserver { |
29 public: | 29 public: |
30 explicit WebViewPermissionHelper(WebViewGuest* guest); | 30 explicit WebViewPermissionHelper(WebViewGuest* guest); |
31 virtual ~WebViewPermissionHelper(); | 31 ~WebViewPermissionHelper() override; |
32 typedef base::Callback< | 32 typedef base::Callback< |
33 void(bool /* allow */, const std::string& /* user_input */)> | 33 void(bool /* allow */, const std::string& /* user_input */)> |
34 PermissionResponseCallback; | 34 PermissionResponseCallback; |
35 | 35 |
36 // A map to store the callback for a request keyed by the request's id. | 36 // A map to store the callback for a request keyed by the request's id. |
37 struct PermissionResponseInfo { | 37 struct PermissionResponseInfo { |
38 PermissionResponseCallback callback; | 38 PermissionResponseCallback callback; |
39 WebViewPermissionType permission_type; | 39 WebViewPermissionType permission_type; |
40 bool allowed_by_default; | 40 bool allowed_by_default; |
41 PermissionResponseInfo(); | 41 PermissionResponseInfo(); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 WebViewGuest* web_view_guest() { return web_view_guest_; } | 135 WebViewGuest* web_view_guest() { return web_view_guest_; } |
136 | 136 |
137 private: | 137 private: |
138 void OnMediaPermissionResponse(const content::MediaStreamRequest& request, | 138 void OnMediaPermissionResponse(const content::MediaStreamRequest& request, |
139 const content::MediaResponseCallback& callback, | 139 const content::MediaResponseCallback& callback, |
140 bool allow, | 140 bool allow, |
141 const std::string& user_input); | 141 const std::string& user_input); |
142 | 142 |
143 #if defined(ENABLE_PLUGINS) | 143 #if defined(ENABLE_PLUGINS) |
144 // content::WebContentsObserver implementation. | 144 // content::WebContentsObserver implementation. |
145 virtual bool OnMessageReceived( | 145 bool OnMessageReceived(const IPC::Message& message, |
146 const IPC::Message& message, | 146 content::RenderFrameHost* render_frame_host) override; |
147 content::RenderFrameHost* render_frame_host) override; | 147 bool OnMessageReceived(const IPC::Message& message) override; |
148 virtual bool OnMessageReceived(const IPC::Message& message) override; | |
149 #endif // defined(ENABLE_PLUGINS) | 148 #endif // defined(ENABLE_PLUGINS) |
150 | 149 |
151 // A counter to generate a unique request id for a permission request. | 150 // A counter to generate a unique request id for a permission request. |
152 // We only need the ids to be unique for a given WebViewGuest. | 151 // We only need the ids to be unique for a given WebViewGuest. |
153 int next_permission_request_id_; | 152 int next_permission_request_id_; |
154 | 153 |
155 WebViewPermissionHelper::RequestMap pending_permission_requests_; | 154 WebViewPermissionHelper::RequestMap pending_permission_requests_; |
156 | 155 |
157 scoped_ptr<WebViewPermissionHelperDelegate> | 156 scoped_ptr<WebViewPermissionHelperDelegate> |
158 web_view_permission_helper_delegate_; | 157 web_view_permission_helper_delegate_; |
159 | 158 |
160 WebViewGuest* const web_view_guest_; | 159 WebViewGuest* const web_view_guest_; |
161 | 160 |
162 base::WeakPtrFactory<WebViewPermissionHelper> weak_factory_; | 161 base::WeakPtrFactory<WebViewPermissionHelper> weak_factory_; |
163 | 162 |
164 DISALLOW_COPY_AND_ASSIGN(WebViewPermissionHelper); | 163 DISALLOW_COPY_AND_ASSIGN(WebViewPermissionHelper); |
165 }; | 164 }; |
166 | 165 |
167 } // namespace extensions | 166 } // namespace extensions |
168 | 167 |
169 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_PERMISSION_HELPER_H_ | 168 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_PERMISSION_HELPER_H_ |
OLD | NEW |