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.
5 #ifndef APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_
6 #define APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "content/public/browser/web_contents_delegate.h"
10 #include "content/public/browser/web_contents_observer.h"
11 #include "extensions/browser/extension_function_dispatcher.h"
22 class AppWebContentsHelper
;
24 // Manages the web contents for extension-hosted launcher pages. The
25 // implementation for this class should create and maintain the WebContents for
26 // the page, and handle any message passing between the web contents and the
28 class CustomLauncherPageContents
29 : public content::WebContentsDelegate
,
30 public content::WebContentsObserver
,
31 public extensions::ExtensionFunctionDispatcher::Delegate
{
33 CustomLauncherPageContents(scoped_ptr
<AppDelegate
> app_delegate
,
34 const std::string
& extension_id
);
35 virtual ~CustomLauncherPageContents();
37 // Called to initialize and load the WebContents.
38 void Initialize(content::BrowserContext
* context
, const GURL
& url
);
40 content::WebContents
* web_contents() const { return web_contents_
.get(); }
42 // content::WebContentsDelegate overrides:
43 virtual content::WebContents
* OpenURLFromTab(
44 content::WebContents
* source
,
45 const content::OpenURLParams
& params
) OVERRIDE
;
46 virtual void AddNewContents(content::WebContents
* source
,
47 content::WebContents
* new_contents
,
48 WindowOpenDisposition disposition
,
49 const gfx::Rect
& initial_pos
,
51 bool* was_blocked
) OVERRIDE
;
52 virtual bool IsPopupOrPanel(
53 const content::WebContents
* source
) const OVERRIDE
;
54 virtual bool ShouldSuppressDialogs() OVERRIDE
;
55 virtual bool PreHandleGestureEvent(
56 content::WebContents
* source
,
57 const blink::WebGestureEvent
& event
) OVERRIDE
;
58 virtual content::ColorChooser
* OpenColorChooser(
59 content::WebContents
* web_contents
,
61 const std::vector
<content::ColorSuggestion
>& suggestions
) OVERRIDE
;
62 virtual void RunFileChooser(
63 content::WebContents
* tab
,
64 const content::FileChooserParams
& params
) OVERRIDE
;
65 virtual void RequestToLockMouse(content::WebContents
* web_contents
,
67 bool last_unlocked_by_target
) OVERRIDE
;
68 virtual void RequestMediaAccessPermission(
69 content::WebContents
* web_contents
,
70 const content::MediaStreamRequest
& request
,
71 const content::MediaResponseCallback
& callback
) OVERRIDE
;
74 // content::WebContentsObserver overrides:
75 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
77 // extensions::ExtensionFunctionDispatcher::Delegate overrides:
78 virtual extensions::WindowController
* GetExtensionWindowController()
80 virtual content::WebContents
* GetAssociatedWebContents() const OVERRIDE
;
82 void OnRequest(const ExtensionHostMsg_Request_Params
& params
);
84 scoped_ptr
<content::WebContents
> web_contents_
;
85 scoped_ptr
<extensions::ExtensionFunctionDispatcher
>
86 extension_function_dispatcher_
;
87 scoped_ptr
<AppDelegate
> app_delegate_
;
88 scoped_ptr
<AppWebContentsHelper
> helper_
;
90 std::string extension_id_
;
92 DISALLOW_COPY_AND_ASSIGN(CustomLauncherPageContents
);
97 #endif // APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_