| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/permission_set.h" | 5 #include "chrome/common/extensions/permissions/permission_set.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
| 12 #include "chrome/common/extensions/manifest_url_handler.h" |
| 12 #include "chrome/common/extensions/permissions/permissions_info.h" | 13 #include "chrome/common/extensions/permissions/permissions_info.h" |
| 13 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
| 14 #include "extensions/common/url_pattern.h" | 15 #include "extensions/common/url_pattern.h" |
| 15 #include "extensions/common/url_pattern_set.h" | 16 #include "extensions/common/url_pattern_set.h" |
| 16 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 17 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 19 | 20 |
| 20 using extensions::URLPatternSet; | 21 using extensions::URLPatternSet; |
| 21 | 22 |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 // The fileBrowserHandler permission implies the internal version as well. | 523 // The fileBrowserHandler permission implies the internal version as well. |
| 523 if (apis_.find(APIPermission::kFileBrowserHandler) != apis_.end()) | 524 if (apis_.find(APIPermission::kFileBrowserHandler) != apis_.end()) |
| 524 apis_.insert(APIPermission::kFileBrowserHandlerInternal); | 525 apis_.insert(APIPermission::kFileBrowserHandlerInternal); |
| 525 } | 526 } |
| 526 | 527 |
| 527 void PermissionSet::InitImplicitExtensionPermissions( | 528 void PermissionSet::InitImplicitExtensionPermissions( |
| 528 const extensions::Extension* extension) { | 529 const extensions::Extension* extension) { |
| 529 // Add the implied permissions. | 530 // Add the implied permissions. |
| 530 if (!extension->plugins().empty()) | 531 if (!extension->plugins().empty()) |
| 531 apis_.insert(APIPermission::kPlugin); | 532 apis_.insert(APIPermission::kPlugin); |
| 532 | 533 if (!ManifestURL::GetDevToolsPage(extension).is_empty()) |
| 533 if (!extension->devtools_url().is_empty()) | |
| 534 apis_.insert(APIPermission::kDevtools); | 534 apis_.insert(APIPermission::kDevtools); |
| 535 | 535 |
| 536 // Add the scriptable hosts. | 536 // Add the scriptable hosts. |
| 537 for (extensions::UserScriptList::const_iterator content_script = | 537 for (extensions::UserScriptList::const_iterator content_script = |
| 538 extension->content_scripts().begin(); | 538 extension->content_scripts().begin(); |
| 539 content_script != extension->content_scripts().end(); ++content_script) { | 539 content_script != extension->content_scripts().end(); ++content_script) { |
| 540 URLPatternSet::const_iterator pattern = | 540 URLPatternSet::const_iterator pattern = |
| 541 content_script->url_patterns().begin(); | 541 content_script->url_patterns().begin(); |
| 542 for (; pattern != content_script->url_patterns().end(); ++pattern) | 542 for (; pattern != content_script->url_patterns().end(); ++pattern) |
| 543 scriptable_hosts_.AddPattern(*pattern); | 543 scriptable_hosts_.AddPattern(*pattern); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 std::set<std::string> new_hosts_only; | 606 std::set<std::string> new_hosts_only; |
| 607 | 607 |
| 608 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), | 608 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), |
| 609 old_hosts_set.begin(), old_hosts_set.end(), | 609 old_hosts_set.begin(), old_hosts_set.end(), |
| 610 std::inserter(new_hosts_only, new_hosts_only.begin())); | 610 std::inserter(new_hosts_only, new_hosts_only.begin())); |
| 611 | 611 |
| 612 return !new_hosts_only.empty(); | 612 return !new_hosts_only.empty(); |
| 613 } | 613 } |
| 614 | 614 |
| 615 } // namespace extensions | 615 } // namespace extensions |
| OLD | NEW |