OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "chrome/common/view_type.h" | 13 #include "chrome/common/view_type.h" |
14 #include "content/public/common/console_message_level.h" | 14 #include "content/public/common/console_message_level.h" |
15 #include "content/public/renderer/render_view_observer.h" | 15 #include "content/public/renderer/render_view_observer.h" |
16 #include "content/public/renderer/render_view_observer_tracker.h" | 16 #include "content/public/renderer/render_view_observer_tracker.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon
se.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon
se.h" |
18 | 18 |
19 class ExtensionDispatcher; | |
20 class GURL; | 19 class GURL; |
21 class SkBitmap; | 20 class SkBitmap; |
22 struct ExtensionMsg_ExecuteCode_Params; | 21 struct ExtensionMsg_ExecuteCode_Params; |
23 struct WebApplicationInfo; | 22 struct WebApplicationInfo; |
24 | 23 |
25 namespace base { | 24 namespace base { |
26 class ListValue; | 25 class ListValue; |
27 } | 26 } |
28 | 27 |
29 namespace webkit_glue { | 28 namespace webkit_glue { |
30 class ResourceFetcher; | 29 class ResourceFetcher; |
31 class ImageResourceFetcher; | 30 class ImageResourceFetcher; |
32 } | 31 } |
33 | 32 |
| 33 namespace extensions { |
| 34 class Dispatcher; |
| 35 |
34 // RenderView-level plumbing for extension features. | 36 // RenderView-level plumbing for extension features. |
35 class ExtensionHelper | 37 class ExtensionHelper |
36 : public content::RenderViewObserver, | 38 : public content::RenderViewObserver, |
37 public content::RenderViewObserverTracker<ExtensionHelper> { | 39 public content::RenderViewObserverTracker<ExtensionHelper> { |
38 public: | 40 public: |
39 // Returns a list of extension RenderViews that match the given filter | 41 // Returns a list of extension RenderViews that match the given filter |
40 // criteria. If |browser_window_id| is not extension_misc::kUnknownWindowId, | 42 // criteria. If |browser_window_id| is not extension_misc::kUnknownWindowId, |
41 // the list is restricted to views in that browser window. | 43 // the list is restricted to views in that browser window. |
42 static std::vector<content::RenderView*> GetExtensionViews( | 44 static std::vector<content::RenderView*> GetExtensionViews( |
43 const std::string& extension_id, | 45 const std::string& extension_id, |
44 int browser_window_id, | 46 int browser_window_id, |
45 chrome::ViewType view_type); | 47 chrome::ViewType view_type); |
46 | 48 |
47 // Returns the given extension's background page, or NULL if none. | 49 // Returns the given extension's background page, or NULL if none. |
48 static content::RenderView* GetBackgroundPage( | 50 static content::RenderView* GetBackgroundPage( |
49 const std::string& extension_id); | 51 const std::string& extension_id); |
50 | 52 |
51 ExtensionHelper(content::RenderView* render_view, | 53 ExtensionHelper(content::RenderView* render_view, Dispatcher* dispatcher); |
52 ExtensionDispatcher* extension_dispatcher); | |
53 virtual ~ExtensionHelper(); | 54 virtual ~ExtensionHelper(); |
54 | 55 |
55 // Starts installation of the page in the specified frame as a web app. The | 56 // Starts installation of the page in the specified frame as a web app. The |
56 // page must link to an external 'definition file'. This is different from | 57 // page must link to an external 'definition file'. This is different from |
57 // the 'application shortcuts' feature where we pull the application | 58 // the 'application shortcuts' feature where we pull the application |
58 // definition out of optional meta tags in the page. | 59 // definition out of optional meta tags in the page. |
59 bool InstallWebApplicationUsingDefinitionFile(WebKit::WebFrame* frame, | 60 bool InstallWebApplicationUsingDefinitionFile(WebKit::WebFrame* frame, |
60 string16* error); | 61 string16* error); |
61 | 62 |
62 int tab_id() const { return tab_id_; } | 63 int tab_id() const { return tab_id_; } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 106 |
106 // Callback triggered after each icon referenced by the application definition | 107 // Callback triggered after each icon referenced by the application definition |
107 // is downloaded. | 108 // is downloaded. |
108 void DidDownloadApplicationIcon(webkit_glue::ImageResourceFetcher* fetcher, | 109 void DidDownloadApplicationIcon(webkit_glue::ImageResourceFetcher* fetcher, |
109 const SkBitmap& image); | 110 const SkBitmap& image); |
110 | 111 |
111 // Helper to add an logging message to the root frame's console. | 112 // Helper to add an logging message to the root frame's console. |
112 void AddMessageToRootConsole(content::ConsoleMessageLevel level, | 113 void AddMessageToRootConsole(content::ConsoleMessageLevel level, |
113 const string16& message); | 114 const string16& message); |
114 | 115 |
115 ExtensionDispatcher* extension_dispatcher_; | 116 Dispatcher* dispatcher_; |
116 | 117 |
117 // The app info that we are processing. This is used when installing an app | 118 // The app info that we are processing. This is used when installing an app |
118 // via application definition. The in-progress web app is stored here while | 119 // via application definition. The in-progress web app is stored here while |
119 // its manifest and icons are downloaded. | 120 // its manifest and icons are downloaded. |
120 scoped_ptr<WebApplicationInfo> pending_app_info_; | 121 scoped_ptr<WebApplicationInfo> pending_app_info_; |
121 | 122 |
122 // Used to download the application definition file. | 123 // Used to download the application definition file. |
123 scoped_ptr<webkit_glue::ResourceFetcher> app_definition_fetcher_; | 124 scoped_ptr<webkit_glue::ResourceFetcher> app_definition_fetcher_; |
124 | 125 |
125 // Used to download the icons for an application. | 126 // Used to download the icons for an application. |
(...skipping 10 matching lines...) Expand all Loading... |
136 | 137 |
137 // Id of the tab which the RenderView is attached to. | 138 // Id of the tab which the RenderView is attached to. |
138 int tab_id_; | 139 int tab_id_; |
139 | 140 |
140 // Id number of browser window which RenderView is attached to. | 141 // Id number of browser window which RenderView is attached to. |
141 int browser_window_id_; | 142 int browser_window_id_; |
142 | 143 |
143 DISALLOW_COPY_AND_ASSIGN(ExtensionHelper); | 144 DISALLOW_COPY_AND_ASSIGN(ExtensionHelper); |
144 }; | 145 }; |
145 | 146 |
| 147 } // namespace extensions |
| 148 |
146 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_HELPER_H_ | 149 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_HELPER_H_ |
OLD | NEW |