| OLD | NEW |
| 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 COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ | 5 #ifndef COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ |
| 6 #define COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ | 6 #define COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/android/jni_weak_ref.h" | 8 #include "base/android/jni_weak_ref.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/supports_user_data.h" | 10 #include "base/supports_user_data.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // To us this class: | 31 // To us this class: |
| 32 // 1) the Java-side interface implementation must be associated (via the | 32 // 1) the Java-side interface implementation must be associated (via the |
| 33 // Associate method) with a WebContents for which URLRequests are to be | 33 // Associate method) with a WebContents for which URLRequests are to be |
| 34 // intercepted, | 34 // intercepted, |
| 35 // 2) the ResourceThrottle obtained via CreateThrottleFor must be associated | 35 // 2) the ResourceThrottle obtained via CreateThrottleFor must be associated |
| 36 // with the URLRequests in the ResourceDispatcherHostDelegate | 36 // with the URLRequests in the ResourceDispatcherHostDelegate |
| 37 // implementation. | 37 // implementation. |
| 38 class InterceptNavigationDelegate : public base::SupportsUserData::Data { | 38 class InterceptNavigationDelegate : public base::SupportsUserData::Data { |
| 39 public: | 39 public: |
| 40 InterceptNavigationDelegate(JNIEnv* env, jobject jdelegate); | 40 InterceptNavigationDelegate(JNIEnv* env, jobject jdelegate); |
| 41 virtual ~InterceptNavigationDelegate(); | 41 ~InterceptNavigationDelegate() override; |
| 42 | 42 |
| 43 // Associates the InterceptNavigationDelegate with a WebContents using the | 43 // Associates the InterceptNavigationDelegate with a WebContents using the |
| 44 // SupportsUserData mechanism. | 44 // SupportsUserData mechanism. |
| 45 // As implied by the use of scoped_ptr, the WebContents will assume ownership | 45 // As implied by the use of scoped_ptr, the WebContents will assume ownership |
| 46 // of |delegate|. | 46 // of |delegate|. |
| 47 static void Associate(content::WebContents* web_contents, | 47 static void Associate(content::WebContents* web_contents, |
| 48 scoped_ptr<InterceptNavigationDelegate> delegate); | 48 scoped_ptr<InterceptNavigationDelegate> delegate); |
| 49 // Gets the InterceptNavigationDelegate associated with the WebContents, | 49 // Gets the InterceptNavigationDelegate associated with the WebContents, |
| 50 // can be null. | 50 // can be null. |
| 51 static InterceptNavigationDelegate* Get(content::WebContents* web_contents); | 51 static InterceptNavigationDelegate* Get(content::WebContents* web_contents); |
| 52 | 52 |
| 53 // Creates a InterceptNavigationResourceThrottle that will direct all | 53 // Creates a InterceptNavigationResourceThrottle that will direct all |
| 54 // callbacks to the InterceptNavigationDelegate. | 54 // callbacks to the InterceptNavigationDelegate. |
| 55 static content::ResourceThrottle* CreateThrottleFor( | 55 static content::ResourceThrottle* CreateThrottleFor( |
| 56 net::URLRequest* request); | 56 net::URLRequest* request); |
| 57 | 57 |
| 58 virtual bool ShouldIgnoreNavigation( | 58 virtual bool ShouldIgnoreNavigation( |
| 59 const NavigationParams& navigation_params); | 59 const NavigationParams& navigation_params); |
| 60 private: | 60 private: |
| 61 JavaObjectWeakGlobalRef weak_jdelegate_; | 61 JavaObjectWeakGlobalRef weak_jdelegate_; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 bool RegisterInterceptNavigationDelegate(JNIEnv* env); | 64 bool RegisterInterceptNavigationDelegate(JNIEnv* env); |
| 65 | 65 |
| 66 } // namespace navigation_interception | 66 } // namespace navigation_interception |
| 67 | 67 |
| 68 #endif // COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ | 68 #endif // COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ |
| OLD | NEW |