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

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

Issue 236113002: Suppress tabs permission warning if there is already a browsingHistory warning. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "extensions/common/extensions_client.h" 9 #include "extensions/common/extensions_client.h"
10 #include "extensions/common/permissions/permission_message.h" 10 #include "extensions/common/permissions/permission_message.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 int id) { 66 int id) {
67 for (PermissionMessages::iterator it = messages.begin(); 67 for (PermissionMessages::iterator it = messages.begin();
68 it != messages.end(); ++it) { 68 it != messages.end(); ++it) {
69 if (it->id() == id) 69 if (it->id() == id)
70 return it; 70 return it;
71 } 71 }
72 72
73 return messages.end(); 73 return messages.end();
74 } 74 }
75 75
76 void SuppressMessage(PermissionMessages& messages,
77 int suppressing_message,
78 int suppressed_message) {
79 PermissionMessages::iterator suppressed =
80 FindMessageByID(messages, suppressed_message);
81 if (suppressed != messages.end() &&
82 FindMessageByID(messages, suppressing_message) != messages.end()) {
83 messages.erase(suppressed);
84 }
85 }
86
76 } // namespace 87 } // namespace
77 88
78 ChromePermissionMessageProvider::ChromePermissionMessageProvider() { 89 ChromePermissionMessageProvider::ChromePermissionMessageProvider() {
79 } 90 }
80 91
81 ChromePermissionMessageProvider::~ChromePermissionMessageProvider() { 92 ChromePermissionMessageProvider::~ChromePermissionMessageProvider() {
82 } 93 }
83 94
84 // static 95 // static
85 PermissionMessages ChromePermissionMessageProvider::GetPermissionMessages( 96 PermissionMessages ChromePermissionMessageProvider::GetPermissionMessages(
(...skipping 11 matching lines...) Expand all
97 std::set<PermissionMessage> host_msgs = 108 std::set<PermissionMessage> host_msgs =
98 GetHostPermissionMessages(permissions, extension_type); 109 GetHostPermissionMessages(permissions, extension_type);
99 std::set<PermissionMessage> api_msgs = GetAPIPermissionMessages(permissions); 110 std::set<PermissionMessage> api_msgs = GetAPIPermissionMessages(permissions);
100 std::set<PermissionMessage> manifest_permission_msgs = 111 std::set<PermissionMessage> manifest_permission_msgs =
101 GetManifestPermissionMessages(permissions); 112 GetManifestPermissionMessages(permissions);
102 messages.insert(messages.end(), host_msgs.begin(), host_msgs.end()); 113 messages.insert(messages.end(), host_msgs.begin(), host_msgs.end());
103 messages.insert(messages.end(), api_msgs.begin(), api_msgs.end()); 114 messages.insert(messages.end(), api_msgs.begin(), api_msgs.end());
104 messages.insert(messages.end(), manifest_permission_msgs.begin(), 115 messages.insert(messages.end(), manifest_permission_msgs.begin(),
105 manifest_permission_msgs.end()); 116 manifest_permission_msgs.end());
106 117
107 // Special hack: bookmarks permission message supersedes override bookmarks UI 118 // Some warnings are more generic and/or powerful and superseed other
108 // permission message if both permissions are specified. 119 // warnings. In that case, suppress the superseeded warning.
109 PermissionMessages::iterator override_bookmarks_ui = 120 SuppressMessage(messages,
110 FindMessageByID(messages, PermissionMessage::kOverrideBookmarksUI); 121 PermissionMessage::kBookmarks,
111 if (override_bookmarks_ui != messages.end() && 122 PermissionMessage::kOverrideBookmarksUI);
112 FindMessageByID(messages, PermissionMessage::kBookmarks) != 123 SuppressMessage(messages,
113 messages.end()) { 124 PermissionMessage::kBrowsingHistory,
114 messages.erase(override_bookmarks_ui); 125 PermissionMessage::kTabs);
115 }
116
117 return messages; 126 return messages;
118 } 127 }
119 128
120 // static 129 // static
121 std::vector<base::string16> ChromePermissionMessageProvider::GetWarningMessages( 130 std::vector<base::string16> ChromePermissionMessageProvider::GetWarningMessages(
122 const PermissionSet* permissions, 131 const PermissionSet* permissions,
123 Manifest::Type extension_type) const { 132 Manifest::Type extension_type) const {
124 std::vector<base::string16> message_strings; 133 std::vector<base::string16> message_strings;
125 PermissionMessages messages = 134 PermissionMessages messages =
126 GetPermissionMessages(permissions, extension_type); 135 GetPermissionMessages(permissions, extension_type);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 PermissionMessage(PermissionMessage::kFileSystemDirectory, 265 PermissionMessage(PermissionMessage::kFileSystemDirectory,
257 base::string16())); 266 base::string16()));
258 } 267 }
259 268
260 // A special hack: The warning message for declarativeWebRequest 269 // A special hack: The warning message for declarativeWebRequest
261 // permissions speaks about blocking parts of pages, which is a 270 // permissions speaks about blocking parts of pages, which is a
262 // subset of what the "<all_urls>" access allows. Therefore we 271 // subset of what the "<all_urls>" access allows. Therefore we
263 // display only the "<all_urls>" warning message if both permissions 272 // display only the "<all_urls>" warning message if both permissions
264 // are required. 273 // are required.
265 if (ShouldWarnAllHosts(permissions)) { 274 if (ShouldWarnAllHosts(permissions)) {
266 messages.erase( 275 messages.erase(
Devlin 2014/04/14 22:27:43 Could we also move this one (and maybe the file sy
meacer 2014/04/15 00:20:44 This automatically merged into the SuppressMessage
267 PermissionMessage( 276 PermissionMessage(
268 PermissionMessage::kDeclarativeWebRequest, base::string16())); 277 PermissionMessage::kDeclarativeWebRequest, base::string16()));
269 } 278 }
270 279
271 return messages; 280 return messages;
272 } 281 }
273 282
274 std::set<PermissionMessage> 283 std::set<PermissionMessage>
275 ChromePermissionMessageProvider::GetManifestPermissionMessages( 284 ChromePermissionMessageProvider::GetManifestPermissionMessages(
276 const PermissionSet* permissions) const { 285 const PermissionSet* permissions) const {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 std::set<std::string> old_hosts_set( 402 std::set<std::string> old_hosts_set(
394 permission_message_util::GetDistinctHosts(old_list, false, false)); 403 permission_message_util::GetDistinctHosts(old_list, false, false));
395 std::set<std::string> new_hosts_only = 404 std::set<std::string> new_hosts_only =
396 base::STLSetDifference<std::set<std::string> >(new_hosts_set, 405 base::STLSetDifference<std::set<std::string> >(new_hosts_set,
397 old_hosts_set); 406 old_hosts_set);
398 407
399 return !new_hosts_only.empty(); 408 return !new_hosts_only.empty();
400 } 409 }
401 410
402 } // namespace extensions 411 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698