blob: b5522873ebc2b39f5f52869783feccef6848d1bf [file] [log] [blame]
[email protected]ec0573392014-07-11 03:49:111// 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
5#ifndef APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_
6#define APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_
7
mostynbecb4a22b2016-04-04 06:08:018#include <memory>
9
[email protected]96498372014-08-04 13:52:0610#include "content/public/browser/web_contents_delegate.h"
[email protected]ec0573392014-07-11 03:49:1111
12class GURL;
13
14namespace content {
15class BrowserContext;
16}
17
[email protected]21d3f3a2014-08-20 09:39:5518namespace extensions {
[email protected]96498372014-08-04 13:52:0619class AppDelegate;
20class AppWebContentsHelper;
[email protected]21d3f3a2014-08-20 09:39:5521}
22
23namespace apps {
[email protected]96498372014-08-04 13:52:0624
[email protected]ec0573392014-07-11 03:49:1125// Manages the web contents for extension-hosted launcher pages. The
26// implementation for this class should create and maintain the WebContents for
27// the page, and handle any message passing between the web contents and the
28// extension system.
rdevlin.cronincb2ec659a2015-06-10 23:32:4129class CustomLauncherPageContents : public content::WebContentsDelegate {
[email protected]ec0573392014-07-11 03:49:1130 public:
mostynbecb4a22b2016-04-04 06:08:0131 CustomLauncherPageContents(
32 std::unique_ptr<extensions::AppDelegate> app_delegate,
33 const std::string& extension_id);
dcheng2f5be412014-10-22 01:46:0834 ~CustomLauncherPageContents() override;
[email protected]ec0573392014-07-11 03:49:1135
36 // Called to initialize and load the WebContents.
37 void Initialize(content::BrowserContext* context, const GURL& url);
38
39 content::WebContents* web_contents() const { return web_contents_.get(); }
40
[email protected]96498372014-08-04 13:52:0641 // content::WebContentsDelegate overrides:
dcheng2f5be412014-10-22 01:46:0842 content::WebContents* OpenURLFromTab(
[email protected]96498372014-08-04 13:52:0643 content::WebContents* source,
anand.ratnc7a465642014-10-09 05:55:0144 const content::OpenURLParams& params) override;
dcheng2f5be412014-10-22 01:46:0845 void AddNewContents(content::WebContents* source,
46 content::WebContents* new_contents,
47 WindowOpenDisposition disposition,
bokan107a47f2015-02-03 23:23:3948 const gfx::Rect& initial_rect,
dcheng2f5be412014-10-22 01:46:0849 bool user_gesture,
50 bool* was_blocked) override;
51 bool IsPopupOrPanel(const content::WebContents* source) const override;
mathiash72a5e462014-11-19 08:18:5052 bool ShouldSuppressDialogs(content::WebContents* source) override;
dcheng2f5be412014-10-22 01:46:0853 bool PreHandleGestureEvent(content::WebContents* source,
54 const blink::WebGestureEvent& event) override;
55 content::ColorChooser* OpenColorChooser(
[email protected]96498372014-08-04 13:52:0656 content::WebContents* web_contents,
57 SkColor color,
anand.ratnc7a465642014-10-09 05:55:0158 const std::vector<content::ColorSuggestion>& suggestions) override;
dcheng2f5be412014-10-22 01:46:0859 void RunFileChooser(content::WebContents* tab,
60 const content::FileChooserParams& params) override;
61 void RequestToLockMouse(content::WebContents* web_contents,
62 bool user_gesture,
63 bool last_unlocked_by_target) override;
64 void RequestMediaAccessPermission(
[email protected]96498372014-08-04 13:52:0665 content::WebContents* web_contents,
66 const content::MediaStreamRequest& request,
anand.ratnc7a465642014-10-09 05:55:0167 const content::MediaResponseCallback& callback) override;
dcheng2f5be412014-10-22 01:46:0868 bool CheckMediaAccessPermission(content::WebContents* web_contents,
69 const GURL& security_origin,
70 content::MediaStreamType type) override;
[email protected]96498372014-08-04 13:52:0671
[email protected]ec0573392014-07-11 03:49:1172 private:
mostynbecb4a22b2016-04-04 06:08:0173 std::unique_ptr<content::WebContents> web_contents_;
74 std::unique_ptr<extensions::AppDelegate> app_delegate_;
75 std::unique_ptr<extensions::AppWebContentsHelper> helper_;
[email protected]96498372014-08-04 13:52:0676
77 std::string extension_id_;
[email protected]ec0573392014-07-11 03:49:1178
79 DISALLOW_COPY_AND_ASSIGN(CustomLauncherPageContents);
80};
81
82} // namespace apps
83
84#endif // APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_