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

Side by Side Diff: chrome/browser/extensions/extension_info_map.cc

Issue 8312005: Ignore paths when matching patterns for extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix silly typo. Created 9 years, 1 month 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/browser/extensions/extension_info_map.h" 5 #include "chrome/browser/extensions/extension_info_map.h"
6 6
7 #include "chrome/common/extensions/extension.h" 7 #include "chrome/common/extensions/extension.h"
8 #include "chrome/common/extensions/extension_set.h"
9 #include "chrome/common/url_constants.h"
8 #include "content/browser/browser_thread.h" 10 #include "content/browser/browser_thread.h"
9 11
10 namespace { 12 namespace {
11 13
12 void CheckOnValidThread() { 14 void CheckOnValidThread() {
13 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 15 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
14 } 16 }
15 17
16 } // namespace 18 } // namespace
17 19
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 117 }
116 118
117 bool ExtensionInfoMap::IsExtensionInProcess( 119 bool ExtensionInfoMap::IsExtensionInProcess(
118 const std::string& extension_id, int process_id) const { 120 const std::string& extension_id, int process_id) const {
119 return std::find( 121 return std::find(
120 extension_process_ids_.begin(), 122 extension_process_ids_.begin(),
121 extension_process_ids_.end(), 123 extension_process_ids_.end(),
122 ExtensionProcessIDMap::value_type(extension_id, process_id)) != 124 ExtensionProcessIDMap::value_type(extension_id, process_id)) !=
123 extension_process_ids_.end(); 125 extension_process_ids_.end();
124 } 126 }
127
128 bool ExtensionInfoMap::SecurityOriginHasAPIPermission(
129 const GURL& origin, int process_id,
Aaron Boodman 2011/10/31 23:57:11 How about adding GetByOrigin to ExtensionSet? That
dcheng 2011/11/01 18:18:02 Before I update this, what would GetByOrigin retur
Aaron Boodman 2011/11/01 19:20:57 Yeah, I realized this won't work on the train ride
130 ExtensionAPIPermission::ID permission) const {
131 if (origin.SchemeIs(chrome::kExtensionScheme)) {
132 const std::string& id = origin.host();
133 return extensions_.GetByID(id)->HasAPIPermission(permission) &&
134 IsExtensionInProcess(id, process_id);
135 }
136
137 ExtensionSet::ExtensionMap::const_iterator i = extensions_.begin();
138 for (; i != extensions_.end(); ++i) {
139 if (i->second->web_extent().MatchesSecurityOrigin(origin) &&
140 IsExtensionInProcess(i->first, process_id) &&
141 i->second->HasAPIPermission(permission)) {
142 return true;
143 }
144 }
145 return false;
146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698