Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_DELEGATE_H_ | |
| 6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_DELEGATE_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 | |
| 15 namespace content { | |
| 16 class RenderViewHost; | |
| 17 struct Referrer; | |
| 18 class WebContents; | |
| 19 } | |
| 20 | |
| 21 namespace net { | |
| 22 class URLRequest; | |
| 23 } | |
| 24 | |
| 25 // This lets us implement URLRequest intercepting in a way that lets the | |
| 26 // embedder associate URLRequests with the WebContents that the URLRequest | |
| 27 // is made for. | |
| 28 // | |
| 29 // It is preferable to use the static getter methods to obtain a new instance | |
| 30 // of the class rather than holding on to one for prolonged periods of time | |
| 31 // (see note for more details). | |
| 32 // | |
| 33 // Note: The native AwWebContentsIoThreadDelegate instance has a Global ref to | |
| 34 // the Java object. By keeping the native AwWebContentsIoThreadDelegate | |
| 35 // instance alive you're also prolonging the lifetime of the Java instance, so | |
| 36 // don't keep a AwWebContentsIoThreadDelegate if you don't need to. | |
| 37 // It is also possible that AwWebContentsIoThreadDelegate becomes invalid when | |
| 38 // you're holding on to it. This could happen if the WebContents is destroyed. | |
|
joth
2012/09/01 01:24:14
if the WC is destroyed, the AwWebContentsIoThread
mkosiba (inactive)
2012/09/11 01:22:25
the Java side class will exist, but we only make c
| |
| 39 // In that case the instance methods will noop and return default/null values. | |
| 40 class AwWebContentsIoThreadDelegate { | |
| 41 public: | |
| 42 // This will attempt to fetch the AwWebContentsIoThreadDelegate for the given | |
| 43 // |rvh|. | |
| 44 // This method can be called from any thread. | |
| 45 // An empty scoped_ptr is a valid return value. | |
| 46 static scoped_ptr<AwWebContentsIoThreadDelegate> | |
| 47 ForRenderViewHost(content::RenderViewHost* rvh); | |
|
joth
2012/09/01 01:24:14
returning scoped_ptr (returning ownership) makes i
mkosiba (inactive)
2012/09/11 01:22:25
it's a bit uncommon but the intent behind this is
| |
| 48 | |
| 49 // This will attempt to fetch the AwWebContentsIoThreadDelegate for the given | |
| 50 // This method can be called from any thread. | |
| 51 // |contents|. An empty scoped_ptr is a valid return value. | |
| 52 static scoped_ptr<AwWebContentsIoThreadDelegate> | |
| 53 ForWebContents(content::WebContents* contents); | |
|
joth
2012/09/01 01:24:14
Can't quite follow the usage model for these witho
mkosiba (inactive)
2012/09/11 01:22:25
yeath.. I'll clean this up. We should be getting t
| |
| 54 | |
| 55 static bool RegisterAwWebContentsIoThreadDelegate(JNIEnv* env); | |
| 56 | |
| 57 // This method is called on the IO thread only. | |
| 58 scoped_ptr<InterceptedRequestData> ShouldInterceptRequest( | |
| 59 const net::URLRequest* request); | |
| 60 | |
| 61 ~AwWebContentsIoThreadDelegate(); | |
| 62 | |
| 63 class WebContentsObserver; | |
|
joth
2012/09/01 01:24:14
nit: call this something about its job, JavaDelega
mkosiba (inactive)
2012/09/11 01:22:25
Renamed, has to be inner/friend in order to be abl
| |
| 64 private: | |
| 65 DISALLOW_COPY_AND_ASSIGN(AwWebContentsIoThreadDelegate); | |
|
joth
2012/09/01 01:24:14
should be last.
the WCO forward declaration isn't
mkosiba (inactive)
2012/09/11 01:22:25
Done
| |
| 66 | |
| 67 AwWebContentsIoThreadDelegate(const base::android::JavaRef<jobject>& obj); | |
| 68 void OnWebContentsDestroyed(); | |
| 69 | |
| 70 base::android::ScopedJavaGlobalRef<jobject> java_object_; | |
| 71 }; | |
| 72 | |
| 73 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_IO_THREAD_DELEGATE_H_ | |
| OLD | NEW |