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

Side by Side Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.cc

Issue 14651017: Move RuntimeData and related permissions out of Extension class (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_permissions
Patch Set: Latest master Created 7 years, 7 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
OLDNEW
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/browser/extensions/api/declarative_webrequest/webrequest_rules_ registry.h" 5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_ registry.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit ion.h" 13 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit ion.h"
14 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_consta nts.h" 14 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_consta nts.h"
15 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" 15 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h"
16 #include "chrome/browser/extensions/api/web_request/web_request_permissions.h" 16 #include "chrome/browser/extensions/api/web_request/web_request_permissions.h"
17 #include "chrome/browser/extensions/extension_system.h" 17 #include "chrome/browser/extensions/extension_system.h"
18 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
19 #include "chrome/common/extensions/permissions/permissions_data.h"
19 #include "extensions/common/error_utils.h" 20 #include "extensions/common/error_utils.h"
20 #include "net/url_request/url_request.h" 21 #include "net/url_request/url_request.h"
21 22
22 namespace { 23 namespace {
23 24
24 const char kActionCannotBeExecuted[] = "The action '*' can never be executed " 25 const char kActionCannotBeExecuted[] = "The action '*' can never be executed "
25 "because there are is no time in the request life-cycle during which the " 26 "because there are is no time in the request life-cycle during which the "
26 "conditions can be checked and the action can possibly be executed."; 27 "conditions can be checked and the action can possibly be executed.";
27 28
28 const char kAllURLsPermissionNeeded[] = 29 const char kAllURLsPermissionNeeded[] =
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 std::string* error) { 333 std::string* error) {
333 return (StageChecker(conditions, actions, error) && 334 return (StageChecker(conditions, actions, error) &&
334 HostPermissionsChecker(extension, actions, error)); 335 HostPermissionsChecker(extension, actions, error));
335 } 336 }
336 337
337 // static 338 // static
338 bool WebRequestRulesRegistry::HostPermissionsChecker( 339 bool WebRequestRulesRegistry::HostPermissionsChecker(
339 const Extension* extension, 340 const Extension* extension,
340 const WebRequestActionSet* actions, 341 const WebRequestActionSet* actions,
341 std::string* error) { 342 std::string* error) {
342 if (extension->HasEffectiveAccessToAllHosts()) 343 if (PermissionsData::HasEffectiveAccessToAllHosts(extension))
343 return true; 344 return true;
344 345
345 // Without the permission for all URLs, actions with the STRATEGY_DEFAULT 346 // Without the permission for all URLs, actions with the STRATEGY_DEFAULT
346 // should not be registered, they would never be able to execute. 347 // should not be registered, they would never be able to execute.
347 for (WebRequestActionSet::Actions::const_iterator action_iter = 348 for (WebRequestActionSet::Actions::const_iterator action_iter =
348 actions->actions().begin(); 349 actions->actions().begin();
349 action_iter != actions->actions().end(); 350 action_iter != actions->actions().end();
350 ++action_iter) { 351 ++action_iter) {
351 if ((*action_iter)->host_permissions_strategy() == 352 if ((*action_iter)->host_permissions_strategy() ==
352 WebRequestAction::STRATEGY_DEFAULT) { 353 WebRequestAction::STRATEGY_DEFAULT) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 RuleTriggers::const_iterator rule_trigger = rule_triggers_.find(*url_match); 400 RuleTriggers::const_iterator rule_trigger = rule_triggers_.find(*url_match);
400 CHECK(rule_trigger != rule_triggers_.end()); 401 CHECK(rule_trigger != rule_triggers_.end());
401 if (!ContainsKey(*result, rule_trigger->second) && 402 if (!ContainsKey(*result, rule_trigger->second) &&
402 rule_trigger->second->conditions().IsFulfilled(*url_match, 403 rule_trigger->second->conditions().IsFulfilled(*url_match,
403 request_data)) 404 request_data))
404 result->insert(rule_trigger->second); 405 result->insert(rule_trigger->second);
405 } 406 }
406 } 407 }
407 408
408 } // namespace extensions 409 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/cookies/cookies_helpers.cc ('k') | chrome/browser/extensions/api/downloads/downloads_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698