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

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

Issue 16295003: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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) 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_action .h" 5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action .h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/json/json_file_value_serializer.h" 8 #include "base/json/json_file_value_serializer.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 void WebRequestActionWithThreadsTest::SetUp() { 106 void WebRequestActionWithThreadsTest::SetUp() {
107 testing::Test::SetUp(); 107 testing::Test::SetUp();
108 108
109 std::string error; 109 std::string error;
110 extension_ = LoadManifestUnchecked("permissions", 110 extension_ = LoadManifestUnchecked("permissions",
111 "web_request_com_host_permissions.json", 111 "web_request_com_host_permissions.json",
112 Manifest::INVALID_LOCATION, 112 Manifest::INVALID_LOCATION,
113 Extension::NO_FLAGS, 113 Extension::NO_FLAGS,
114 "ext_id_1", 114 "ext_id_1",
115 &error); 115 &error);
116 ASSERT_TRUE(extension_) << error; 116 ASSERT_TRUE(extension_.get()) << error;
117 extension_all_urls_ = 117 extension_all_urls_ =
118 LoadManifestUnchecked("permissions", 118 LoadManifestUnchecked("permissions",
119 "web_request_all_host_permissions.json", 119 "web_request_all_host_permissions.json",
120 Manifest::INVALID_LOCATION, 120 Manifest::INVALID_LOCATION,
121 Extension::NO_FLAGS, 121 Extension::NO_FLAGS,
122 "ext_id_2", 122 "ext_id_2",
123 &error); 123 &error);
124 ASSERT_TRUE(extension_all_urls_) << error; 124 ASSERT_TRUE(extension_all_urls_.get()) << error;
125 extension_info_map_ = new ExtensionInfoMap; 125 extension_info_map_ = new ExtensionInfoMap;
126 ASSERT_TRUE(extension_info_map_); 126 ASSERT_TRUE(extension_info_map_.get());
127 extension_info_map_->AddExtension( 127 extension_info_map_->AddExtension(
128 extension_.get(), base::Time::Now(), false /*incognito_enabled*/); 128 extension_.get(), base::Time::Now(), false /*incognito_enabled*/);
129 extension_info_map_->AddExtension(extension_all_urls_.get(), 129 extension_info_map_->AddExtension(extension_all_urls_.get(),
130 base::Time::Now(), 130 base::Time::Now(),
131 false /*incognito_enabled*/); 131 false /*incognito_enabled*/);
132 } 132 }
133 133
134 bool WebRequestActionWithThreadsTest::ActionWorksOnRequest( 134 bool WebRequestActionWithThreadsTest::ActionWorksOnRequest(
135 const char* url_string, 135 const char* url_string,
136 const std::string& extension_id, 136 const std::string& extension_id,
137 const WebRequestActionSet* action_set, 137 const WebRequestActionSet* action_set,
138 RequestStage stage) { 138 RequestStage stage) {
139 net::TestURLRequest regular_request(GURL(url_string), NULL, &context_, NULL); 139 net::TestURLRequest regular_request(GURL(url_string), NULL, &context_, NULL);
140 std::list<LinkedPtrEventResponseDelta> deltas; 140 std::list<LinkedPtrEventResponseDelta> deltas;
141 scoped_refptr<net::HttpResponseHeaders> headers( 141 scoped_refptr<net::HttpResponseHeaders> headers(
142 new net::HttpResponseHeaders("")); 142 new net::HttpResponseHeaders(""));
143 WebRequestData request_data(&regular_request, stage, headers); 143 WebRequestData request_data(&regular_request, stage, headers.get());
144 std::set<std::string> ignored_tags; 144 std::set<std::string> ignored_tags;
145 WebRequestAction::ApplyInfo apply_info = { 145 WebRequestAction::ApplyInfo apply_info = { extension_info_map_.get(),
146 extension_info_map_, request_data, false /*crosses_incognito*/, &deltas, 146 request_data,
147 &ignored_tags 147 false /*crosses_incognito*/,
148 }; 148 &deltas, &ignored_tags };
149 action_set->Apply(extension_id, base::Time(), &apply_info); 149 action_set->Apply(extension_id, base::Time(), &apply_info);
150 return (1u == deltas.size() || 0u < ignored_tags.size()); 150 return (1u == deltas.size() || 0u < ignored_tags.size());
151 } 151 }
152 152
153 void WebRequestActionWithThreadsTest::CheckActionNeedsAllUrls( 153 void WebRequestActionWithThreadsTest::CheckActionNeedsAllUrls(
154 const char* action, 154 const char* action,
155 RequestStage stage) { 155 RequestStage stage) {
156 scoped_ptr<WebRequestActionSet> action_set(CreateSetOfActions(action)); 156 scoped_ptr<WebRequestActionSet> action_set(CreateSetOfActions(action));
157 157
158 // Although |extension_| has matching *.com host permission, |action| 158 // Although |extension_| has matching *.com host permission, |action|
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 for (WebRequestActionSet::Actions::const_iterator it = 567 for (WebRequestActionSet::Actions::const_iterator it =
568 action_set->actions().begin(); 568 action_set->actions().begin();
569 it != action_set->actions().end(); 569 it != action_set->actions().end();
570 ++it) { 570 ++it) {
571 EXPECT_EQ(kExpectedNames[index], (*it)->GetName()); 571 EXPECT_EQ(kExpectedNames[index], (*it)->GetName());
572 ++index; 572 ++index;
573 } 573 }
574 } 574 }
575 575
576 } // namespace extensions 576 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698