Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_ | 5 #ifndef APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_ |
| 6 #define APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_ | 6 #define APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "content/public/browser/web_contents_delegate.h" | |
| 9 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
| 10 #include "extensions/browser/extension_function_dispatcher.h" | 11 #include "extensions/browser/extension_function_dispatcher.h" |
| 11 | 12 |
| 12 class GURL; | 13 class GURL; |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 class BrowserContext; | 16 class BrowserContext; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace apps { | 19 namespace apps { |
| 19 | 20 |
| 21 class AppDelegate; | |
| 22 class AppWebContentsHelper; | |
| 23 | |
| 20 // Manages the web contents for extension-hosted launcher pages. The | 24 // Manages the web contents for extension-hosted launcher pages. The |
| 21 // implementation for this class should create and maintain the WebContents for | 25 // implementation for this class should create and maintain the WebContents for |
| 22 // the page, and handle any message passing between the web contents and the | 26 // the page, and handle any message passing between the web contents and the |
| 23 // extension system. | 27 // extension system. |
| 24 class CustomLauncherPageContents | 28 class CustomLauncherPageContents |
| 25 : public content::WebContentsObserver, | 29 : public content::WebContentsDelegate, |
| 30 public content::WebContentsObserver, | |
| 26 public extensions::ExtensionFunctionDispatcher::Delegate { | 31 public extensions::ExtensionFunctionDispatcher::Delegate { |
| 27 public: | 32 public: |
| 28 CustomLauncherPageContents(); | 33 // Takes ownership of |app_delegate|. |
| 34 CustomLauncherPageContents(AppDelegate* app_delegate, | |
|
benwells
2014/08/04 02:35:20
If you make this a scoped_ptr<AppDelegate> it will
Matt Giuca
2014/08/04 06:25:58
Done.
(After discussing with Sam about how to do
benwells
2014/08/04 06:53:16
Yes was what I meant. I'm not sure if you've got t
| |
| 35 const std::string& extension_id); | |
| 29 virtual ~CustomLauncherPageContents(); | 36 virtual ~CustomLauncherPageContents(); |
| 30 | 37 |
| 31 // Called to initialize and load the WebContents. | 38 // Called to initialize and load the WebContents. |
| 32 void Initialize(content::BrowserContext* context, const GURL& url); | 39 void Initialize(content::BrowserContext* context, const GURL& url); |
| 33 | 40 |
| 34 content::WebContents* web_contents() const { return web_contents_.get(); } | 41 content::WebContents* web_contents() const { return web_contents_.get(); } |
| 35 | 42 |
| 43 // content::WebContentsDelegate overrides: | |
| 44 virtual content::WebContents* OpenURLFromTab( | |
| 45 content::WebContents* source, | |
| 46 const content::OpenURLParams& params) OVERRIDE; | |
| 47 virtual void AddNewContents(content::WebContents* source, | |
| 48 content::WebContents* new_contents, | |
| 49 WindowOpenDisposition disposition, | |
| 50 const gfx::Rect& initial_pos, | |
| 51 bool user_gesture, | |
| 52 bool* was_blocked) OVERRIDE; | |
| 53 virtual bool IsPopupOrPanel( | |
| 54 const content::WebContents* source) const OVERRIDE; | |
| 55 virtual bool ShouldSuppressDialogs() OVERRIDE; | |
| 56 virtual bool PreHandleGestureEvent( | |
| 57 content::WebContents* source, | |
| 58 const blink::WebGestureEvent& event) OVERRIDE; | |
| 59 virtual content::ColorChooser* OpenColorChooser( | |
| 60 content::WebContents* web_contents, | |
| 61 SkColor color, | |
| 62 const std::vector<content::ColorSuggestion>& suggestions) OVERRIDE; | |
| 63 virtual void RunFileChooser( | |
| 64 content::WebContents* tab, | |
| 65 const content::FileChooserParams& params) OVERRIDE; | |
| 66 virtual void RequestToLockMouse(content::WebContents* web_contents, | |
| 67 bool user_gesture, | |
| 68 bool last_unlocked_by_target) OVERRIDE; | |
| 69 virtual void RequestMediaAccessPermission( | |
| 70 content::WebContents* web_contents, | |
| 71 const content::MediaStreamRequest& request, | |
| 72 const content::MediaResponseCallback& callback) OVERRIDE; | |
| 73 | |
| 36 private: | 74 private: |
| 37 // content::WebContentsObserver overrides: | 75 // content::WebContentsObserver overrides: |
| 38 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 76 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 39 | 77 |
| 40 // extensions::ExtensionFunctionDispatcher::Delegate overrides: | 78 // extensions::ExtensionFunctionDispatcher::Delegate overrides: |
| 41 virtual extensions::WindowController* GetExtensionWindowController() | 79 virtual extensions::WindowController* GetExtensionWindowController() |
| 42 const OVERRIDE; | 80 const OVERRIDE; |
| 43 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; | 81 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; |
| 44 | 82 |
| 45 void OnRequest(const ExtensionHostMsg_Request_Params& params); | 83 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
| 46 | 84 |
| 47 scoped_ptr<content::WebContents> web_contents_; | 85 scoped_ptr<content::WebContents> web_contents_; |
| 48 scoped_ptr<extensions::ExtensionFunctionDispatcher> | 86 scoped_ptr<extensions::ExtensionFunctionDispatcher> |
| 49 extension_function_dispatcher_; | 87 extension_function_dispatcher_; |
| 88 scoped_ptr<AppDelegate> app_delegate_; | |
| 89 scoped_ptr<AppWebContentsHelper> helper_; | |
| 90 | |
| 91 std::string extension_id_; | |
| 50 | 92 |
| 51 DISALLOW_COPY_AND_ASSIGN(CustomLauncherPageContents); | 93 DISALLOW_COPY_AND_ASSIGN(CustomLauncherPageContents); |
| 52 }; | 94 }; |
| 53 | 95 |
| 54 } // namespace apps | 96 } // namespace apps |
| 55 | 97 |
| 56 #endif // APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_ | 98 #endif // APPS_CUSTOM_LAUNCHER_PAGE_CONTENTS_H_ |
| OLD | NEW |