Add diagnostics_writer.cc to the list of files allowed to printf.
[chromium-blink-merge.git] / apps / custom_launcher_page_contents.h
blob38e1cda56f283e077c2f634eee17d1380834083e
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 apps {
21 class AppDelegate;
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
27 // extension system.
28 class CustomLauncherPageContents
29 : public content::WebContentsDelegate,
30 public content::WebContentsObserver,
31 public extensions::ExtensionFunctionDispatcher::Delegate {
32 public:
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,
50 bool user_gesture,
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,
60 SkColor color,
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,
66 bool user_gesture,
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;
73 private:
74 // content::WebContentsObserver overrides:
75 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
77 // extensions::ExtensionFunctionDispatcher::Delegate overrides:
78 virtual extensions::WindowController* GetExtensionWindowController()
79 const OVERRIDE;
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);
95 } // namespace apps
97 #endif // APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_