[email protected] | ec057339 | 2014-07-11 03:49:11 | [diff] [blame] | 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 | |
| 5 | #ifndef APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_ |
| 6 | #define APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_ |
| 7 | |
mostynb | ecb4a22b | 2016-04-04 06:08:01 | [diff] [blame] | 8 | #include <memory> |
| 9 | |
[email protected] | 9649837 | 2014-08-04 13:52:06 | [diff] [blame] | 10 | #include "content/public/browser/web_contents_delegate.h" |
[email protected] | ec057339 | 2014-07-11 03:49:11 | [diff] [blame] | 11 | |
| 12 | class GURL; |
| 13 | |
| 14 | namespace content { |
| 15 | class BrowserContext; |
| 16 | } |
| 17 | |
[email protected] | 21d3f3a | 2014-08-20 09:39:55 | [diff] [blame] | 18 | namespace extensions { |
[email protected] | 9649837 | 2014-08-04 13:52:06 | [diff] [blame] | 19 | class AppDelegate; |
| 20 | class AppWebContentsHelper; |
[email protected] | 21d3f3a | 2014-08-20 09:39:55 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | namespace apps { |
[email protected] | 9649837 | 2014-08-04 13:52:06 | [diff] [blame] | 24 | |
[email protected] | ec057339 | 2014-07-11 03:49:11 | [diff] [blame] | 25 | // 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.cronin | cb2ec659a | 2015-06-10 23:32:41 | [diff] [blame] | 29 | class CustomLauncherPageContents : public content::WebContentsDelegate { |
[email protected] | ec057339 | 2014-07-11 03:49:11 | [diff] [blame] | 30 | public: |
mostynb | ecb4a22b | 2016-04-04 06:08:01 | [diff] [blame] | 31 | CustomLauncherPageContents( |
| 32 | std::unique_ptr<extensions::AppDelegate> app_delegate, |
| 33 | const std::string& extension_id); |
dcheng | 2f5be41 | 2014-10-22 01:46:08 | [diff] [blame] | 34 | ~CustomLauncherPageContents() override; |
[email protected] | ec057339 | 2014-07-11 03:49:11 | [diff] [blame] | 35 | |
| 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] | 9649837 | 2014-08-04 13:52:06 | [diff] [blame] | 41 | // content::WebContentsDelegate overrides: |
dcheng | 2f5be41 | 2014-10-22 01:46:08 | [diff] [blame] | 42 | content::WebContents* OpenURLFromTab( |
[email protected] | 9649837 | 2014-08-04 13:52:06 | [diff] [blame] | 43 | content::WebContents* source, |
anand.ratn | c7a46564 | 2014-10-09 05:55:01 | [diff] [blame] | 44 | const content::OpenURLParams& params) override; |
dcheng | 2f5be41 | 2014-10-22 01:46:08 | [diff] [blame] | 45 | void AddNewContents(content::WebContents* source, |
| 46 | content::WebContents* new_contents, |
| 47 | WindowOpenDisposition disposition, |
bokan | 107a47f | 2015-02-03 23:23:39 | [diff] [blame] | 48 | const gfx::Rect& initial_rect, |
dcheng | 2f5be41 | 2014-10-22 01:46:08 | [diff] [blame] | 49 | bool user_gesture, |
| 50 | bool* was_blocked) override; |
| 51 | bool IsPopupOrPanel(const content::WebContents* source) const override; |
mathiash | 72a5e46 | 2014-11-19 08:18:50 | [diff] [blame] | 52 | bool ShouldSuppressDialogs(content::WebContents* source) override; |
dcheng | 2f5be41 | 2014-10-22 01:46:08 | [diff] [blame] | 53 | bool PreHandleGestureEvent(content::WebContents* source, |
| 54 | const blink::WebGestureEvent& event) override; |
| 55 | content::ColorChooser* OpenColorChooser( |
[email protected] | 9649837 | 2014-08-04 13:52:06 | [diff] [blame] | 56 | content::WebContents* web_contents, |
| 57 | SkColor color, |
anand.ratn | c7a46564 | 2014-10-09 05:55:01 | [diff] [blame] | 58 | const std::vector<content::ColorSuggestion>& suggestions) override; |
dcheng | 2f5be41 | 2014-10-22 01:46:08 | [diff] [blame] | 59 | 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] | 9649837 | 2014-08-04 13:52:06 | [diff] [blame] | 65 | content::WebContents* web_contents, |
| 66 | const content::MediaStreamRequest& request, |
anand.ratn | c7a46564 | 2014-10-09 05:55:01 | [diff] [blame] | 67 | const content::MediaResponseCallback& callback) override; |
dcheng | 2f5be41 | 2014-10-22 01:46:08 | [diff] [blame] | 68 | bool CheckMediaAccessPermission(content::WebContents* web_contents, |
| 69 | const GURL& security_origin, |
| 70 | content::MediaStreamType type) override; |
[email protected] | 9649837 | 2014-08-04 13:52:06 | [diff] [blame] | 71 | |
[email protected] | ec057339 | 2014-07-11 03:49:11 | [diff] [blame] | 72 | private: |
mostynb | ecb4a22b | 2016-04-04 06:08:01 | [diff] [blame] | 73 | std::unique_ptr<content::WebContents> web_contents_; |
| 74 | std::unique_ptr<extensions::AppDelegate> app_delegate_; |
| 75 | std::unique_ptr<extensions::AppWebContentsHelper> helper_; |
[email protected] | 9649837 | 2014-08-04 13:52:06 | [diff] [blame] | 76 | |
| 77 | std::string extension_id_; |
[email protected] | ec057339 | 2014-07-11 03:49:11 | [diff] [blame] | 78 | |
| 79 | DISALLOW_COPY_AND_ASSIGN(CustomLauncherPageContents); |
| 80 | }; |
| 81 | |
| 82 | } // namespace apps |
| 83 | |
| 84 | #endif // APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_ |