Workaround for xkbcommon dead keys.
[chromium-blink-merge.git] / components / web_contents_delegate_android / web_contents_delegate_android.h
blobbb77259cff2e6e0f1250efb2d0348a4a94334a4e
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.
5 #ifndef COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_WEB_CONTENTS_DELEGATE_ANDROID_H_
6 #define COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_WEB_CONTENTS_DELEGATE_ANDROID_H_
8 #include "base/android/jni_weak_ref.h"
9 #include "base/android/scoped_java_ref.h"
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/public/browser/web_contents_delegate.h"
14 class GURL;
16 namespace content {
17 class WebContents;
18 class WebContentsDelegate;
19 struct NativeWebKeyboardEvent;
20 struct OpenURLParams;
23 namespace web_contents_delegate_android {
25 class ValidationMessageBubbleAndroid;
27 enum WebContentsDelegateLogLevel {
28 // Equivalent of WebCore::WebConsoleMessage::LevelDebug.
29 WEB_CONTENTS_DELEGATE_LOG_LEVEL_DEBUG = 0,
30 // Equivalent of WebCore::WebConsoleMessage::LevelLog.
31 WEB_CONTENTS_DELEGATE_LOG_LEVEL_LOG = 1,
32 // Equivalent of WebCore::WebConsoleMessage::LevelWarning.
33 WEB_CONTENTS_DELEGATE_LOG_LEVEL_WARNING = 2,
34 // Equivalent of WebCore::WebConsoleMessage::LevelError.
35 WEB_CONTENTS_DELEGATE_LOG_LEVEL_ERROR = 3,
39 // Native underpinnings of WebContentsDelegateAndroid.java. Provides a default
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
42 // as required.
43 class WebContentsDelegateAndroid : public content::WebContentsDelegate {
44 public:
45 WebContentsDelegateAndroid(JNIEnv* env, jobject obj);
46 virtual ~WebContentsDelegateAndroid();
48 // Binds this WebContentsDelegateAndroid to the passed WebContents instance,
49 // such that when that WebContents is destroyed, this
50 // WebContentsDelegateAndroid instance will be destroyed too.
51 void SetOwnerWebContents(content::WebContents* contents);
53 // Overridden from WebContentsDelegate:
54 virtual content::WebContents* OpenURLFromTab(
55 content::WebContents* source,
56 const content::OpenURLParams& params) override;
57 virtual content::ColorChooser* OpenColorChooser(
58 content::WebContents* source,
59 SkColor color,
60 const std::vector<content::ColorSuggestion>& suggestions) override;
61 virtual void NavigationStateChanged(
62 content::WebContents* source,
63 content::InvalidateTypes changed_flags) override;
64 virtual void VisibleSSLStateChanged(
65 const content::WebContents* source) override;
66 virtual void ActivateContents(content::WebContents* contents) override;
67 virtual void DeactivateContents(content::WebContents* contents) override;
68 virtual void LoadingStateChanged(content::WebContents* source,
69 bool to_different_document) override;
70 virtual void LoadProgressChanged(content::WebContents* source,
71 double load_progress) override;
72 virtual void RendererUnresponsive(content::WebContents* source) override;
73 virtual void RendererResponsive(content::WebContents* source) override;
74 virtual void DidNavigateToPendingEntry(content::WebContents* source) override;
75 virtual void WebContentsCreated(content::WebContents* source_contents,
76 int opener_render_frame_id,
77 const base::string16& frame_name,
78 const GURL& target_url,
79 content::WebContents* new_contents) override;
80 virtual bool ShouldCreateWebContents(
81 content::WebContents* web_contents,
82 int route_id,
83 int main_frame_route_id,
84 WindowContainerType window_container_type,
85 const base::string16& frame_name,
86 const GURL& target_url,
87 const std::string& partition_id,
88 content::SessionStorageNamespace* session_storage_namespace) override;
89 virtual bool OnGoToEntryOffset(int offset) override;
90 virtual void CloseContents(content::WebContents* source) override;
91 virtual void MoveContents(content::WebContents* source,
92 const gfx::Rect& pos) override;
93 virtual bool AddMessageToConsole(content::WebContents* source,
94 int32 level,
95 const base::string16& message,
96 int32 line_no,
97 const base::string16& source_id) override;
98 virtual void UpdateTargetURL(content::WebContents* source,
99 const GURL& url) override;
100 virtual void HandleKeyboardEvent(
101 content::WebContents* source,
102 const content::NativeWebKeyboardEvent& event) override;
103 virtual bool TakeFocus(content::WebContents* source, bool reverse) override;
104 virtual void ShowRepostFormWarningDialog(
105 content::WebContents* source) override;
106 virtual void ToggleFullscreenModeForTab(content::WebContents* web_contents,
107 bool enter_fullscreen) override;
108 virtual bool IsFullscreenForTabOrPending(
109 const content::WebContents* web_contents) const override;
110 virtual void ShowValidationMessage(content::WebContents* web_contents,
111 const gfx::Rect& anchor_in_root_view,
112 const base::string16& main_text,
113 const base::string16& sub_text) override;
114 virtual void HideValidationMessage(
115 content::WebContents* web_contents) override;
116 virtual void MoveValidationMessage(
117 content::WebContents* web_contents,
118 const gfx::Rect& anchor_in_root_view) override;
120 protected:
121 base::android::ScopedJavaLocalRef<jobject> GetJavaDelegate(JNIEnv* env) const;
123 private:
124 // We depend on the java side user of WebContentDelegateAndroid to hold a
125 // strong reference to that object as long as they want to receive callbacks
126 // on it. Using a weak ref here allows it to be correctly GCed.
127 JavaObjectWeakGlobalRef weak_java_delegate_;
129 scoped_ptr<ValidationMessageBubbleAndroid> validation_message_bubble_;
132 bool RegisterWebContentsDelegateAndroid(JNIEnv* env);
134 } // namespace web_contents_delegate_android
136 #endif // COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_WEB_CONTENTS_DELEGATE_ANDROID_H_