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

Side by Side Diff: chrome/common/extensions/chrome_extensions_client.cc

Issue 27446002: Move permission warning message handling from PermissionSet to PermissionMessageProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
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/extensions/permissions/app_permission_message_provider.h "
10 #include "chrome/common/extensions/permissions/extension_permission_message_prov ider.h"
9 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
10 #include "content/public/common/url_constants.h" 12 #include "content/public/common/url_constants.h"
11 #include "extensions/common/permissions/permission_message.h" 13 #include "extensions/common/permissions/permission_message.h"
12 #include "extensions/common/url_pattern_set.h" 14 #include "extensions/common/url_pattern_set.h"
13 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
15 #include "url/gurl.h" 17 #include "url/gurl.h"
16 18
17 namespace extensions { 19 namespace extensions {
18 20
19 static base::LazyInstance<ChromeExtensionsClient> g_client = 21 static base::LazyInstance<ChromeExtensionsClient> g_client =
20 LAZY_INSTANCE_INITIALIZER; 22 LAZY_INSTANCE_INITIALIZER;
21 23
22 ChromeExtensionsClient::ChromeExtensionsClient() 24 ChromeExtensionsClient::ChromeExtensionsClient()
23 : chrome_api_permissions_(ChromeAPIPermissions()) { 25 : chrome_api_permissions_(ChromeAPIPermissions()) {
24 } 26 }
25 27
26 ChromeExtensionsClient::~ChromeExtensionsClient() { 28 ChromeExtensionsClient::~ChromeExtensionsClient() {
27 } 29 }
28 30
31 void ChromeExtensionsClient::Initialize() {
32 RegisterChromeManifestHandlers();
33
34 ExtensionPermissionMessageProvider* extension_permission_message_provider =
35 new ExtensionPermissionMessageProvider;
36 AppPermissionMessageProvider* app_permission_message_provider =
37 new AppPermissionMessageProvider;
38 std::vector<std::pair<Manifest::Type, PermissionMessageProvider*> >
39 custom_providers;
40 custom_providers.push_back(std::make_pair(
41 Manifest::TYPE_PLATFORM_APP,
42 app_permission_message_provider));
43 PermissionMessageProvider::SetProviders(extension_permission_message_provider,
44 custom_providers);
45 }
46
29 const PermissionsProvider& 47 const PermissionsProvider&
30 ChromeExtensionsClient::GetPermissionsProvider() const { 48 ChromeExtensionsClient::GetPermissionsProvider() const {
31 return chrome_api_permissions_; 49 return chrome_api_permissions_;
32 } 50 }
33 51
34 FeatureProvider* ChromeExtensionsClient::GetFeatureProviderByName( 52 FeatureProvider* ChromeExtensionsClient::GetFeatureProviderByName(
35 const std::string& name) const { 53 const std::string& name) const {
36 return BaseFeatureProvider::GetByName(name); 54 return BaseFeatureProvider::GetByName(name);
37 } 55 }
38 56
39 void ChromeExtensionsClient::RegisterManifestHandlers() const {
40 RegisterChromeManifestHandlers();
41 }
42
43 void ChromeExtensionsClient::FilterHostPermissions( 57 void ChromeExtensionsClient::FilterHostPermissions(
44 const URLPatternSet& hosts, 58 const URLPatternSet& hosts,
45 URLPatternSet* new_hosts, 59 URLPatternSet* new_hosts,
46 std::set<PermissionMessage>* messages) const { 60 std::set<PermissionMessage>* messages) const {
47 for (URLPatternSet::const_iterator i = hosts.begin(); 61 for (URLPatternSet::const_iterator i = hosts.begin();
48 i != hosts.end(); ++i) { 62 i != hosts.end(); ++i) {
49 // Filters out every URL pattern that matches chrome:// scheme. 63 // Filters out every URL pattern that matches chrome:// scheme.
50 if (i->scheme() == chrome::kChromeUIScheme) { 64 if (i->scheme() == chrome::kChromeUIScheme) {
51 // chrome://favicon is the only URL for chrome:// scheme that we 65 // chrome://favicon is the only URL for chrome:// scheme that we
52 // want to support. We want to deprecate the "chrome" scheme. 66 // want to support. We want to deprecate the "chrome" scheme.
53 // We should not add any additional "host" here. 67 // We should not add any additional "host" here.
54 if (GURL(chrome::kChromeUIFaviconURL).host() != i->host()) 68 if (GURL(chrome::kChromeUIFaviconURL).host() != i->host())
55 continue; 69 continue;
56 messages->insert(PermissionMessage( 70 messages->insert(PermissionMessage(
57 PermissionMessage::kFavicon, 71 PermissionMessage::kFavicon,
58 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FAVICON))); 72 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FAVICON)));
59 } else { 73 } else {
60 new_hosts->AddPattern(*i); 74 new_hosts->AddPattern(*i);
61 } 75 }
62 } 76 }
63 } 77 }
64 78
65 // static 79 // static
66 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { 80 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() {
67 return g_client.Pointer(); 81 return g_client.Pointer();
68 } 82 }
69 83
70 } // namespace extensions 84 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698