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

Side by Side Diff: android_webview/native/aw_contents.h

Issue 239793002: Handle media access permission request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 6 years, 8 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 #ifndef ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ 5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_
6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ 6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <list> 9 #include <list>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 12
13 #include "android_webview/browser/browser_view_renderer.h" 13 #include "android_webview/browser/browser_view_renderer.h"
14 #include "android_webview/browser/browser_view_renderer_client.h" 14 #include "android_webview/browser/browser_view_renderer_client.h"
15 #include "android_webview/browser/find_helper.h" 15 #include "android_webview/browser/find_helper.h"
16 #include "android_webview/browser/icon_helper.h" 16 #include "android_webview/browser/icon_helper.h"
17 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" 17 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h"
18 #include "android_webview/browser/shared_renderer_state.h" 18 #include "android_webview/browser/shared_renderer_state.h"
19 #include "android_webview/native/permission/permission_request_handler_client.h"
19 #include "base/android/scoped_java_ref.h" 20 #include "base/android/scoped_java_ref.h"
20 #include "base/android/jni_helper.h" 21 #include "base/android/jni_helper.h"
21 #include "base/callback_forward.h" 22 #include "base/callback_forward.h"
22 #include "base/memory/scoped_ptr.h" 23 #include "base/memory/scoped_ptr.h"
23 24
24 class SkBitmap; 25 class SkBitmap;
25 class TabContents; 26 class TabContents;
26 struct AwDrawGLInfo; 27 struct AwDrawGLInfo;
27 28
28 namespace content { 29 namespace content {
29 class WebContents; 30 class WebContents;
30 } 31 }
31 32
32 namespace android_webview { 33 namespace android_webview {
33 34
34 class AwContentsContainer; 35 class AwContentsContainer;
35 class AwContentsClientBridge; 36 class AwContentsClientBridge;
36 class AwPdfExporter; 37 class AwPdfExporter;
37 class AwWebContentsDelegate; 38 class AwWebContentsDelegate;
38 class HardwareRenderer; 39 class HardwareRenderer;
40 class PermissionRequestHandler;
39 41
40 // Native side of java-class of same name. 42 // Native side of java-class of same name.
41 // Provides the ownership of and access to browser components required for 43 // Provides the ownership of and access to browser components required for
42 // WebView functionality; analogous to chrome's TabContents, but with a 44 // WebView functionality; analogous to chrome's TabContents, but with a
43 // level of indirection provided by the AwContentsContainer abstraction. 45 // level of indirection provided by the AwContentsContainer abstraction.
44 // 46 //
45 // Object lifetime: 47 // Object lifetime:
46 // For most purposes the java and native objects can be considered to have 48 // For most purposes the java and native objects can be considered to have
47 // 1:1 lifetime and relationship. The exception is the java instance that 49 // 1:1 lifetime and relationship. The exception is the java instance that
48 // hosts a popup will be rebound to a second native instance (carrying the 50 // hosts a popup will be rebound to a second native instance (carrying the
49 // popup content) and discard the 'default' native instance it made on 51 // popup content) and discard the 'default' native instance it made on
50 // construction. A native instance is only bound to at most one Java peer over 52 // construction. A native instance is only bound to at most one Java peer over
51 // its entire lifetime - see Init() and SetPendingWebContentsForPopup() for the 53 // its entire lifetime - see Init() and SetPendingWebContentsForPopup() for the
52 // construction points, and SetJavaPeers() where these paths join. 54 // construction points, and SetJavaPeers() where these paths join.
53 class AwContents : public FindHelper::Listener, 55 class AwContents : public FindHelper::Listener,
54 public IconHelper::Listener, 56 public IconHelper::Listener,
55 public AwRenderViewHostExtClient, 57 public AwRenderViewHostExtClient,
56 public BrowserViewRendererClient { 58 public BrowserViewRendererClient,
59 public PermissionRequestHandlerClient {
57 public: 60 public:
58 // Returns the AwContents instance associated with |web_contents|, or NULL. 61 // Returns the AwContents instance associated with |web_contents|, or NULL.
59 static AwContents* FromWebContents(content::WebContents* web_contents); 62 static AwContents* FromWebContents(content::WebContents* web_contents);
60 63
61 // Returns the AwContents instance associated with with the given 64 // Returns the AwContents instance associated with with the given
62 // render_process_id and render_view_id, or NULL. 65 // render_process_id and render_view_id, or NULL.
63 static AwContents* FromID(int render_process_id, int render_view_id); 66 static AwContents* FromID(int render_process_id, int render_view_id);
64 67
65 AwContents(scoped_ptr<content::WebContents> web_contents); 68 AwContents(scoped_ptr<content::WebContents> web_contents);
66 virtual ~AwContents(); 69 virtual ~AwContents();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void DrawGL(AwDrawGLInfo* draw_info); 133 void DrawGL(AwDrawGLInfo* draw_info);
131 134
132 // Geolocation API support 135 // Geolocation API support
133 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>); 136 void ShowGeolocationPrompt(const GURL& origin, base::Callback<void(bool)>);
134 void HideGeolocationPrompt(const GURL& origin); 137 void HideGeolocationPrompt(const GURL& origin);
135 void InvokeGeolocationCallback(JNIEnv* env, 138 void InvokeGeolocationCallback(JNIEnv* env,
136 jobject obj, 139 jobject obj,
137 jboolean value, 140 jboolean value,
138 jstring origin); 141 jstring origin);
139 142
143 // PermissionRequestHandlerClient implementation.
144 virtual void OnPermissionRequest(
145 scoped_refptr<AwPermissionRequest> request) OVERRIDE;
146 virtual void OnPermissionRequestCanceled(
147 scoped_refptr<AwPermissionRequest> request) OVERRIDE;
148
149 PermissionRequestHandler* GetPermissionRequestHandler() {
150 return permission_request_handler_.get();
151 }
152
140 // Find-in-page API and related methods. 153 // Find-in-page API and related methods.
141 void FindAllAsync(JNIEnv* env, jobject obj, jstring search_string); 154 void FindAllAsync(JNIEnv* env, jobject obj, jstring search_string);
142 void FindNext(JNIEnv* env, jobject obj, jboolean forward); 155 void FindNext(JNIEnv* env, jobject obj, jboolean forward);
143 void ClearMatches(JNIEnv* env, jobject obj); 156 void ClearMatches(JNIEnv* env, jobject obj);
144 FindHelper* GetFindHelper(); 157 FindHelper* GetFindHelper();
145 158
146 // FindHelper::Listener implementation. 159 // FindHelper::Listener implementation.
147 virtual void OnFindResultReceived(int active_ordinal, 160 virtual void OnFindResultReceived(int active_ordinal,
148 int match_count, 161 int match_count,
149 bool finished) OVERRIDE; 162 bool finished) OVERRIDE;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; 226 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_;
214 scoped_ptr<AwContentsClientBridge> contents_client_bridge_; 227 scoped_ptr<AwContentsClientBridge> contents_client_bridge_;
215 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; 228 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_;
216 scoped_ptr<FindHelper> find_helper_; 229 scoped_ptr<FindHelper> find_helper_;
217 scoped_ptr<IconHelper> icon_helper_; 230 scoped_ptr<IconHelper> icon_helper_;
218 scoped_ptr<AwContents> pending_contents_; 231 scoped_ptr<AwContents> pending_contents_;
219 SharedRendererState shared_renderer_state_; 232 SharedRendererState shared_renderer_state_;
220 BrowserViewRenderer browser_view_renderer_; 233 BrowserViewRenderer browser_view_renderer_;
221 scoped_ptr<HardwareRenderer> hardware_renderer_; 234 scoped_ptr<HardwareRenderer> hardware_renderer_;
222 scoped_ptr<AwPdfExporter> pdf_exporter_; 235 scoped_ptr<AwPdfExporter> pdf_exporter_;
236 scoped_ptr<PermissionRequestHandler> permission_request_handler_;
223 237
224 // GURL is supplied by the content layer as requesting frame. 238 // GURL is supplied by the content layer as requesting frame.
225 // Callback is supplied by the content layer, and is invoked with the result 239 // Callback is supplied by the content layer, and is invoked with the result
226 // from the permission prompt. 240 // from the permission prompt.
227 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback; 241 typedef std::pair<const GURL, base::Callback<void(bool)> > OriginCallback;
228 // The first element in the list is always the currently pending request. 242 // The first element in the list is always the currently pending request.
229 std::list<OriginCallback> pending_geolocation_prompts_; 243 std::list<OriginCallback> pending_geolocation_prompts_;
230 244
231 DISALLOW_COPY_AND_ASSIGN(AwContents); 245 DISALLOW_COPY_AND_ASSIGN(AwContents);
232 }; 246 };
233 247
234 bool RegisterAwContents(JNIEnv* env); 248 bool RegisterAwContents(JNIEnv* env);
235 249
236 } // namespace android_webview 250 } // namespace android_webview
237 251
238 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ 252 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698