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

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

Issue 9820003: Implementation of beginning of Declarative Web Request API backend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h "
6
7 #include "base/logging.h"
8 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action .h"
9 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit ion.h"
10
11 namespace extensions {
12 namespace declarative_webrequest {
13
14 WebRequestRule::WebRequestRule(
15 scoped_ptr<WebRequestConditionCollection> conditions,
16 scoped_ptr<WebRequestActionCollection> actions)
17 : conditions_(conditions.release()),
18 actions_(actions.release()) {
19 CHECK(conditions_.get());
20 CHECK(actions_.get());
21 }
22
23 WebRequestRule::~WebRequestRule() {}
24
25 // static
26 bool WebRequestRuleFactory::CheckConsistency(
27 WebRequestConditionCollection* conditions,
28 WebRequestActionCollection* actions,
29 std::string* error) {
30 // TODO(battre): Implement this.
31 return true;
32 }
33
34 // static
35 scoped_ptr<WebRequestRule> WebRequestRuleFactory::CreateRule(
36 URLMatcherConditionFactory* url_matcher_condition_factory,
37 linked_ptr<RulesRegistry::Rule> rule,
38 std::string* error) {
39 scoped_ptr<WebRequestRule> error_result;
40
41 scoped_ptr<WebRequestConditionCollection> conditions =
42 WebRequestConditionFactory::CreateConditionCollection(
Matt Perry 2012/03/22 23:07:25 +2 indent
battre 2012/03/26 18:35:51 Done.
43 url_matcher_condition_factory, rule->conditions, error);
44 if (!error->empty())
45 return error_result.Pass();
46 CHECK(conditions.get());
47
48 // Parse Actions
Matt Perry 2012/03/22 23:07:25 nit: superfluous comment
battre 2012/03/26 18:35:51 Done.
49 scoped_ptr<WebRequestActionCollection> actions =
50 WebRequestActionFactory::CreateActionCollection(rule->actions, error);
51 if (!error->empty())
52 return error_result.Pass();
53 CHECK(actions.get());
54
55 if (!CheckConsistency(conditions.get(), actions.get(), error)) {
56 DCHECK(!error->empty());
57 return error_result.Pass();
58 }
59
60 return scoped_ptr<WebRequestRule>(
61 new WebRequestRule(conditions.Pass(), actions.Pass()));
62 }
63
64 } // namespace declarative_webrequest
65 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698