OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "extensions/common/permissions/permissions_data.h" | 5 #include "extensions/common/permissions/permissions_data.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // Otherwise, the valid schemes were handled by URLPattern. | 88 // Otherwise, the valid schemes were handled by URLPattern. |
89 return true; | 89 return true; |
90 } | 90 } |
91 | 91 |
92 // Parses the host and api permissions from the specified permission |key| | 92 // Parses the host and api permissions from the specified permission |key| |
93 // from |extension|'s manifest. | 93 // from |extension|'s manifest. |
94 bool ParseHelper(Extension* extension, | 94 bool ParseHelper(Extension* extension, |
95 const char* key, | 95 const char* key, |
96 APIPermissionSet* api_permissions, | 96 APIPermissionSet* api_permissions, |
97 URLPatternSet* host_permissions, | 97 URLPatternSet* host_permissions, |
98 string16* error) { | 98 base::string16* error) { |
99 if (!extension->manifest()->HasKey(key)) | 99 if (!extension->manifest()->HasKey(key)) |
100 return true; | 100 return true; |
101 | 101 |
102 const base::ListValue* permissions = NULL; | 102 const base::ListValue* permissions = NULL; |
103 if (!extension->manifest()->GetList(key, &permissions)) { | 103 if (!extension->manifest()->GetList(key, &permissions)) { |
104 *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidPermissions, | 104 *error = ErrorUtils::FormatErrorMessageUTF16(errors::kInvalidPermissions, |
105 std::string()); | 105 std::string()); |
106 return false; | 106 return false; |
107 } | 107 } |
108 | 108 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 base::AutoLock auto_lock(extension->permissions_data()->runtime_lock_); | 422 base::AutoLock auto_lock(extension->permissions_data()->runtime_lock_); |
423 if (ShouldSkipPermissionWarnings(extension)) { | 423 if (ShouldSkipPermissionWarnings(extension)) { |
424 return PermissionMessages(); | 424 return PermissionMessages(); |
425 } else { | 425 } else { |
426 return PermissionMessageProvider::Get()->GetPermissionMessages( | 426 return PermissionMessageProvider::Get()->GetPermissionMessages( |
427 GetActivePermissions(extension), extension->GetType()); | 427 GetActivePermissions(extension), extension->GetType()); |
428 } | 428 } |
429 } | 429 } |
430 | 430 |
431 // static | 431 // static |
432 std::vector<string16> PermissionsData::GetPermissionMessageStrings( | 432 std::vector<base::string16> PermissionsData::GetPermissionMessageStrings( |
433 const Extension* extension) { | 433 const Extension* extension) { |
434 base::AutoLock auto_lock(extension->permissions_data()->runtime_lock_); | 434 base::AutoLock auto_lock(extension->permissions_data()->runtime_lock_); |
435 if (ShouldSkipPermissionWarnings(extension)) { | 435 if (ShouldSkipPermissionWarnings(extension)) { |
436 return std::vector<string16>(); | 436 return std::vector<base::string16>(); |
437 } else { | 437 } else { |
438 return PermissionMessageProvider::Get()->GetWarningMessages( | 438 return PermissionMessageProvider::Get()->GetWarningMessages( |
439 GetActivePermissions(extension), extension->GetType()); | 439 GetActivePermissions(extension), extension->GetType()); |
440 } | 440 } |
441 } | 441 } |
442 | 442 |
443 // static | 443 // static |
444 std::vector<string16> PermissionsData::GetPermissionMessageDetailsStrings( | 444 std::vector<base::string16> PermissionsData::GetPermissionMessageDetailsStrings( |
445 const Extension* extension) { | 445 const Extension* extension) { |
446 base::AutoLock auto_lock(extension->permissions_data()->runtime_lock_); | 446 base::AutoLock auto_lock(extension->permissions_data()->runtime_lock_); |
447 if (ShouldSkipPermissionWarnings(extension)) { | 447 if (ShouldSkipPermissionWarnings(extension)) { |
448 return std::vector<string16>(); | 448 return std::vector<base::string16>(); |
449 } else { | 449 } else { |
450 return PermissionMessageProvider::Get()->GetWarningMessagesDetails( | 450 return PermissionMessageProvider::Get()->GetWarningMessagesDetails( |
451 GetActivePermissions(extension), extension->GetType()); | 451 GetActivePermissions(extension), extension->GetType()); |
452 } | 452 } |
453 } | 453 } |
454 | 454 |
455 // static | 455 // static |
456 bool PermissionsData::CanExecuteScriptOnPage(const Extension* extension, | 456 bool PermissionsData::CanExecuteScriptOnPage(const Extension* extension, |
457 const GURL& document_url, | 457 const GURL& document_url, |
458 const GURL& top_frame_url, | 458 const GURL& top_frame_url, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 return true; | 554 return true; |
555 } | 555 } |
556 | 556 |
557 if (error) { | 557 if (error) { |
558 *error = ErrorUtils::FormatErrorMessage(errors::kCannotAccessPage, | 558 *error = ErrorUtils::FormatErrorMessage(errors::kCannotAccessPage, |
559 page_url.spec()); | 559 page_url.spec()); |
560 } | 560 } |
561 return false; | 561 return false; |
562 } | 562 } |
563 | 563 |
564 bool PermissionsData::ParsePermissions(Extension* extension, string16* error) { | 564 bool PermissionsData::ParsePermissions(Extension* extension, |
| 565 base::string16* error) { |
565 initial_required_permissions_.reset(new InitialPermissions); | 566 initial_required_permissions_.reset(new InitialPermissions); |
566 if (!ParseHelper(extension, | 567 if (!ParseHelper(extension, |
567 keys::kPermissions, | 568 keys::kPermissions, |
568 &initial_required_permissions_->api_permissions, | 569 &initial_required_permissions_->api_permissions, |
569 &initial_required_permissions_->host_permissions, | 570 &initial_required_permissions_->host_permissions, |
570 error)) { | 571 error)) { |
571 return false; | 572 return false; |
572 } | 573 } |
573 | 574 |
574 // TODO(jeremya/kalman) do this via the features system by exposing the | 575 // TODO(jeremya/kalman) do this via the features system by exposing the |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 initial_optional_permissions_->api_permissions, | 618 initial_optional_permissions_->api_permissions, |
618 initial_optional_permissions_->manifest_permissions, | 619 initial_optional_permissions_->manifest_permissions, |
619 initial_optional_permissions_->host_permissions, | 620 initial_optional_permissions_->host_permissions, |
620 URLPatternSet()); | 621 URLPatternSet()); |
621 | 622 |
622 initial_required_permissions_.reset(); | 623 initial_required_permissions_.reset(); |
623 initial_optional_permissions_.reset(); | 624 initial_optional_permissions_.reset(); |
624 } | 625 } |
625 | 626 |
626 } // namespace extensions | 627 } // namespace extensions |
OLD | NEW |