Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: chrome/renderer/extensions/extension_renderer_info.h

Issue 3263007: Reland r57788 - Expose Extension Bindings to Component Applications (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: don't hide gallery url in omnibar Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_RENDERER_INFO_H_ 5 #ifndef CHROME_RENDERER_EXTENSIONS_EXTENSION_RENDERER_INFO_H_
6 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_RENDERER_INFO_H_ 6 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_RENDERER_INFO_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "chrome/common/extensions/extension.h"
13 #include "chrome/common/extensions/extension_extent.h" 14 #include "chrome/common/extensions/extension_extent.h"
14 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
15 16
16 struct ViewMsg_ExtensionsUpdated_Params; 17 struct ViewMsg_ExtensionsUpdated_Params;
17 struct ViewMsg_ExtensionRendererInfo; 18 struct ViewMsg_ExtensionRendererInfo;
18 19
19 // Extension information needed in the renderer process along with static 20 // Extension information needed in the renderer process along with static
20 // methods to look up information about the currently loaded extensions. 21 // methods to look up information about the currently loaded extensions.
21 class ExtensionRendererInfo { 22 class ExtensionRendererInfo {
22 public: 23 public:
23 ExtensionRendererInfo(); 24 ExtensionRendererInfo();
24 ExtensionRendererInfo(const ExtensionRendererInfo& that); 25 ExtensionRendererInfo(const ExtensionRendererInfo& that);
25 ~ExtensionRendererInfo(); 26 ~ExtensionRendererInfo();
26 27
27 const std::string& id() const { return id_; } 28 const std::string& id() const { return id_; }
28 const ExtensionExtent& web_extent() const { return web_extent_; } 29 const ExtensionExtent& web_extent() const { return web_extent_; }
29 const std::string& name() const { return name_; } 30 const std::string& name() const { return name_; }
30 const GURL& icon_url() const { return icon_url_; } 31 const GURL& icon_url() const { return icon_url_; }
31 32
32 // Replace the list of extensions with those provided in |params|. 33 // Replace the list of extensions with those provided in |params|.
33 static void UpdateExtensions(const ViewMsg_ExtensionsUpdated_Params& params); 34 static void UpdateExtensions(const ViewMsg_ExtensionsUpdated_Params& params);
34 35
35 // Returns the extension ID that the given URL is a part of, or empty if 36 // Returns the extension ID that the given URL is a part of, or empty if
36 // none. This includes web URLs that are part of an extension's web extent. 37 // none. This includes web URLs that are part of an extension's web extent.
38 static std::string GetIdByURL(const GURL& url);
39
40 // Returns the ExtensionRendererInfo that the given URL is a part of, or NULL
41 // if none. This includes web URLs that are part of an extension's web extent.
42 // NOTE: This can return NULL if called before UpdateExtensions receives
43 // bulk extension data (e.g. if called from
44 // EventBindings::HandleContextCreated)
37 static ExtensionRendererInfo* GetByURL(const GURL& url); 45 static ExtensionRendererInfo* GetByURL(const GURL& url);
38 46
39 // Returns true if |new_url| is in the extent of the same extension as 47 // Returns true if |new_url| is in the extent of the same extension as
40 // |old_url|. Also returns true if neither URL is in an app. 48 // |old_url|. Also returns true if neither URL is in an app.
41 static bool InSameExtent(const GURL& old_url, const GURL& new_url); 49 static bool InSameExtent(const GURL& old_url, const GURL& new_url);
42 50
43 // Look up an ExtensionInfo object by id. 51 // Look up an ExtensionInfo object by id.
44 static ExtensionRendererInfo* GetByID(const std::string& id); 52 static ExtensionRendererInfo* GetByID(const std::string& id);
45 53
54 // Returns true if |url| should get extension api bindings and be permitted
55 // to make api calls. Note that this is independent of what extension
56 // permissions the given extension has been granted.
57 static bool ExtensionBindingsAllowed(const GURL& url);
58
46 private: 59 private:
47 void Update(const ViewMsg_ExtensionRendererInfo& info); 60 void Update(const ViewMsg_ExtensionRendererInfo& info);
48 61
49 FRIEND_TEST_ALL_PREFIXES(ExtensionRendererInfoTest, ExtensionRendererInfo); 62 FRIEND_TEST_ALL_PREFIXES(ExtensionRendererInfoTest, ExtensionRendererInfo);
50 63
51 std::string id_; 64 std::string id_;
52 ExtensionExtent web_extent_; 65 ExtensionExtent web_extent_;
53 std::string name_; 66 std::string name_;
67 Extension::Location location_;
54 GURL icon_url_; 68 GURL icon_url_;
55 69
56 // static 70 // static
57 static std::vector<ExtensionRendererInfo>* extensions_; 71 static std::vector<ExtensionRendererInfo>* extensions_;
58 }; 72 };
59 73
60 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_RENDERER_INFO_H_ 74 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_RENDERER_INFO_H_
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_process_bindings.cc ('k') | chrome/renderer/extensions/extension_renderer_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698