Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / android / chrome_web_contents_delegate_android.h
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 CHROME_BROWSER_ANDROID_CHROME_WEB_CONTENTS_DELEGATE_ANDROID_H_
6 #define CHROME_BROWSER_ANDROID_CHROME_WEB_CONTENTS_DELEGATE_ANDROID_H_
7
8 #include <jni.h>
9
10 #include "base/files/file_path.h"
11 #include "components/web_contents_delegate_android/web_contents_delegate_android.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
14
15 class FindNotificationDetails;
16
17 namespace content {
18 struct FileChooserParams;
19 class WebContents;
20 }
21
22 namespace gfx {
23 class Rect;
24 class RectF;
25 }
26
27 namespace chrome {
28 namespace android {
29
30 // Chromium Android specific WebContentsDelegate.
31 // Should contain any WebContentsDelegate implementations required by
32 // the Chromium Android port but not to be shared with WebView.
33 class ChromeWebContentsDelegateAndroid
34     : public web_contents_delegate_android::WebContentsDelegateAndroid,
35       public content::NotificationObserver {
36  public:
37   ChromeWebContentsDelegateAndroid(JNIEnv* env, jobject obj);
38   virtual ~ChromeWebContentsDelegateAndroid();
39
40   virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE;
41   virtual void RunFileChooser(content::WebContents* web_contents,
42                               const content::FileChooserParams& params)
43                               OVERRIDE;
44   virtual void CloseContents(content::WebContents* web_contents) OVERRIDE;
45   virtual void FindReply(content::WebContents* web_contents,
46                          int request_id,
47                          int number_of_matches,
48                          const gfx::Rect& selection_rect,
49                          int active_match_ordinal,
50                          bool final_update) OVERRIDE;
51   virtual void FindMatchRectsReply(content::WebContents* web_contents,
52                                    int version,
53                                    const std::vector<gfx::RectF>& rects,
54                                    const gfx::RectF& active_rect) OVERRIDE;
55   virtual content::JavaScriptDialogManager*
56   GetJavaScriptDialogManager() OVERRIDE;
57   virtual void RequestMediaAccessPermission(
58       content::WebContents* web_contents,
59       const content::MediaStreamRequest& request,
60       const content::MediaResponseCallback& callback) OVERRIDE;
61   virtual bool RequestPpapiBrokerPermission(
62       content::WebContents* web_contents,
63       const GURL& url,
64       const base::FilePath& plugin_path,
65       const base::Callback<void(bool)>& callback) OVERRIDE;
66   virtual content::WebContents* OpenURLFromTab(
67       content::WebContents* source,
68       const content::OpenURLParams& params) OVERRIDE;
69   virtual void AddNewContents(content::WebContents* source,
70                               content::WebContents* new_contents,
71                               WindowOpenDisposition disposition,
72                               const gfx::Rect& initial_pos,
73                               bool user_gesture,
74                               bool* was_blocked) OVERRIDE;
75   virtual void WebContentsCreated(content::WebContents* source_contents,
76                                   int64 source_frame_id,
77                                   const base::string16& frame_name,
78                                   const GURL& target_url,
79                                   content::WebContents* new_contents) OVERRIDE;
80  private:
81   // NotificationObserver implementation.
82   virtual void Observe(int type,
83                        const content::NotificationSource& source,
84                        const content::NotificationDetails& details) OVERRIDE;
85
86   void OnFindResultAvailable(content::WebContents* web_contents,
87                              const FindNotificationDetails* find_result);
88
89   content::NotificationRegistrar notification_registrar_;
90 };
91
92 // Register the native methods through JNI.
93 bool RegisterChromeWebContentsDelegateAndroid(JNIEnv* env);
94
95 }  // namespace android
96 }  // namespace chrome
97
98 #endif  // CHROME_BROWSER_ANDROID_CHROME_WEB_CONTENTS_DELEGATE_ANDROID_H_