| 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 "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/api/plugins/plugins_handler.h" | 11 #include "chrome/common/extensions/api/plugins/plugins_handler.h" |
| 12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 13 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" |
| 13 #include "chrome/common/extensions/manifest_url_handler.h" | 14 #include "chrome/common/extensions/manifest_url_handler.h" |
| 14 #include "chrome/common/extensions/permissions/permissions_info.h" | 15 #include "chrome/common/extensions/permissions/permissions_info.h" |
| 15 #include "content/public/common/url_constants.h" | 16 #include "content/public/common/url_constants.h" |
| 16 #include "extensions/common/url_pattern.h" | 17 #include "extensions/common/url_pattern.h" |
| 17 #include "extensions/common/url_pattern_set.h" | 18 #include "extensions/common/url_pattern_set.h" |
| 18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 19 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 20 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 21 | 22 |
| 22 using extensions::URLPatternSet; | 23 using extensions::URLPatternSet; |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 const extensions::Extension* extension) { | 529 const extensions::Extension* extension) { |
| 529 // Add the implied permissions. | 530 // Add the implied permissions. |
| 530 if (extensions::PluginInfo::HasPlugins(extension)) | 531 if (extensions::PluginInfo::HasPlugins(extension)) |
| 531 apis_.insert(APIPermission::kPlugin); | 532 apis_.insert(APIPermission::kPlugin); |
| 532 | 533 |
| 533 if (!ManifestURL::GetDevToolsPage(extension).is_empty()) | 534 if (!ManifestURL::GetDevToolsPage(extension).is_empty()) |
| 534 apis_.insert(APIPermission::kDevtools); | 535 apis_.insert(APIPermission::kDevtools); |
| 535 | 536 |
| 536 // Add the scriptable hosts. | 537 // Add the scriptable hosts. |
| 537 for (extensions::UserScriptList::const_iterator content_script = | 538 for (extensions::UserScriptList::const_iterator content_script = |
| 538 extension->content_scripts().begin(); | 539 ContentScriptsInfo::GetContentScripts(extension).begin(); |
| 539 content_script != extension->content_scripts().end(); ++content_script) { | 540 content_script != ContentScriptsInfo::GetContentScripts(extension).end(); |
| 541 ++content_script) { |
| 540 URLPatternSet::const_iterator pattern = | 542 URLPatternSet::const_iterator pattern = |
| 541 content_script->url_patterns().begin(); | 543 content_script->url_patterns().begin(); |
| 542 for (; pattern != content_script->url_patterns().end(); ++pattern) | 544 for (; pattern != content_script->url_patterns().end(); ++pattern) |
| 543 scriptable_hosts_.AddPattern(*pattern); | 545 scriptable_hosts_.AddPattern(*pattern); |
| 544 } | 546 } |
| 545 } | 547 } |
| 546 | 548 |
| 547 void PermissionSet::InitEffectiveHosts() { | 549 void PermissionSet::InitEffectiveHosts() { |
| 548 effective_hosts_.ClearPatterns(); | 550 effective_hosts_.ClearPatterns(); |
| 549 | 551 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 std::set<std::string> new_hosts_only; | 608 std::set<std::string> new_hosts_only; |
| 607 | 609 |
| 608 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), | 610 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), |
| 609 old_hosts_set.begin(), old_hosts_set.end(), | 611 old_hosts_set.begin(), old_hosts_set.end(), |
| 610 std::inserter(new_hosts_only, new_hosts_only.begin())); | 612 std::inserter(new_hosts_only, new_hosts_only.begin())); |
| 611 | 613 |
| 612 return !new_hosts_only.empty(); | 614 return !new_hosts_only.empty(); |
| 613 } | 615 } |
| 614 | 616 |
| 615 } // namespace extensions | 617 } // namespace extensions |
| OLD | NEW |