blob: 36e7f79f7114ec6d143c70efae64303b868dabf2 [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
8#include "base/memory/scoped_ptr.h"
[email protected]96498372014-08-04 13:52:069#include "content/public/browser/web_contents_delegate.h"
[email protected]ec0573392014-07-11 03:49:1110#include "content/public/browser/web_contents_observer.h"
11#include "extensions/browser/extension_function_dispatcher.h"
12
13class GURL;
14
15namespace content {
16class BrowserContext;
17}
18
[email protected]21d3f3a2014-08-20 09:39:5519namespace extensions {
[email protected]96498372014-08-04 13:52:0620class AppDelegate;
21class AppWebContentsHelper;
[email protected]21d3f3a2014-08-20 09:39:5522}
23
24namespace apps {
[email protected]96498372014-08-04 13:52:0625
[email protected]ec0573392014-07-11 03:49:1126// Manages the web contents for extension-hosted launcher pages. The
27// implementation for this class should create and maintain the WebContents for
28// the page, and handle any message passing between the web contents and the
29// extension system.
30class CustomLauncherPageContents
[email protected]96498372014-08-04 13:52:0631 : public content::WebContentsDelegate,
32 public content::WebContentsObserver,
[email protected]ec0573392014-07-11 03:49:1133 public extensions::ExtensionFunctionDispatcher::Delegate {
34 public:
[email protected]21d3f3a2014-08-20 09:39:5535 CustomLauncherPageContents(scoped_ptr<extensions::AppDelegate> app_delegate,
[email protected]96498372014-08-04 13:52:0636 const std::string& extension_id);
[email protected]ec0573392014-07-11 03:49:1137 virtual ~CustomLauncherPageContents();
38
39 // Called to initialize and load the WebContents.
40 void Initialize(content::BrowserContext* context, const GURL& url);
41
42 content::WebContents* web_contents() const { return web_contents_.get(); }
43
[email protected]96498372014-08-04 13:52:0644 // content::WebContentsDelegate overrides:
45 virtual content::WebContents* OpenURLFromTab(
46 content::WebContents* source,
47 const content::OpenURLParams& params) OVERRIDE;
48 virtual void AddNewContents(content::WebContents* source,
49 content::WebContents* new_contents,
50 WindowOpenDisposition disposition,
51 const gfx::Rect& initial_pos,
52 bool user_gesture,
53 bool* was_blocked) OVERRIDE;
54 virtual bool IsPopupOrPanel(
55 const content::WebContents* source) const OVERRIDE;
56 virtual bool ShouldSuppressDialogs() OVERRIDE;
57 virtual bool PreHandleGestureEvent(
58 content::WebContents* source,
59 const blink::WebGestureEvent& event) OVERRIDE;
60 virtual content::ColorChooser* OpenColorChooser(
61 content::WebContents* web_contents,
62 SkColor color,
63 const std::vector<content::ColorSuggestion>& suggestions) OVERRIDE;
64 virtual void RunFileChooser(
65 content::WebContents* tab,
66 const content::FileChooserParams& params) OVERRIDE;
67 virtual void RequestToLockMouse(content::WebContents* web_contents,
68 bool user_gesture,
69 bool last_unlocked_by_target) OVERRIDE;
70 virtual void RequestMediaAccessPermission(
71 content::WebContents* web_contents,
72 const content::MediaStreamRequest& request,
73 const content::MediaResponseCallback& callback) OVERRIDE;
74
[email protected]ec0573392014-07-11 03:49:1175 private:
76 // content::WebContentsObserver overrides:
77 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
78
79 // extensions::ExtensionFunctionDispatcher::Delegate overrides:
80 virtual extensions::WindowController* GetExtensionWindowController()
81 const OVERRIDE;
82 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE;
83
84 void OnRequest(const ExtensionHostMsg_Request_Params& params);
85
86 scoped_ptr<content::WebContents> web_contents_;
87 scoped_ptr<extensions::ExtensionFunctionDispatcher>
88 extension_function_dispatcher_;
[email protected]21d3f3a2014-08-20 09:39:5589 scoped_ptr<extensions::AppDelegate> app_delegate_;
90 scoped_ptr<extensions::AppWebContentsHelper> helper_;
[email protected]96498372014-08-04 13:52:0691
92 std::string extension_id_;
[email protected]ec0573392014-07-11 03:49:1193
94 DISALLOW_COPY_AND_ASSIGN(CustomLauncherPageContents);
95};
96
97} // namespace apps
98
99#endif // APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_