OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/common/extensions/chrome_extensions_client.h" | 5 #include "chrome/common/extensions/chrome_extensions_client.h" |
6 | 6 |
7 #include "chrome/common/extensions/chrome_manifest_handlers.h" | 7 #include "chrome/common/extensions/chrome_manifest_handlers.h" |
8 #include "chrome/common/extensions/features/base_feature_provider.h" | 8 #include "chrome/common/extensions/features/base_feature_provider.h" |
9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
11 #include "extensions/common/permissions/permission_message.h" | 11 #include "extensions/common/permissions/permission_message.h" |
12 #include "extensions/common/url_pattern_set.h" | 12 #include "extensions/common/url_pattern_set.h" |
13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
16 | 16 |
17 namespace extensions { | 17 namespace extensions { |
18 | 18 |
19 static base::LazyInstance<ChromeExtensionsClient> g_client = | 19 static base::LazyInstance<ChromeExtensionsClient> g_client = |
20 LAZY_INSTANCE_INITIALIZER; | 20 LAZY_INSTANCE_INITIALIZER; |
21 | 21 |
22 ChromeExtensionsClient::ChromeExtensionsClient() | 22 ChromeExtensionsClient::ChromeExtensionsClient() |
23 : chrome_api_permissions_(ChromeAPIPermissions()) { | 23 : chrome_api_permissions_(ChromeAPIPermissions()) { |
24 } | 24 } |
25 | 25 |
26 ChromeExtensionsClient::~ChromeExtensionsClient() { | 26 ChromeExtensionsClient::~ChromeExtensionsClient() { |
27 } | 27 } |
28 | 28 |
| 29 void ChromeExtensionsClient::Initialize() { |
| 30 RegisterChromeManifestHandlers(); |
| 31 } |
| 32 |
29 const PermissionsProvider& | 33 const PermissionsProvider& |
30 ChromeExtensionsClient::GetPermissionsProvider() const { | 34 ChromeExtensionsClient::GetPermissionsProvider() const { |
31 return chrome_api_permissions_; | 35 return chrome_api_permissions_; |
32 } | 36 } |
33 | 37 |
| 38 const PermissionMessageProvider& |
| 39 ChromeExtensionsClient::GetPermissionMessageProvider() const { |
| 40 return permission_message_provider_; |
| 41 } |
| 42 |
34 FeatureProvider* ChromeExtensionsClient::GetFeatureProviderByName( | 43 FeatureProvider* ChromeExtensionsClient::GetFeatureProviderByName( |
35 const std::string& name) const { | 44 const std::string& name) const { |
36 return BaseFeatureProvider::GetByName(name); | 45 return BaseFeatureProvider::GetByName(name); |
37 } | 46 } |
38 | 47 |
39 void ChromeExtensionsClient::RegisterManifestHandlers() const { | |
40 RegisterChromeManifestHandlers(); | |
41 } | |
42 | |
43 void ChromeExtensionsClient::FilterHostPermissions( | 48 void ChromeExtensionsClient::FilterHostPermissions( |
44 const URLPatternSet& hosts, | 49 const URLPatternSet& hosts, |
45 URLPatternSet* new_hosts, | 50 URLPatternSet* new_hosts, |
46 std::set<PermissionMessage>* messages) const { | 51 std::set<PermissionMessage>* messages) const { |
47 for (URLPatternSet::const_iterator i = hosts.begin(); | 52 for (URLPatternSet::const_iterator i = hosts.begin(); |
48 i != hosts.end(); ++i) { | 53 i != hosts.end(); ++i) { |
49 // Filters out every URL pattern that matches chrome:// scheme. | 54 // Filters out every URL pattern that matches chrome:// scheme. |
50 if (i->scheme() == chrome::kChromeUIScheme) { | 55 if (i->scheme() == chrome::kChromeUIScheme) { |
51 // chrome://favicon is the only URL for chrome:// scheme that we | 56 // chrome://favicon is the only URL for chrome:// scheme that we |
52 // want to support. We want to deprecate the "chrome" scheme. | 57 // want to support. We want to deprecate the "chrome" scheme. |
53 // We should not add any additional "host" here. | 58 // We should not add any additional "host" here. |
54 if (GURL(chrome::kChromeUIFaviconURL).host() != i->host()) | 59 if (GURL(chrome::kChromeUIFaviconURL).host() != i->host()) |
55 continue; | 60 continue; |
56 messages->insert(PermissionMessage( | 61 messages->insert(PermissionMessage( |
57 PermissionMessage::kFavicon, | 62 PermissionMessage::kFavicon, |
58 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FAVICON))); | 63 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FAVICON))); |
59 } else { | 64 } else { |
60 new_hosts->AddPattern(*i); | 65 new_hosts->AddPattern(*i); |
61 } | 66 } |
62 } | 67 } |
63 } | 68 } |
64 | 69 |
65 // static | 70 // static |
66 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { | 71 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { |
67 return g_client.Pointer(); | 72 return g_client.Pointer(); |
68 } | 73 } |
69 | 74 |
70 } // namespace extensions | 75 } // namespace extensions |
OLD | NEW |