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_WEB_CONTENTS_DELEGATE_ANDROID_WEB_CONTENTS_DELEGATE_ANDROID_H
_ | 5 #ifndef COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_WEB_CONTENTS_DELEGATE_ANDROID_H
_ |
6 #define COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_WEB_CONTENTS_DELEGATE_ANDROID_H
_ | 6 #define COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_WEB_CONTENTS_DELEGATE_ANDROID_H
_ |
7 | 7 |
8 #include "base/android/jni_weak_ref.h" | 8 #include "base/android/jni_weak_ref.h" |
9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 }; | 36 }; |
37 | 37 |
38 | 38 |
39 // Native underpinnings of WebContentsDelegateAndroid.java. Provides a default | 39 // Native underpinnings of WebContentsDelegateAndroid.java. Provides a default |
40 // delegate for WebContents to forward calls to the java peer. The embedding | 40 // delegate for WebContents to forward calls to the java peer. The embedding |
41 // application may subclass and override methods on either the C++ or Java side | 41 // application may subclass and override methods on either the C++ or Java side |
42 // as required. | 42 // as required. |
43 class WebContentsDelegateAndroid : public content::WebContentsDelegate { | 43 class WebContentsDelegateAndroid : public content::WebContentsDelegate { |
44 public: | 44 public: |
45 WebContentsDelegateAndroid(JNIEnv* env, jobject obj); | 45 WebContentsDelegateAndroid(JNIEnv* env, jobject obj); |
46 virtual ~WebContentsDelegateAndroid(); | 46 ~WebContentsDelegateAndroid() override; |
47 | 47 |
48 // Binds this WebContentsDelegateAndroid to the passed WebContents instance, | 48 // Binds this WebContentsDelegateAndroid to the passed WebContents instance, |
49 // such that when that WebContents is destroyed, this | 49 // such that when that WebContents is destroyed, this |
50 // WebContentsDelegateAndroid instance will be destroyed too. | 50 // WebContentsDelegateAndroid instance will be destroyed too. |
51 void SetOwnerWebContents(content::WebContents* contents); | 51 void SetOwnerWebContents(content::WebContents* contents); |
52 | 52 |
53 // Overridden from WebContentsDelegate: | 53 // Overridden from WebContentsDelegate: |
54 virtual content::WebContents* OpenURLFromTab( | 54 content::WebContents* OpenURLFromTab( |
55 content::WebContents* source, | 55 content::WebContents* source, |
56 const content::OpenURLParams& params) override; | 56 const content::OpenURLParams& params) override; |
57 virtual content::ColorChooser* OpenColorChooser( | 57 content::ColorChooser* OpenColorChooser( |
58 content::WebContents* source, | 58 content::WebContents* source, |
59 SkColor color, | 59 SkColor color, |
60 const std::vector<content::ColorSuggestion>& suggestions) override; | 60 const std::vector<content::ColorSuggestion>& suggestions) override; |
61 virtual void NavigationStateChanged( | 61 void NavigationStateChanged(content::WebContents* source, |
62 content::WebContents* source, | 62 content::InvalidateTypes changed_flags) override; |
63 content::InvalidateTypes changed_flags) override; | 63 void VisibleSSLStateChanged(const content::WebContents* source) override; |
64 virtual void VisibleSSLStateChanged( | 64 void ActivateContents(content::WebContents* contents) override; |
65 const content::WebContents* source) override; | 65 void DeactivateContents(content::WebContents* contents) override; |
66 virtual void ActivateContents(content::WebContents* contents) override; | 66 void LoadingStateChanged(content::WebContents* source, |
67 virtual void DeactivateContents(content::WebContents* contents) override; | 67 bool to_different_document) override; |
68 virtual void LoadingStateChanged(content::WebContents* source, | 68 void LoadProgressChanged(content::WebContents* source, |
69 bool to_different_document) override; | 69 double load_progress) override; |
70 virtual void LoadProgressChanged(content::WebContents* source, | 70 void RendererUnresponsive(content::WebContents* source) override; |
71 double load_progress) override; | 71 void RendererResponsive(content::WebContents* source) override; |
72 virtual void RendererUnresponsive(content::WebContents* source) override; | 72 void DidNavigateToPendingEntry(content::WebContents* source) override; |
73 virtual void RendererResponsive(content::WebContents* source) override; | 73 void WebContentsCreated(content::WebContents* source_contents, |
74 virtual void DidNavigateToPendingEntry(content::WebContents* source) override; | 74 int opener_render_frame_id, |
75 virtual void WebContentsCreated(content::WebContents* source_contents, | 75 const base::string16& frame_name, |
76 int opener_render_frame_id, | 76 const GURL& target_url, |
77 const base::string16& frame_name, | 77 content::WebContents* new_contents) override; |
78 const GURL& target_url, | 78 bool ShouldCreateWebContents( |
79 content::WebContents* new_contents) override; | |
80 virtual bool ShouldCreateWebContents( | |
81 content::WebContents* web_contents, | 79 content::WebContents* web_contents, |
82 int route_id, | 80 int route_id, |
83 int main_frame_route_id, | 81 int main_frame_route_id, |
84 WindowContainerType window_container_type, | 82 WindowContainerType window_container_type, |
85 const base::string16& frame_name, | 83 const base::string16& frame_name, |
86 const GURL& target_url, | 84 const GURL& target_url, |
87 const std::string& partition_id, | 85 const std::string& partition_id, |
88 content::SessionStorageNamespace* session_storage_namespace) override; | 86 content::SessionStorageNamespace* session_storage_namespace) override; |
89 virtual bool OnGoToEntryOffset(int offset) override; | 87 bool OnGoToEntryOffset(int offset) override; |
90 virtual void CloseContents(content::WebContents* source) override; | 88 void CloseContents(content::WebContents* source) override; |
91 virtual void MoveContents(content::WebContents* source, | 89 void MoveContents(content::WebContents* source, |
92 const gfx::Rect& pos) override; | 90 const gfx::Rect& pos) override; |
93 virtual bool AddMessageToConsole(content::WebContents* source, | 91 bool AddMessageToConsole(content::WebContents* source, |
94 int32 level, | 92 int32 level, |
95 const base::string16& message, | 93 const base::string16& message, |
96 int32 line_no, | 94 int32 line_no, |
97 const base::string16& source_id) override; | 95 const base::string16& source_id) override; |
98 virtual void UpdateTargetURL(content::WebContents* source, | 96 void UpdateTargetURL(content::WebContents* source, const GURL& url) override; |
99 const GURL& url) override; | 97 void HandleKeyboardEvent( |
100 virtual void HandleKeyboardEvent( | |
101 content::WebContents* source, | 98 content::WebContents* source, |
102 const content::NativeWebKeyboardEvent& event) override; | 99 const content::NativeWebKeyboardEvent& event) override; |
103 virtual bool TakeFocus(content::WebContents* source, bool reverse) override; | 100 bool TakeFocus(content::WebContents* source, bool reverse) override; |
104 virtual void ShowRepostFormWarningDialog( | 101 void ShowRepostFormWarningDialog(content::WebContents* source) override; |
105 content::WebContents* source) override; | 102 void EnterFullscreenModeForTab(content::WebContents* web_contents, |
106 virtual void EnterFullscreenModeForTab(content::WebContents* web_contents, | 103 const GURL& origin) override; |
107 const GURL& origin) override; | 104 void ExitFullscreenModeForTab(content::WebContents* web_contents) override; |
108 virtual void ExitFullscreenModeForTab( | 105 bool IsFullscreenForTabOrPending( |
109 content::WebContents* web_contents) override; | |
110 virtual bool IsFullscreenForTabOrPending( | |
111 const content::WebContents* web_contents) const override; | 106 const content::WebContents* web_contents) const override; |
112 virtual void ShowValidationMessage(content::WebContents* web_contents, | 107 void ShowValidationMessage(content::WebContents* web_contents, |
113 const gfx::Rect& anchor_in_root_view, | 108 const gfx::Rect& anchor_in_root_view, |
114 const base::string16& main_text, | 109 const base::string16& main_text, |
115 const base::string16& sub_text) override; | 110 const base::string16& sub_text) override; |
116 virtual void HideValidationMessage( | 111 void HideValidationMessage(content::WebContents* web_contents) override; |
117 content::WebContents* web_contents) override; | 112 void MoveValidationMessage(content::WebContents* web_contents, |
118 virtual void MoveValidationMessage( | 113 const gfx::Rect& anchor_in_root_view) override; |
119 content::WebContents* web_contents, | |
120 const gfx::Rect& anchor_in_root_view) override; | |
121 | 114 |
122 protected: | 115 protected: |
123 base::android::ScopedJavaLocalRef<jobject> GetJavaDelegate(JNIEnv* env) const; | 116 base::android::ScopedJavaLocalRef<jobject> GetJavaDelegate(JNIEnv* env) const; |
124 | 117 |
125 private: | 118 private: |
126 // We depend on the java side user of WebContentDelegateAndroid to hold a | 119 // We depend on the java side user of WebContentDelegateAndroid to hold a |
127 // strong reference to that object as long as they want to receive callbacks | 120 // strong reference to that object as long as they want to receive callbacks |
128 // on it. Using a weak ref here allows it to be correctly GCed. | 121 // on it. Using a weak ref here allows it to be correctly GCed. |
129 JavaObjectWeakGlobalRef weak_java_delegate_; | 122 JavaObjectWeakGlobalRef weak_java_delegate_; |
130 | 123 |
131 scoped_ptr<ValidationMessageBubbleAndroid> validation_message_bubble_; | 124 scoped_ptr<ValidationMessageBubbleAndroid> validation_message_bubble_; |
132 }; | 125 }; |
133 | 126 |
134 bool RegisterWebContentsDelegateAndroid(JNIEnv* env); | 127 bool RegisterWebContentsDelegateAndroid(JNIEnv* env); |
135 | 128 |
136 } // namespace web_contents_delegate_android | 129 } // namespace web_contents_delegate_android |
137 | 130 |
138 #endif // COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_WEB_CONTENTS_DELEGATE_ANDROI
D_H_ | 131 #endif // COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_WEB_CONTENTS_DELEGATE_ANDROI
D_H_ |
OLD | NEW |