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

Side by Side Diff: chrome/common/extensions/permissions/chrome_permission_message_provider.cc

Issue 482953003: Add a separate warning message for topSites permission. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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/permissions/chrome_permission_message_provide r.h" 5 #include "chrome/common/extensions/permissions/chrome_permission_message_provide r.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chrome/grit/generated_resources.h" 9 #include "chrome/grit/generated_resources.h"
10 #include "extensions/common/extensions_client.h" 10 #include "extensions/common/extensions_client.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 ChromePermissionMessageProvider::ChromePermissionMessageProvider() { 74 ChromePermissionMessageProvider::ChromePermissionMessageProvider() {
75 } 75 }
76 76
77 ChromePermissionMessageProvider::~ChromePermissionMessageProvider() { 77 ChromePermissionMessageProvider::~ChromePermissionMessageProvider() {
78 } 78 }
79 79
80 PermissionMessages ChromePermissionMessageProvider::GetPermissionMessages( 80 PermissionMessages ChromePermissionMessageProvider::GetPermissionMessages(
81 const PermissionSet* permissions, 81 const PermissionSet* permissions,
82 Manifest::Type extension_type) const { 82 Manifest::Type extension_type) const {
83 PermissionMessages messages;
84 if (permissions->HasEffectiveFullAccess()) {
not at google - send to devlin 2014/08/18 22:59:42 Why did you need to move this up?
meacer 2014/08/18 23:11:07 Early return. The suppress list isn't needed if we
not at google - send to devlin 2014/08/18 23:17:30 Ah right. Full as in ***FULL*** not like all-urls.
meacer 2014/08/18 23:31:13 That looks like a bug to me with the automation AP
85 messages.push_back(PermissionMessage(
86 PermissionMessage::kFullAccess,
87 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS)));
88 return messages;
89 }
90
83 // Some warnings are more generic and/or powerful and superseed other 91 // Some warnings are more generic and/or powerful and superseed other
84 // warnings. In that case, the first message suppresses the second one. 92 // warnings. In that case, the first message suppresses the second one.
85 std::multimap<PermissionMessage::ID, PermissionMessage::ID> kSuppressList; 93 std::multimap<PermissionMessage::ID, PermissionMessage::ID> kSuppressList;
86 kSuppressList.insert( 94 kSuppressList.insert(
87 {PermissionMessage::kBluetooth, PermissionMessage::kBluetoothDevices}); 95 {PermissionMessage::kBluetooth, PermissionMessage::kBluetoothDevices});
88 kSuppressList.insert( 96 kSuppressList.insert(
89 {PermissionMessage::kBookmarks, PermissionMessage::kOverrideBookmarksUI}); 97 {PermissionMessage::kBookmarks, PermissionMessage::kOverrideBookmarksUI});
90 // History already allows reading favicons. 98 // History already allows reading favicons.
91 kSuppressList.insert( 99 kSuppressList.insert(
92 {PermissionMessage::kBrowsingHistory, PermissionMessage::kFavicon}); 100 {PermissionMessage::kBrowsingHistory, PermissionMessage::kFavicon});
93 // History already allows tabs access. 101 // History already allows tabs access.
94 kSuppressList.insert( 102 kSuppressList.insert(
95 {PermissionMessage::kBrowsingHistory, PermissionMessage::kTabs}); 103 {PermissionMessage::kBrowsingHistory, PermissionMessage::kTabs});
104 // History already allows access the list of most frequently visited sites.
105 kSuppressList.insert(
106 {PermissionMessage::kBrowsingHistory, PermissionMessage::kTopSites});
96 // A special hack: If kFileSystemWriteDirectory would be displayed, hide 107 // A special hack: If kFileSystemWriteDirectory would be displayed, hide
97 // kFileSystemDirectory as the write directory message implies it. 108 // kFileSystemDirectory as the write directory message implies it.
98 // TODO(sammc): Remove this. See http://crbug.com/284849. 109 // TODO(sammc): Remove this. See http://crbug.com/284849.
99 kSuppressList.insert({PermissionMessage::kFileSystemWriteDirectory, 110 kSuppressList.insert({PermissionMessage::kFileSystemWriteDirectory,
100 PermissionMessage::kFileSystemDirectory}); 111 PermissionMessage::kFileSystemDirectory});
101 // Full access already allows DeclarativeWebRequest. 112 // Full access already allows DeclarativeWebRequest.
102 kSuppressList.insert({PermissionMessage::kHostsAll, 113 kSuppressList.insert({PermissionMessage::kHostsAll,
103 PermissionMessage::kDeclarativeWebRequest}); 114 PermissionMessage::kDeclarativeWebRequest});
115 // Full access implies reading the list of most frequently visited sites.
116 kSuppressList.insert(
117 {PermissionMessage::kHostsAll, PermissionMessage::kTopSites});
104 // Full access already covers tabs access. 118 // Full access already covers tabs access.
105 kSuppressList.insert( 119 kSuppressList.insert(
106 {PermissionMessage::kHostsAll, PermissionMessage::kTabs}); 120 {PermissionMessage::kHostsAll, PermissionMessage::kTabs});
107 // Tabs already allows reading favicons. 121 // Tabs already allows reading favicons.
108 kSuppressList.insert({PermissionMessage::kTabs, PermissionMessage::kFavicon}); 122 kSuppressList.insert({PermissionMessage::kTabs, PermissionMessage::kFavicon});
109 123 // Tabs already allows reading the list of most frequently visited sites.
110 PermissionMessages messages; 124 kSuppressList.insert(
111 125 {PermissionMessage::kTabs, PermissionMessage::kTopSites});
112 if (permissions->HasEffectiveFullAccess()) {
113 messages.push_back(PermissionMessage(
114 PermissionMessage::kFullAccess,
115 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS)));
116 return messages;
117 }
118 126
119 PermissionMsgSet host_msgs = 127 PermissionMsgSet host_msgs =
120 GetHostPermissionMessages(permissions, extension_type); 128 GetHostPermissionMessages(permissions, extension_type);
121 PermissionMsgSet api_msgs = GetAPIPermissionMessages(permissions); 129 PermissionMsgSet api_msgs = GetAPIPermissionMessages(permissions);
122 PermissionMsgSet manifest_permission_msgs = 130 PermissionMsgSet manifest_permission_msgs =
123 GetManifestPermissionMessages(permissions); 131 GetManifestPermissionMessages(permissions);
124 messages.insert(messages.end(), host_msgs.begin(), host_msgs.end()); 132 messages.insert(messages.end(), host_msgs.begin(), host_msgs.end());
125 messages.insert(messages.end(), api_msgs.begin(), api_msgs.end()); 133 messages.insert(messages.end(), api_msgs.begin(), api_msgs.end());
126 messages.insert(messages.end(), manifest_permission_msgs.begin(), 134 messages.insert(messages.end(), manifest_permission_msgs.begin(),
127 manifest_permission_msgs.end()); 135 manifest_permission_msgs.end());
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 std::set<std::string> old_hosts_set( 457 std::set<std::string> old_hosts_set(
450 permission_message_util::GetDistinctHosts(old_list, false, false)); 458 permission_message_util::GetDistinctHosts(old_list, false, false));
451 std::set<std::string> new_hosts_only = 459 std::set<std::string> new_hosts_only =
452 base::STLSetDifference<std::set<std::string> >(new_hosts_set, 460 base::STLSetDifference<std::set<std::string> >(new_hosts_set,
453 old_hosts_set); 461 old_hosts_set);
454 462
455 return !new_hosts_only.empty(); 463 return !new_hosts_only.empty();
456 } 464 }
457 465
458 } // namespace extensions 466 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698