aw_web_contents_delegate.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. #ifndef ANDROID_WEBVIEW_BROWSER_AW_WEB_CONTENTS_DELEGATE_H_
  5. #define ANDROID_WEBVIEW_BROWSER_AW_WEB_CONTENTS_DELEGATE_H_
  6. #include "components/embedder_support/android/delegate/web_contents_delegate_android.h"
  7. namespace android_webview {
  8. // WebView specific WebContentsDelegate.
  9. // Should contain WebContentsDelegate code required by WebView that should not
  10. // be part of the Chromium Android port.
  11. class AwWebContentsDelegate
  12. : public web_contents_delegate_android::WebContentsDelegateAndroid {
  13. public:
  14. AwWebContentsDelegate(JNIEnv* env, jobject obj);
  15. ~AwWebContentsDelegate() override;
  16. void RendererUnresponsive(
  17. content::WebContents* source,
  18. content::RenderWidgetHost* render_widget_host,
  19. base::RepeatingClosure hang_monitor_restarter) override;
  20. void RendererResponsive(
  21. content::WebContents* source,
  22. content::RenderWidgetHost* render_widget_host) override;
  23. content::JavaScriptDialogManager* GetJavaScriptDialogManager(
  24. content::WebContents* source) override;
  25. void FindReply(content::WebContents* web_contents,
  26. int request_id,
  27. int number_of_matches,
  28. const gfx::Rect& selection_rect,
  29. int active_match_ordinal,
  30. bool final_update) override;
  31. void RunFileChooser(content::RenderFrameHost* render_frame_host,
  32. scoped_refptr<content::FileSelectListener> listener,
  33. const blink::mojom::FileChooserParams& params) override;
  34. // See //android_webview/docs/how-does-on-create-window-work.md for more
  35. // details.
  36. void AddNewContents(content::WebContents* source,
  37. std::unique_ptr<content::WebContents> new_contents,
  38. const GURL& target_url,
  39. WindowOpenDisposition disposition,
  40. const gfx::Rect& initial_rect,
  41. bool user_gesture,
  42. bool* was_blocked) override;
  43. void NavigationStateChanged(content::WebContents* source,
  44. content::InvalidateTypes changed_flags) override;
  45. void WebContentsCreated(content::WebContents* source_contents,
  46. int opener_render_process_id,
  47. int opener_render_frame_id,
  48. const std::string& frame_name,
  49. const GURL& target_url,
  50. content::WebContents* new_contents) override;
  51. void CloseContents(content::WebContents* source) override;
  52. void ActivateContents(content::WebContents* contents) override;
  53. void LoadingStateChanged(content::WebContents* source,
  54. bool to_different_document) override;
  55. bool ShouldResumeRequestsForCreatedWindow() override;
  56. void RequestMediaAccessPermission(
  57. content::WebContents* web_contents,
  58. const content::MediaStreamRequest& request,
  59. content::MediaResponseCallback callback) override;
  60. void EnterFullscreenModeForTab(
  61. content::RenderFrameHost* requesting_frame,
  62. const blink::mojom::FullscreenOptions& options) override;
  63. void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
  64. bool IsFullscreenForTabOrPending(
  65. const content::WebContents* web_contents) override;
  66. void UpdateUserGestureCarryoverInfo(
  67. content::WebContents* web_contents) override;
  68. scoped_refptr<content::FileSelectListener> TakeFileSelectListener();
  69. private:
  70. bool is_fullscreen_;
  71. // Maintain a FileSelectListener instance passed to RunFileChooser() until
  72. // a callback is called.
  73. scoped_refptr<content::FileSelectListener> file_select_listener_;
  74. };
  75. } // namespace android_webview
  76. #endif // ANDROID_WEBVIEW_BROWSER_AW_WEB_CONTENTS_DELEGATE_H_