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

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

Issue 10702083: Add ContentViewDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 8 years, 3 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) 2012 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 #ifndef ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_CLIENT_H_
6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_CLIENT_H_
7
8 #include "base/android/scoped_java_ref.h"
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11
12 class GURL;
13 class InterceptedRequestData;
14 class JavaDelegateMapMaintainer;
15
16 namespace content {
17 class WebContents;
18 }
19
20 namespace net {
21 class URLRequest;
22 }
23
24 namespace android_webview {
25
26 // This class provides a means of calling Java methods on an instance that has
27 // a 1:1 relationship with a WebContents instance directly from the IO thread.
28 //
29 // Specifically this is used to implement URLRequest intercepting in a way that
30 // lets the embedder associate URLRequests with the WebContents that the
31 // URLRequest is made for.
32 //
33 // The native class is intended to be a short-lived handle that pins the
34 // Java-side instance. It is preferable to use the static getter methods to
35 // obtain a new instance of the class rather than holding on to one for
36 // prolonged periods of time (see note for more details).
37 //
38 // Note: The native AwContentsIoThreadClient instance has a Global ref to
39 // the Java object. By keeping the native AwContentsIoThreadClient
40 // instance alive you're also prolonging the lifetime of the Java instance, so
41 // don't keep a AwContentsIoThreadClient if you don't need to.
42 class AwContentsIoThreadClient {
43 public:
44 // This will attempt to fetch the AwContentsIoThreadClient for the given
45 // |render_process_id|, |render_view_id| pair.
46 // This method can be called from any thread.
47 // An empty scoped_ptr is a valid return value.
48 static AwContentsIoThreadClient FromID(int render_process_id,
49 int render_view_id);
50
51 // Associates the |jclient| instance (which must implement the
52 // AwContentsIoThreadClient Java interface) with the |web_contents|.
53 // This should be called at most once per |web_contents|.
54 static void Associate(content::WebContents* web_contents,
55 const base::android::JavaRef<jobject>& jclient);
56
57 AwContentsIoThreadClient(const AwContentsIoThreadClient& orig);
58 ~AwContentsIoThreadClient();
59 void operator=(const AwContentsIoThreadClient& rhs);
60
61 // This method is called on the IO thread only.
62 scoped_ptr<InterceptedRequestData> ShouldInterceptRequest(
63 const net::URLRequest* request);
64
65 private:
66 AwContentsIoThreadClient();
67 AwContentsIoThreadClient(const base::android::JavaRef<jobject>& jclient);
68
69 base::android::ScopedJavaGlobalRef<jobject> java_object_;
70 };
71
72 // JNI registration method.
73 bool RegisterAwContentsIoThreadClient(JNIEnv* env);
74
75
76 } // namespace android_webview
77
78 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_CLIENT_H_
OLDNEW
« no previous file with comments | « android_webview/native/aw_contents.cc ('k') | android_webview/native/aw_contents_io_thread_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698