OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_RENDERER_EXTENSIONS_EXTENSION_HELPER_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_EXTENSION_HELPER_H_ |
6 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_HELPER_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
| 11 #include "content/renderer/render_view.h" |
11 #include "content/renderer/render_view_observer.h" | 12 #include "content/renderer/render_view_observer.h" |
| 13 #include "content/renderer/render_view_observer_tracker.h" |
12 | 14 |
13 class ExtensionDispatcher; | 15 class ExtensionDispatcher; |
14 class GURL; | 16 class GURL; |
15 class ListValue; | 17 class ListValue; |
16 struct ExtensionMsg_ExecuteCode_Params; | 18 struct ExtensionMsg_ExecuteCode_Params; |
| 19 struct WebApplicationInfo; |
| 20 |
| 21 namespace webkit_glue { |
| 22 class ResourceFetcher; |
| 23 } |
17 | 24 |
18 // Filters extension related messages sent to RenderViews. | 25 // Filters extension related messages sent to RenderViews. |
19 class ExtensionHelper : public RenderViewObserver { | 26 class ExtensionHelper : public RenderViewObserver, |
| 27 public RenderViewObserverTracker<ExtensionHelper> { |
20 public: | 28 public: |
21 ExtensionHelper(RenderView* render_view, | 29 ExtensionHelper(RenderView* render_view, |
22 ExtensionDispatcher* extension_dispatcher); | 30 ExtensionDispatcher* extension_dispatcher); |
23 virtual ~ExtensionHelper(); | 31 virtual ~ExtensionHelper(); |
24 | 32 |
| 33 // Starts installation of the page in the specified frame as a web app. The |
| 34 // page must link to an external 'definition file'. This is different from |
| 35 // the 'application shortcuts' feature where we pull the application |
| 36 // definition out of optional meta tags in the page. |
| 37 bool InstallWebApplicationUsingDefinitionFile(WebKit::WebFrame* frame, |
| 38 string16* error); |
| 39 |
25 private: | 40 private: |
26 // RenderViewObserver implementation. | 41 // RenderViewObserver implementation. |
27 virtual bool OnMessageReceived(const IPC::Message& message); | 42 virtual bool OnMessageReceived(const IPC::Message& message); |
28 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame); | 43 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame); |
29 virtual void DidFinishLoad(WebKit::WebFrame* frame); | 44 virtual void DidFinishLoad(WebKit::WebFrame* frame); |
30 virtual void DidCreateDocumentElement(WebKit::WebFrame* frame); | 45 virtual void DidCreateDocumentElement(WebKit::WebFrame* frame); |
31 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame); | 46 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame); |
32 virtual void FrameDetached(WebKit::WebFrame* frame); | 47 virtual void FrameDetached(WebKit::WebFrame* frame); |
33 virtual void DidCreateDataSource(WebKit::WebFrame* frame, | 48 virtual void DidCreateDataSource(WebKit::WebFrame* frame, |
34 WebKit::WebDataSource* ds); | 49 WebKit::WebDataSource* ds); |
35 | 50 |
36 void OnExtensionResponse(int request_id, bool success, | 51 void OnExtensionResponse(int request_id, bool success, |
37 const std::string& response, | 52 const std::string& response, |
38 const std::string& error); | 53 const std::string& error); |
39 void OnExtensionMessageInvoke(const std::string& extension_id, | 54 void OnExtensionMessageInvoke(const std::string& extension_id, |
40 const std::string& function_name, | 55 const std::string& function_name, |
41 const ListValue& args, | 56 const ListValue& args, |
42 const GURL& event_url); | 57 const GURL& event_url); |
43 void OnExecuteCode(const ExtensionMsg_ExecuteCode_Params& params); | 58 void OnExecuteCode(const ExtensionMsg_ExecuteCode_Params& params); |
| 59 void OnGetApplicationInfo(int page_id); |
| 60 |
| 61 // Callback triggered when we finish downloading the application definition |
| 62 // file. |
| 63 void DidDownloadApplicationDefinition(const WebKit::WebURLResponse& response, |
| 64 const std::string& data); |
| 65 |
| 66 // Callback triggered after each icon referenced by the application definition |
| 67 // is downloaded. |
| 68 void DidDownloadApplicationIcon(webkit_glue::ImageResourceFetcher* fetcher, |
| 69 const SkBitmap& image); |
| 70 |
| 71 // Helper to add an error message to the root frame's console. |
| 72 void AddErrorToRootConsole(const string16& message); |
44 | 73 |
45 ExtensionDispatcher* extension_dispatcher_; | 74 ExtensionDispatcher* extension_dispatcher_; |
46 | 75 |
| 76 // The app info that we are processing. This is used when installing an app |
| 77 // via application definition. The in-progress web app is stored here while |
| 78 // its manifest and icons are downloaded. |
| 79 scoped_ptr<WebApplicationInfo> pending_app_info_; |
| 80 |
| 81 // Used to download the application definition file. |
| 82 scoped_ptr<webkit_glue::ResourceFetcher> app_definition_fetcher_; |
| 83 |
| 84 // Used to download the icons for an application. |
| 85 RenderView::ImageResourceFetcherList app_icon_fetchers_; |
| 86 |
| 87 // The number of app icon requests outstanding. When this reaches zero, we're |
| 88 // done processing an app definition file. |
| 89 int pending_app_icon_requests_; |
| 90 |
47 DISALLOW_COPY_AND_ASSIGN(ExtensionHelper); | 91 DISALLOW_COPY_AND_ASSIGN(ExtensionHelper); |
48 }; | 92 }; |
49 | 93 |
50 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_HELPER_H_ | 94 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_HELPER_H_ |
OLD | NEW |