Chromium Code Reviews| 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 | 530 |
| 531 const ExtensionsClient::ScriptingWhitelist& whitelist = | 531 const ExtensionsClient::ScriptingWhitelist& whitelist = |
| 532 ExtensionsClient::Get()->GetScriptingWhitelist(); | 532 ExtensionsClient::Get()->GetScriptingWhitelist(); |
| 533 | 533 |
| 534 return std::find(whitelist.begin(), whitelist.end(), extension->id()) != | 534 return std::find(whitelist.begin(), whitelist.end(), extension->id()) != |
| 535 whitelist.end(); | 535 whitelist.end(); |
| 536 } | 536 } |
| 537 | 537 |
| 538 // static | 538 // static |
| 539 bool PermissionsData::CanCaptureVisiblePage(const Extension* extension, | 539 bool PermissionsData::CanCaptureVisiblePage(const Extension* extension, |
| 540 const GURL& page_url, | |
| 541 int tab_id, | 540 int tab_id, |
| 542 std::string* error) { | 541 std::string* error) { |
| 543 if (tab_id >= 0) { | 542 scoped_refptr<const PermissionSet> tab_permissions = |
| 544 scoped_refptr<const PermissionSet> tab_permissions = | 543 GetActivePermissions(extension); |
| 545 GetTabSpecificPermissions(extension, tab_id); | 544 URLPattern all_urls(URLPattern::SCHEME_ALL); |
| 546 if (tab_permissions.get() && | 545 all_urls.SetMatchAllURLs(true); |
|
not at google - send to devlin
2014/01/16 17:48:26
you can construct this in a single line with
URLP
sadrul
2014/01/20 13:53:37
Done.
| |
| 547 tab_permissions->explicit_hosts().MatchesSecurityOrigin(page_url)) { | 546 if (tab_permissions.get() && |
|
not at google - send to devlin
2014/01/16 17:48:26
I think there will always be active permissions, s
sadrul
2014/01/20 13:53:37
Done.
not at google - send to devlin
2014/01/21 21:44:21
I think I may have misread your code actually :\
sadrul
2014/01/23 20:11:14
Restored the null check for |tab_permissions|
| |
| 548 return true; | 547 tab_permissions->explicit_hosts().ContainsPattern(all_urls)) { |
| 549 } | |
| 550 } | |
| 551 | |
| 552 if (HasHostPermission(extension, page_url) || | |
| 553 page_url.GetOrigin() == extension->url()) { | |
| 554 return true; | 548 return true; |
| 555 } | 549 } |
| 556 | 550 |
| 557 if (error) { | 551 if (tab_id >= 0 && |
| 558 *error = ErrorUtils::FormatErrorMessage(errors::kCannotAccessPage, | 552 HasAPIPermission(extension, APIPermission::kActiveTab) && |
| 559 page_url.spec()); | 553 GetTabSpecificPermissions(extension, tab_id)) { |
|
not at google - send to devlin
2014/01/16 17:48:26
I think the old check was what you want? the tab_p
sadrul
2014/01/20 13:53:37
If the extension has the |activeTab| permission, a
not at google - send to devlin
2014/01/21 21:44:21
I think you're right; the checks are actually effe
sadrul
2014/01/23 20:11:14
Yep, sounds good. Done.
| |
| 554 return true; | |
| 560 } | 555 } |
| 556 | |
| 557 if (error) | |
| 558 *error = errors::kAllURLOrActiveTabNeeded; | |
|
not at google - send to devlin
2014/01/16 17:48:26
hopefully developers won't be confused... "but I h
sadrul
2014/01/20 13:53:37
Done. (please let me know if you have suggestion a
| |
| 561 return false; | 559 return false; |
| 562 } | 560 } |
| 563 | 561 |
| 564 bool PermissionsData::ParsePermissions(Extension* extension, | 562 bool PermissionsData::ParsePermissions(Extension* extension, |
| 565 base::string16* error) { | 563 base::string16* error) { |
| 566 initial_required_permissions_.reset(new InitialPermissions); | 564 initial_required_permissions_.reset(new InitialPermissions); |
| 567 if (!ParseHelper(extension, | 565 if (!ParseHelper(extension, |
| 568 keys::kPermissions, | 566 keys::kPermissions, |
| 569 &initial_required_permissions_->api_permissions, | 567 &initial_required_permissions_->api_permissions, |
| 570 &initial_required_permissions_->host_permissions, | 568 &initial_required_permissions_->host_permissions, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 initial_optional_permissions_->api_permissions, | 616 initial_optional_permissions_->api_permissions, |
| 619 initial_optional_permissions_->manifest_permissions, | 617 initial_optional_permissions_->manifest_permissions, |
| 620 initial_optional_permissions_->host_permissions, | 618 initial_optional_permissions_->host_permissions, |
| 621 URLPatternSet()); | 619 URLPatternSet()); |
| 622 | 620 |
| 623 initial_required_permissions_.reset(); | 621 initial_required_permissions_.reset(); |
| 624 initial_optional_permissions_.reset(); | 622 initial_optional_permissions_.reset(); |
| 625 } | 623 } |
| 626 | 624 |
| 627 } // namespace extensions | 625 } // namespace extensions |
| OLD | NEW |