Skia roll 790ffe3:0b36e6b
[chromium-blink-merge.git] / apps / custom_launcher_page_contents.h
blob36e7f79f7114ec6d143c70efae64303b868dabf2
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;
75 private:
76 // content::WebContentsObserver overrides:
77 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
79 // extensions::ExtensionFunctionDispatcher::Delegate overrides:
80 virtual extensions::WindowController* GetExtensionWindowController()
81 const OVERRIDE;
82 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE;
84 void OnRequest(const ExtensionHostMsg_Request_Params& params);
86 scoped_ptr<content::WebContents> web_contents_;
87 scoped_ptr<extensions::ExtensionFunctionDispatcher>
88 extension_function_dispatcher_;
89 scoped_ptr<extensions::AppDelegate> app_delegate_;
90 scoped_ptr<extensions::AppWebContentsHelper> helper_;
92 std::string extension_id_;
94 DISALLOW_COPY_AND_ASSIGN(CustomLauncherPageContents);
97 } // namespace apps
99 #endif // APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_