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

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

Issue 253433002: Stop prompting for the file system write permission in packaged apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Indent 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
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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 for (APIPermissionSet::const_iterator permission_it = 250 for (APIPermissionSet::const_iterator permission_it =
251 permissions->apis().begin(); 251 permissions->apis().begin();
252 permission_it != permissions->apis().end(); ++permission_it) { 252 permission_it != permissions->apis().end(); ++permission_it) {
253 if (permission_it->HasMessages()) { 253 if (permission_it->HasMessages()) {
254 PermissionMessages new_messages = permission_it->GetMessages(); 254 PermissionMessages new_messages = permission_it->GetMessages();
255 messages.insert(new_messages.begin(), new_messages.end()); 255 messages.insert(new_messages.begin(), new_messages.end());
256 } 256 }
257 } 257 }
258 258
259 // A special hack: If kFileSystemWriteDirectory would be displayed, hide 259 // A special hack: If kFileSystemWriteDirectory would be displayed, hide
260 // kFileSystemDirectory and and kFileSystemWrite as the write directory 260 // kFileSystemDirectory as the write directory message implies it.
261 // message implies the other two.
262 // TODO(sammc): Remove this. See http://crbug.com/284849. 261 // TODO(sammc): Remove this. See http://crbug.com/284849.
263 SuppressMessage(messages, 262 SuppressMessage(messages,
264 PermissionMessage::kFileSystemWriteDirectory, 263 PermissionMessage::kFileSystemWriteDirectory,
265 PermissionMessage::kFileSystemWrite);
266 SuppressMessage(messages,
267 PermissionMessage::kFileSystemWriteDirectory,
268 PermissionMessage::kFileSystemDirectory); 264 PermissionMessage::kFileSystemDirectory);
269 // A special hack: The warning message for declarativeWebRequest 265 // A special hack: The warning message for declarativeWebRequest
270 // permissions speaks about blocking parts of pages, which is a 266 // permissions speaks about blocking parts of pages, which is a
271 // subset of what the "<all_urls>" access allows. Therefore we 267 // subset of what the "<all_urls>" access allows. Therefore we
272 // display only the "<all_urls>" warning message if both permissions 268 // display only the "<all_urls>" warning message if both permissions
273 // are required. 269 // are required.
274 if (ShouldWarnAllHosts(permissions)) { 270 if (ShouldWarnAllHosts(permissions)) {
275 messages.erase( 271 messages.erase(
276 PermissionMessage( 272 PermissionMessage(
277 PermissionMessage::kDeclarativeWebRequest, base::string16())); 273 PermissionMessage::kDeclarativeWebRequest, base::string16()));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 const PermissionSet* old_permissions, 324 const PermissionSet* old_permissions,
329 const PermissionSet* new_permissions) const { 325 const PermissionSet* new_permissions) const {
330 if (new_permissions == NULL) 326 if (new_permissions == NULL)
331 return false; 327 return false;
332 328
333 PermissionMsgSet old_warnings = GetAPIPermissionMessages(old_permissions); 329 PermissionMsgSet old_warnings = GetAPIPermissionMessages(old_permissions);
334 PermissionMsgSet new_warnings = GetAPIPermissionMessages(new_permissions); 330 PermissionMsgSet new_warnings = GetAPIPermissionMessages(new_permissions);
335 PermissionMsgSet delta_warnings = 331 PermissionMsgSet delta_warnings =
336 base::STLSetDifference<PermissionMsgSet>(new_warnings, old_warnings); 332 base::STLSetDifference<PermissionMsgSet>(new_warnings, old_warnings);
337 333
338 // A special hack: kFileSystemWriteDirectory implies kFileSystemDirectory and 334 // A special hack: kFileSystemWriteDirectory implies kFileSystemDirectory.
339 // kFileSystemWrite.
340 // TODO(sammc): Remove this. See http://crbug.com/284849. 335 // TODO(sammc): Remove this. See http://crbug.com/284849.
341 if (old_warnings.find(PermissionMessage( 336 if (old_warnings.find(PermissionMessage(
342 PermissionMessage::kFileSystemWriteDirectory, base::string16())) != 337 PermissionMessage::kFileSystemWriteDirectory, base::string16())) !=
343 old_warnings.end()) { 338 old_warnings.end()) {
344 delta_warnings.erase( 339 delta_warnings.erase(
345 PermissionMessage(PermissionMessage::kFileSystemDirectory, 340 PermissionMessage(PermissionMessage::kFileSystemDirectory,
346 base::string16())); 341 base::string16()));
347 delta_warnings.erase(
348 PermissionMessage(PermissionMessage::kFileSystemWrite,
349 base::string16()));
350 } 342 }
351 343
352 // It is a privilege increase if there are additional warnings present. 344 // It is a privilege increase if there are additional warnings present.
353 return !delta_warnings.empty(); 345 return !delta_warnings.empty();
354 } 346 }
355 347
356 bool ChromePermissionMessageProvider::IsManifestPermissionPrivilegeIncrease( 348 bool ChromePermissionMessageProvider::IsManifestPermissionPrivilegeIncrease(
357 const PermissionSet* old_permissions, 349 const PermissionSet* old_permissions,
358 const PermissionSet* new_permissions) const { 350 const PermissionSet* new_permissions) const {
359 if (new_permissions == NULL) 351 if (new_permissions == NULL)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 std::set<std::string> old_hosts_set( 391 std::set<std::string> old_hosts_set(
400 permission_message_util::GetDistinctHosts(old_list, false, false)); 392 permission_message_util::GetDistinctHosts(old_list, false, false));
401 std::set<std::string> new_hosts_only = 393 std::set<std::string> new_hosts_only =
402 base::STLSetDifference<std::set<std::string> >(new_hosts_set, 394 base::STLSetDifference<std::set<std::string> >(new_hosts_set,
403 old_hosts_set); 395 old_hosts_set);
404 396
405 return !new_hosts_only.empty(); 397 return !new_hosts_only.empty();
406 } 398 }
407 399
408 } // namespace extensions 400 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698