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 ANDROID_WEBVIEW_NATIVE_AW_WEB_CONTENTS_DELEGATE_H_
6#define ANDROID_WEBVIEW_NATIVE_AW_WEB_CONTENTS_DELEGATE_H_
7
8#include <jni.h>
9
10#include "components/web_contents_delegate_android/web_contents_delegate_android.h"
11
12namespace android_webview {
13
14// WebView specific WebContentsDelegate.
15// Should contain WebContentsDelegate code required by WebView that should not
16// be part of the Chromium Android port.
17class AwWebContentsDelegate
18    : public web_contents_delegate_android::WebContentsDelegateAndroid {
19 public:
20  AwWebContentsDelegate(JNIEnv* env, jobject obj);
21  virtual ~AwWebContentsDelegate();
22  virtual content::JavaScriptDialogManager* GetJavaScriptDialogManager()
23      OVERRIDE;
24  virtual void FindReply(content::WebContents* web_contents,
25                         int request_id,
26                         int number_of_matches,
27                         const gfx::Rect& selection_rect,
28                         int active_match_ordinal,
29                         bool final_update) OVERRIDE;
30  virtual void CanDownload(content::RenderViewHost* source,
31                           const GURL& url,
32                           const std::string& request_method,
33                           const base::Callback<void(bool)>& callback) OVERRIDE;
34  virtual void RunFileChooser(
35      content::WebContents* web_contents,
36      const content::FileChooserParams& params) OVERRIDE;
37  virtual void AddNewContents(content::WebContents* source,
38                              content::WebContents* new_contents,
39                              WindowOpenDisposition disposition,
40                              const gfx::Rect& initial_pos,
41                              bool user_gesture,
42                              bool* was_blocked) OVERRIDE;
43
44  virtual void WebContentsCreated(content::WebContents* source_contents,
45                                  int opener_render_frame_id,
46                                  const base::string16& frame_name,
47                                  const GURL& target_url,
48                                  content::WebContents* new_contents) OVERRIDE;
49
50  virtual void CloseContents(content::WebContents* source) OVERRIDE;
51  virtual void ActivateContents(content::WebContents* contents) OVERRIDE;
52  virtual void RequestMediaAccessPermission(
53      content::WebContents* web_contents,
54      const content::MediaStreamRequest& request,
55      const content::MediaResponseCallback& callback) OVERRIDE;
56  virtual void ToggleFullscreenModeForTab(content::WebContents* web_contents,
57                                          bool enter_fullscreen) OVERRIDE;
58  virtual bool IsFullscreenForTabOrPending(
59      const content::WebContents* web_contents) const OVERRIDE;
60
61 private:
62  bool is_fullscreen_;
63};
64
65bool RegisterAwWebContentsDelegate(JNIEnv* env);
66
67}  // namespace android_webview
68
69#endif  // ANDROID_WEBVIEW_NATIVE_AW_WEB_CONTENTS_DELEGATE_H_
70