blob: 49f317b857328df280c59c6415112eff8a229c81 [file] [log] [blame]
[email protected]b6cd4722014-05-01 22:04:061// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]44c49c92011-03-28 16:17:232// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]b6cd4722014-05-01 22:04:065#ifndef EXTENSIONS_RENDERER_EXTENSION_HELPER_H_
6#define EXTENSIONS_RENDERER_EXTENSION_HELPER_H_
[email protected]44c49c92011-03-28 16:17:237
[email protected]a2ef54c2011-10-10 16:20:318#include <vector>
[email protected]946a0032011-03-31 18:42:289
[email protected]5b1a04b42012-06-15 00:41:4410#include "content/public/common/console_message_level.h"
[email protected]3a034ebb2011-10-03 19:19:4411#include "content/public/renderer/render_view_observer.h"
12#include "content/public/renderer/render_view_observer_tracker.h"
[email protected]cb2edf22013-04-01 20:25:2313#include "extensions/common/view_type.h"
[email protected]44c49c92011-03-28 16:17:2314
15class GURL;
[email protected]a2ef54c2011-10-10 16:20:3116class SkBitmap;
[email protected]686914f2013-04-25 04:54:5817struct ExtensionMsg_ExternalConnectionInfo;
[email protected]38b592902011-04-16 02:08:4218
[email protected]f3a1c642011-07-12 19:15:0319namespace base {
[email protected]686914f2013-04-25 04:54:5820class DictionaryValue;
[email protected]f3a1c642011-07-12 19:15:0321class ListValue;
22}
23
[email protected]8fe74bf2012-08-07 21:08:4224namespace extensions {
25class Dispatcher;
[email protected]8865fea2013-10-23 01:17:2626struct Message;
[email protected]8fe74bf2012-08-07 21:08:4227
[email protected]d0cf438c2011-08-18 03:08:5228// RenderView-level plumbing for extension features.
[email protected]3a034ebb2011-10-03 19:19:4429class ExtensionHelper
30 : public content::RenderViewObserver,
31 public content::RenderViewObserverTracker<ExtensionHelper> {
[email protected]44c49c92011-03-28 16:17:2332 public:
[email protected]7042b682012-04-19 22:57:5133 // Returns a list of extension RenderViews that match the given filter
34 // criteria. If |browser_window_id| is not extension_misc::kUnknownWindowId,
35 // the list is restricted to views in that browser window.
36 static std::vector<content::RenderView*> GetExtensionViews(
37 const std::string& extension_id,
38 int browser_window_id,
[email protected]cb2edf22013-04-01 20:25:2339 ViewType view_type);
[email protected]7042b682012-04-19 22:57:5140
41 // Returns the given extension's background page, or NULL if none.
42 static content::RenderView* GetBackgroundPage(
43 const std::string& extension_id);
44
[email protected]8fe74bf2012-08-07 21:08:4245 ExtensionHelper(content::RenderView* render_view, Dispatcher* dispatcher);
[email protected]c2a41592011-09-08 01:13:1846 virtual ~ExtensionHelper();
[email protected]44c49c92011-03-28 16:17:2347
[email protected]fc5e65d6b2012-06-13 00:22:5748 int tab_id() const { return tab_id_; }
[email protected]9966325b2011-04-18 05:00:1049 int browser_window_id() const { return browser_window_id_; }
[email protected]cb2edf22013-04-01 20:25:2350 ViewType view_type() const { return view_type_; }
[email protected]d2663612013-03-17 09:25:5651 Dispatcher* dispatcher() const { return dispatcher_; }
[email protected]4f1633f2013-03-09 14:26:2452
[email protected]44c49c92011-03-28 16:17:2353 private:
54 // RenderViewObserver implementation.
[email protected]53416422011-11-21 16:53:5455 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
[email protected]c5041c322014-04-08 05:06:4756 virtual void DidCreateDocumentElement(blink::WebLocalFrame* frame) OVERRIDE;
[email protected]f5b6dd1122013-10-04 02:42:5057 virtual void DidMatchCSS(
[email protected]c5041c322014-04-08 05:06:4758 blink::WebLocalFrame* frame,
[email protected]a1221aea2013-11-07 01:31:3059 const blink::WebVector<blink::WebString>& newly_matching_selectors,
60 const blink::WebVector<blink::WebString>& stopped_matching_selectors)
[email protected]f5b6dd1122013-10-04 02:42:5061 OVERRIDE;
[email protected]a1221aea2013-11-07 01:31:3062 virtual void DraggableRegionsChanged(blink::WebFrame* frame) OVERRIDE;
[email protected]44c49c92011-03-28 16:17:2363
[email protected]74e21e72012-07-09 21:20:5364 void OnExtensionResponse(int request_id, bool success,
65 const base::ListValue& response,
66 const std::string& error);
[email protected]44c49c92011-03-28 16:17:2367 void OnExtensionMessageInvoke(const std::string& extension_id,
[email protected]68e63ea12013-06-05 05:00:5468 const std::string& module_name,
[email protected]44c49c92011-03-28 16:17:2369 const std::string& function_name,
[email protected]f3a1c642011-07-12 19:15:0370 const base::ListValue& args,
[email protected]b085856f2012-03-02 04:37:2571 bool user_gesture);
[email protected]686914f2013-04-25 04:54:5872 void OnExtensionDispatchOnConnect(
73 int target_port_id,
74 const std::string& channel_name,
75 const base::DictionaryValue& source_tab,
[email protected]8ad95b72013-10-16 02:54:1176 const ExtensionMsg_ExternalConnectionInfo& info,
77 const std::string& tls_channel_id);
[email protected]b2e86ec12011-09-15 01:59:0678 void OnExtensionDeliverMessage(int target_port_id,
[email protected]8865fea2013-10-23 01:17:2679 const Message& message);
[email protected]d6b39612013-03-08 02:33:1380 void OnExtensionDispatchOnDisconnect(int port_id,
81 const std::string& error_message);
[email protected]cb2edf22013-04-01 20:25:2382 void OnNotifyRendererViewType(ViewType view_type);
[email protected]fc5e65d6b2012-06-13 00:22:5783 void OnSetTabId(int tab_id);
[email protected]9966325b2011-04-18 05:00:1084 void OnUpdateBrowserWindowId(int window_id);
[email protected]5b1a04b42012-06-15 00:41:4485 void OnAddMessageToConsole(content::ConsoleMessageLevel level,
86 const std::string& message);
[email protected]02d51e42012-10-18 02:39:1987 void OnAppWindowClosed();
[email protected]9a1314a2014-08-18 19:27:3988 void OnSetFrameName(const std::string& name);
[email protected]38b592902011-04-16 02:08:4289
[email protected]8fe74bf2012-08-07 21:08:4290 Dispatcher* dispatcher_;
[email protected]8d97ade2011-04-14 18:17:0891
[email protected]9966325b2011-04-18 05:00:1092 // Type of view attached with RenderView.
[email protected]cb2edf22013-04-01 20:25:2393 ViewType view_type_;
[email protected]9966325b2011-04-18 05:00:1094
[email protected]fc5e65d6b2012-06-13 00:22:5795 // Id of the tab which the RenderView is attached to.
96 int tab_id_;
97
[email protected]9966325b2011-04-18 05:00:1098 // Id number of browser window which RenderView is attached to.
99 int browser_window_id_;
100
[email protected]c2a41592011-09-08 01:13:18101 DISALLOW_COPY_AND_ASSIGN(ExtensionHelper);
[email protected]44c49c92011-03-28 16:17:23102};
103
[email protected]8fe74bf2012-08-07 21:08:42104} // namespace extensions
105
[email protected]b6cd4722014-05-01 22:04:06106#endif // EXTENSIONS_RENDERER_EXTENSION_HELPER_H_