Suppression for crbug/241044.
[chromium-blink-merge.git] / chrome / renderer / extensions / extension_helper.h
blobc48f184d1dd34d9d4217509b1b5a6ea2aab1048f
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
3 // found in the LICENSE file.
5 #ifndef CHROME_RENDERER_EXTENSIONS_EXTENSION_HELPER_H_
6 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_HELPER_H_
8 #include <map>
9 #include <vector>
11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "content/public/common/console_message_level.h"
14 #include "content/public/renderer/render_view_observer.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"
19 class GURL;
20 class SkBitmap;
21 struct ExtensionMsg_ExecuteCode_Params;
22 struct ExtensionMsg_ExternalConnectionInfo;
23 struct WebApplicationInfo;
25 namespace base {
26 class DictionaryValue;
27 class ListValue;
30 namespace extensions {
31 class Dispatcher;
33 // RenderView-level plumbing for extension features.
34 class ExtensionHelper
35 : public content::RenderViewObserver,
36 public content::RenderViewObserverTracker<ExtensionHelper> {
37 public:
38 // Returns a list of extension RenderViews that match the given filter
39 // criteria. If |browser_window_id| is not extension_misc::kUnknownWindowId,
40 // the list is restricted to views in that browser window.
41 static std::vector<content::RenderView*> GetExtensionViews(
42 const std::string& extension_id,
43 int browser_window_id,
44 ViewType view_type);
46 // Returns the given extension's background page, or NULL if none.
47 static content::RenderView* GetBackgroundPage(
48 const std::string& extension_id);
50 ExtensionHelper(content::RenderView* render_view, Dispatcher* dispatcher);
51 virtual ~ExtensionHelper();
53 int tab_id() const { return tab_id_; }
54 int browser_window_id() const { return browser_window_id_; }
55 ViewType view_type() const { return view_type_; }
56 Dispatcher* dispatcher() const { return dispatcher_; }
58 private:
59 // RenderViewObserver implementation.
60 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
61 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE;
62 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE;
63 virtual void DidCreateDocumentElement(WebKit::WebFrame* frame) OVERRIDE;
64 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) OVERRIDE;
65 virtual void FrameDetached(WebKit::WebFrame* frame) OVERRIDE;
66 virtual void DidCreateDataSource(WebKit::WebFrame* frame,
67 WebKit::WebDataSource* ds) OVERRIDE;
68 virtual void DraggableRegionsChanged(WebKit::WebFrame* frame) OVERRIDE;
70 void OnExtensionResponse(int request_id, bool success,
71 const base::ListValue& response,
72 const std::string& error);
73 void OnExtensionMessageInvoke(const std::string& extension_id,
74 const std::string& function_name,
75 const base::ListValue& args,
76 const GURL& event_url,
77 bool user_gesture);
78 void OnExtensionDispatchOnConnect(
79 int target_port_id,
80 const std::string& channel_name,
81 const base::DictionaryValue& source_tab,
82 const ExtensionMsg_ExternalConnectionInfo& info);
83 void OnExtensionDeliverMessage(int target_port_id,
84 const std::string& message);
85 void OnExtensionDispatchOnDisconnect(int port_id,
86 const std::string& error_message);
87 void OnExecuteCode(const ExtensionMsg_ExecuteCode_Params& params);
88 void OnGetApplicationInfo(int page_id);
89 void OnNotifyRendererViewType(ViewType view_type);
90 void OnSetTabId(int tab_id);
91 void OnUpdateBrowserWindowId(int window_id);
92 void OnAddMessageToConsole(content::ConsoleMessageLevel level,
93 const std::string& message);
94 void OnAppWindowClosed();
96 Dispatcher* dispatcher_;
98 // The app info that we are processing. This is used when installing an app
99 // via application definition. The in-progress web app is stored here while
100 // its manifest and icons are downloaded.
101 scoped_ptr<WebApplicationInfo> pending_app_info_;
103 // The number of app icon requests outstanding. When this reaches zero, we're
104 // done processing an app definition file.
105 int pending_app_icon_requests_;
107 // Type of view attached with RenderView.
108 ViewType view_type_;
110 // Id of the tab which the RenderView is attached to.
111 int tab_id_;
113 // Id number of browser window which RenderView is attached to.
114 int browser_window_id_;
116 DISALLOW_COPY_AND_ASSIGN(ExtensionHelper);
119 } // namespace extensions
121 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_HELPER_H_