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

Side by Side Diff: chrome/common/extensions/extension_permission_set.cc

Issue 8138004: Fix issues related to <all_urls> in extensions. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: . Created 9 years, 2 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_permission_set.h" 5 #include "chrome/common/extensions/extension_permission_set.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 std::set<std::string> distinct_hosts; 740 std::set<std::string> distinct_hosts;
741 for (HostVector::iterator it = hosts_best_rcd.begin(); 741 for (HostVector::iterator it = hosts_best_rcd.begin();
742 it != hosts_best_rcd.end(); ++it) 742 it != hosts_best_rcd.end(); ++it)
743 distinct_hosts.insert(it->first + it->second); 743 distinct_hosts.insert(it->first + it->second);
744 return distinct_hosts; 744 return distinct_hosts;
745 } 745 }
746 746
747 void ExtensionPermissionSet::InitEffectiveHosts() { 747 void ExtensionPermissionSet::InitEffectiveHosts() {
748 effective_hosts_.ClearPatterns(); 748 effective_hosts_.ClearPatterns();
749 749
750 URLPatternSet::CreateUnion(
751 explicit_hosts(), scriptable_hosts(), &effective_hosts_);
752
753 // When this has effective access to all hosts, compact the list of hosts
754 // to only contain <all_urls>.
750 if (HasEffectiveAccessToAllHosts()) { 755 if (HasEffectiveAccessToAllHosts()) {
751 URLPattern all_urls(URLPattern::SCHEME_ALL); 756 URLPattern all_urls(URLPattern::SCHEME_ALL);
752 all_urls.SetMatchAllURLs(true); 757 all_urls.SetMatchAllURLs(true);
758 effective_hosts_.ClearPatterns();
753 effective_hosts_.AddPattern(all_urls); 759 effective_hosts_.AddPattern(all_urls);
754 return; 760 return;
755 } 761 }
756
757 URLPatternSet::CreateUnion(
758 explicit_hosts(), scriptable_hosts(), &effective_hosts_);
759 } 762 }
760 763
761 void ExtensionPermissionSet::InitImplicitExtensionPermissions( 764 void ExtensionPermissionSet::InitImplicitExtensionPermissions(
762 const Extension* extension) { 765 const Extension* extension) {
763 // Add the implied permissions. 766 // Add the implied permissions.
764 if (!extension->plugins().empty()) 767 if (!extension->plugins().empty())
765 apis_.insert(ExtensionAPIPermission::kPlugin); 768 apis_.insert(ExtensionAPIPermission::kPlugin);
766 769
767 if (!extension->devtools_url().is_empty()) 770 if (!extension->devtools_url().is_empty())
768 apis_.insert(ExtensionAPIPermission::kDevtools); 771 apis_.insert(ExtensionAPIPermission::kDevtools);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 std::set<std::string> new_hosts_set(GetDistinctHosts(new_list, false, false)); 840 std::set<std::string> new_hosts_set(GetDistinctHosts(new_list, false, false));
838 std::set<std::string> old_hosts_set(GetDistinctHosts(old_list, false, false)); 841 std::set<std::string> old_hosts_set(GetDistinctHosts(old_list, false, false));
839 std::set<std::string> new_hosts_only; 842 std::set<std::string> new_hosts_only;
840 843
841 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), 844 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(),
842 old_hosts_set.begin(), old_hosts_set.end(), 845 old_hosts_set.begin(), old_hosts_set.end(),
843 std::inserter(new_hosts_only, new_hosts_only.begin())); 846 std::inserter(new_hosts_only, new_hosts_only.begin()));
844 847
845 return !new_hosts_only.empty(); 848 return !new_hosts_only.empty();
846 } 849 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698