Service Worker: Remove legacy code for resolving register() to a version
[chromium-blink-merge.git] / apps / custom_launcher_page_contents.h
blobeaa7673a56144a106171b5c97dad178ac6da4ec9
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"
13 class GURL;
15 namespace content {
16 class BrowserContext;
19 namespace extensions {
20 class AppDelegate;
21 class AppWebContentsHelper;
24 namespace apps {
26 // 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.
30 class CustomLauncherPageContents
31 : public content::WebContentsDelegate,
32 public content::WebContentsObserver,
33 public extensions::ExtensionFunctionDispatcher::Delegate {
34 public:
35 CustomLauncherPageContents(scoped_ptr<extensions::AppDelegate> app_delegate,
36 const std::string& extension_id);
37 virtual ~CustomLauncherPageContents();
39 // Called to initialize and load the WebContents.
40 void Initialize(content::BrowserContext* context, const GURL& url);
42 content::WebContents* web_contents() const { return web_contents_.get(); }
44 // 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 virtual bool CheckMediaAccessPermission(
75 content::WebContents* web_contents,
76 const GURL& security_origin,
77 content::MediaStreamType type) OVERRIDE;
79 private:
80 // content::WebContentsObserver overrides:
81 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
83 // extensions::ExtensionFunctionDispatcher::Delegate overrides:
84 virtual extensions::WindowController* GetExtensionWindowController()
85 const OVERRIDE;
86 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE;
88 void OnRequest(const ExtensionHostMsg_Request_Params& params);
90 scoped_ptr<content::WebContents> web_contents_;
91 scoped_ptr<extensions::ExtensionFunctionDispatcher>
92 extension_function_dispatcher_;
93 scoped_ptr<extensions::AppDelegate> app_delegate_;
94 scoped_ptr<extensions::AppWebContentsHelper> helper_;
96 std::string extension_id_;
98 DISALLOW_COPY_AND_ASSIGN(CustomLauncherPageContents);
101 } // namespace apps
103 #endif // APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_