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 CHROME_BROWSER_ANDROID_CHROME_WEB_CONTENTS_DELEGATE_ANDROID_H_
6 #define CHROME_BROWSER_ANDROID_CHROME_WEB_CONTENTS_DELEGATE_ANDROID_H_
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"
15 class FindNotificationDetails;
18 struct FileChooserParams;
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 {
37 ChromeWebContentsDelegateAndroid(JNIEnv* env, jobject obj);
38 virtual ~ChromeWebContentsDelegateAndroid();
40 virtual void RunFileChooser(content::WebContents* web_contents,
41 const content::FileChooserParams& params)
43 virtual void CloseContents(content::WebContents* web_contents) OVERRIDE;
44 virtual void FindReply(content::WebContents* web_contents,
46 int number_of_matches,
47 const gfx::Rect& selection_rect,
48 int active_match_ordinal,
49 bool final_update) OVERRIDE;
50 virtual void FindMatchRectsReply(content::WebContents* web_contents,
52 const std::vector<gfx::RectF>& rects,
53 const gfx::RectF& active_rect) OVERRIDE;
54 virtual content::JavaScriptDialogManager*
55 GetJavaScriptDialogManager() OVERRIDE;
56 virtual void RequestMediaAccessPermission(
57 content::WebContents* web_contents,
58 const content::MediaStreamRequest& request,
59 const content::MediaResponseCallback& callback) OVERRIDE;
60 virtual bool RequestPpapiBrokerPermission(
61 content::WebContents* web_contents,
63 const base::FilePath& plugin_path,
64 const base::Callback<void(bool)>& callback) OVERRIDE;
65 virtual content::WebContents* OpenURLFromTab(
66 content::WebContents* source,
67 const content::OpenURLParams& params) OVERRIDE;
68 virtual void AddNewContents(content::WebContents* source,
69 content::WebContents* new_contents,
70 WindowOpenDisposition disposition,
71 const gfx::Rect& initial_pos,
73 bool* was_blocked) OVERRIDE;
74 virtual void RequestProtectedMediaIdentifierPermission(
75 const content::WebContents* web_contents,
76 const GURL& frame_url,
77 const base::Callback<void(bool)>& callback) OVERRIDE;
80 // NotificationObserver implementation.
81 virtual void Observe(int type,
82 const content::NotificationSource& source,
83 const content::NotificationDetails& details) OVERRIDE;
85 void OnFindResultAvailable(content::WebContents* web_contents,
86 const FindNotificationDetails* find_result);
88 content::NotificationRegistrar notification_registrar_;
91 // Register the native methods through JNI.
92 bool RegisterChromeWebContentsDelegateAndroid(JNIEnv* env);
94 } // namespace android
97 #endif // CHROME_BROWSER_ANDROID_CHROME_WEB_CONTENTS_DELEGATE_ANDROID_H_