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" | |
14 #include "content/public/common/console_message_level.h" | 13 #include "content/public/common/console_message_level.h" |
15 #include "content/public/renderer/render_view_observer.h" | 14 #include "content/public/renderer/render_view_observer.h" |
16 #include "content/public/renderer/render_view_observer_tracker.h" | 15 #include "content/public/renderer/render_view_observer_tracker.h" |
16 #include "extensions/common/view_type.h" | |
17 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLResponse.h" | 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLResponse.h" |
18 | 18 |
19 class GURL; | 19 class GURL; |
20 class SkBitmap; | 20 class SkBitmap; |
21 struct ExtensionMsg_ExecuteCode_Params; | 21 struct ExtensionMsg_ExecuteCode_Params; |
22 struct WebApplicationInfo; | 22 struct WebApplicationInfo; |
23 | 23 |
24 namespace base { | 24 namespace base { |
25 class ListValue; | 25 class ListValue; |
26 } | 26 } |
(...skipping 10 matching lines...) Expand all Loading... | |
37 class ExtensionHelper | 37 class ExtensionHelper |
38 : public content::RenderViewObserver, | 38 : public content::RenderViewObserver, |
39 public content::RenderViewObserverTracker<ExtensionHelper> { | 39 public content::RenderViewObserverTracker<ExtensionHelper> { |
40 public: | 40 public: |
41 // Returns a list of extension RenderViews that match the given filter | 41 // Returns a list of extension RenderViews that match the given filter |
42 // criteria. If |browser_window_id| is not extension_misc::kUnknownWindowId, | 42 // criteria. If |browser_window_id| is not extension_misc::kUnknownWindowId, |
43 // the list is restricted to views in that browser window. | 43 // the list is restricted to views in that browser window. |
44 static std::vector<content::RenderView*> GetExtensionViews( | 44 static std::vector<content::RenderView*> GetExtensionViews( |
45 const std::string& extension_id, | 45 const std::string& extension_id, |
46 int browser_window_id, | 46 int browser_window_id, |
47 chrome::ViewType view_type); | 47 extensions::ViewType view_type); |
Yoyo Zhou
2013/04/01 17:36:51
''
| |
48 | 48 |
49 // Returns the given extension's background page, or NULL if none. | 49 // Returns the given extension's background page, or NULL if none. |
50 static content::RenderView* GetBackgroundPage( | 50 static content::RenderView* GetBackgroundPage( |
51 const std::string& extension_id); | 51 const std::string& extension_id); |
52 | 52 |
53 ExtensionHelper(content::RenderView* render_view, Dispatcher* dispatcher); | 53 ExtensionHelper(content::RenderView* render_view, Dispatcher* dispatcher); |
54 virtual ~ExtensionHelper(); | 54 virtual ~ExtensionHelper(); |
55 | 55 |
56 int tab_id() const { return tab_id_; } | 56 int tab_id() const { return tab_id_; } |
57 int browser_window_id() const { return browser_window_id_; } | 57 int browser_window_id() const { return browser_window_id_; } |
58 chrome::ViewType view_type() const { return view_type_; } | 58 extensions::ViewType view_type() const { return view_type_; } |
59 Dispatcher* dispatcher() const { return dispatcher_; } | 59 Dispatcher* dispatcher() const { return dispatcher_; } |
60 | 60 |
61 private: | 61 private: |
62 // RenderViewObserver implementation. | 62 // RenderViewObserver implementation. |
63 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 63 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
64 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; | 64 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; |
65 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; | 65 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; |
66 virtual void DidCreateDocumentElement(WebKit::WebFrame* frame) OVERRIDE; | 66 virtual void DidCreateDocumentElement(WebKit::WebFrame* frame) OVERRIDE; |
67 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) OVERRIDE; | 67 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) OVERRIDE; |
68 virtual void FrameDetached(WebKit::WebFrame* frame) OVERRIDE; | 68 virtual void FrameDetached(WebKit::WebFrame* frame) OVERRIDE; |
(...skipping 13 matching lines...) Expand all Loading... | |
82 const std::string& channel_name, | 82 const std::string& channel_name, |
83 const std::string& tab_json, | 83 const std::string& tab_json, |
84 const std::string& source_extension_id, | 84 const std::string& source_extension_id, |
85 const std::string& target_extension_id); | 85 const std::string& target_extension_id); |
86 void OnExtensionDeliverMessage(int target_port_id, | 86 void OnExtensionDeliverMessage(int target_port_id, |
87 const std::string& message); | 87 const std::string& message); |
88 void OnExtensionDispatchOnDisconnect(int port_id, | 88 void OnExtensionDispatchOnDisconnect(int port_id, |
89 const std::string& error_message); | 89 const std::string& error_message); |
90 void OnExecuteCode(const ExtensionMsg_ExecuteCode_Params& params); | 90 void OnExecuteCode(const ExtensionMsg_ExecuteCode_Params& params); |
91 void OnGetApplicationInfo(int page_id); | 91 void OnGetApplicationInfo(int page_id); |
92 void OnNotifyRendererViewType(chrome::ViewType view_type); | 92 void OnNotifyRendererViewType(extensions::ViewType view_type); |
93 void OnSetTabId(int tab_id); | 93 void OnSetTabId(int tab_id); |
94 void OnUpdateBrowserWindowId(int window_id); | 94 void OnUpdateBrowserWindowId(int window_id); |
95 void OnAddMessageToConsole(content::ConsoleMessageLevel level, | 95 void OnAddMessageToConsole(content::ConsoleMessageLevel level, |
96 const std::string& message); | 96 const std::string& message); |
97 void OnAppWindowClosed(); | 97 void OnAppWindowClosed(); |
98 | 98 |
99 Dispatcher* dispatcher_; | 99 Dispatcher* dispatcher_; |
100 | 100 |
101 // The app info that we are processing. This is used when installing an app | 101 // The app info that we are processing. This is used when installing an app |
102 // via application definition. The in-progress web app is stored here while | 102 // via application definition. The in-progress web app is stored here while |
103 // its manifest and icons are downloaded. | 103 // its manifest and icons are downloaded. |
104 scoped_ptr<WebApplicationInfo> pending_app_info_; | 104 scoped_ptr<WebApplicationInfo> pending_app_info_; |
105 | 105 |
106 // Used to download the application definition file. | 106 // Used to download the application definition file. |
107 scoped_ptr<webkit_glue::ResourceFetcher> app_definition_fetcher_; | 107 scoped_ptr<webkit_glue::ResourceFetcher> app_definition_fetcher_; |
108 | 108 |
109 // Used to download the icons for an application. | 109 // Used to download the icons for an application. |
110 typedef std::vector<linked_ptr<webkit_glue::ImageResourceFetcher> > | 110 typedef std::vector<linked_ptr<webkit_glue::ImageResourceFetcher> > |
111 ImageResourceFetcherList; | 111 ImageResourceFetcherList; |
112 ImageResourceFetcherList app_icon_fetchers_; | 112 ImageResourceFetcherList app_icon_fetchers_; |
113 | 113 |
114 // The number of app icon requests outstanding. When this reaches zero, we're | 114 // The number of app icon requests outstanding. When this reaches zero, we're |
115 // done processing an app definition file. | 115 // done processing an app definition file. |
116 int pending_app_icon_requests_; | 116 int pending_app_icon_requests_; |
117 | 117 |
118 // Type of view attached with RenderView. | 118 // Type of view attached with RenderView. |
119 chrome::ViewType view_type_; | 119 extensions::ViewType view_type_; |
120 | 120 |
121 // Id of the tab which the RenderView is attached to. | 121 // Id of the tab which the RenderView is attached to. |
122 int tab_id_; | 122 int tab_id_; |
123 | 123 |
124 // Id number of browser window which RenderView is attached to. | 124 // Id number of browser window which RenderView is attached to. |
125 int browser_window_id_; | 125 int browser_window_id_; |
126 | 126 |
127 DISALLOW_COPY_AND_ASSIGN(ExtensionHelper); | 127 DISALLOW_COPY_AND_ASSIGN(ExtensionHelper); |
128 }; | 128 }; |
129 | 129 |
130 } // namespace extensions | 130 } // namespace extensions |
131 | 131 |
132 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_HELPER_H_ | 132 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_HELPER_H_ |
OLD | NEW |