shell_app_delegate.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2014 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 EXTENSIONS_SHELL_BROWSER_SHELL_APP_DELEGATE_H_
  5. #define EXTENSIONS_SHELL_BROWSER_SHELL_APP_DELEGATE_H_
  6. #include "content/public/browser/web_contents_observer.h"
  7. #include "extensions/browser/app_window/app_delegate.h"
  8. namespace extensions {
  9. // AppDelegate implementation for app_shell. Sets focus after the WebContents is
  10. // created. Ignores most operations that would create a new dialog or window.
  11. class ShellAppDelegate : public AppDelegate {
  12. public:
  13. ShellAppDelegate();
  14. ShellAppDelegate(const ShellAppDelegate&) = delete;
  15. ShellAppDelegate& operator=(const ShellAppDelegate&) = delete;
  16. ~ShellAppDelegate() override;
  17. // AppDelegate overrides:
  18. void InitWebContents(content::WebContents* web_contents) override;
  19. void RenderFrameCreated(content::RenderFrameHost* frame_host) override;
  20. void ResizeWebContents(content::WebContents* web_contents,
  21. const gfx::Size& size) override;
  22. content::WebContents* OpenURLFromTab(
  23. content::BrowserContext* context,
  24. content::WebContents* source,
  25. const content::OpenURLParams& params) override;
  26. void AddNewContents(content::BrowserContext* context,
  27. std::unique_ptr<content::WebContents> new_contents,
  28. const GURL& target_url,
  29. WindowOpenDisposition disposition,
  30. const gfx::Rect& initial_rect,
  31. bool user_gesture) override;
  32. void RunFileChooser(content::RenderFrameHost* render_frame_host,
  33. scoped_refptr<content::FileSelectListener> listener,
  34. const blink::mojom::FileChooserParams& params) override;
  35. void RequestMediaAccessPermission(content::WebContents* web_contents,
  36. const content::MediaStreamRequest& request,
  37. content::MediaResponseCallback callback,
  38. const Extension* extension) override;
  39. bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host,
  40. const GURL& security_origin,
  41. blink::mojom::MediaStreamType type,
  42. const Extension* extension) override;
  43. int PreferredIconSize() const override;
  44. void SetWebContentsBlocked(content::WebContents* web_contents,
  45. bool blocked) override;
  46. bool IsWebContentsVisible(content::WebContents* web_contents) override;
  47. void SetTerminatingCallback(base::OnceClosure callback) override;
  48. void OnHide() override {}
  49. void OnShow() override {}
  50. bool TakeFocus(content::WebContents* web_contents, bool reverse) override;
  51. content::PictureInPictureResult EnterPictureInPicture(
  52. content::WebContents* web_contents) override;
  53. void ExitPictureInPicture() override;
  54. };
  55. } // namespace extensions
  56. #endif // EXTENSIONS_SHELL_BROWSER_SHELL_APP_DELEGATE_H_