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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_api_unittest.cc

Issue 10836206: Removed static factories for data, ftp, file, and about jobs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: small fix Created 8 years, 4 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 <map> 5 #include <map>
6 #include <queue> 6 #include <queue>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/json/json_string_value_serializer.h" 11 #include "base/json/json_string_value_serializer.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
17 #include "chrome/browser/api/prefs/pref_member.h" 17 #include "chrome/browser/api/prefs/pref_member.h"
18 #include "chrome/browser/content_settings/cookie_settings.h" 18 #include "chrome/browser/content_settings/cookie_settings.h"
19 #include "chrome/browser/extensions/api/web_request/web_request_api.h" 19 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
20 #include "chrome/browser/extensions/api/web_request/web_request_api_constants.h" 20 #include "chrome/browser/extensions/api/web_request/web_request_api_constants.h"
21 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" 21 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h"
22 #include "chrome/browser/extensions/event_router_forwarder.h" 22 #include "chrome/browser/extensions/event_router_forwarder.h"
23 #include "chrome/browser/net/about_protocol_handler.h"
23 #include "chrome/browser/net/chrome_network_delegate.h" 24 #include "chrome/browser/net/chrome_network_delegate.h"
24 #include "chrome/common/extensions/extension_messages.h" 25 #include "chrome/common/extensions/extension_messages.h"
25 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
26 #include "chrome/test/base/testing_browser_process.h" 27 #include "chrome/test/base/testing_browser_process.h"
27 #include "chrome/test/base/testing_pref_service.h" 28 #include "chrome/test/base/testing_pref_service.h"
28 #include "chrome/test/base/testing_profile.h" 29 #include "chrome/test/base/testing_profile.h"
29 #include "content/public/test/test_browser_thread.h" 30 #include "content/public/test/test_browser_thread.h"
30 #include "net/base/auth.h" 31 #include "net/base/auth.h"
31 #include "net/base/capturing_net_log.h" 32 #include "net/base/capturing_net_log.h"
32 #include "net/base/mock_host_resolver.h" 33 #include "net/base/mock_host_resolver.h"
33 #include "net/base/net_util.h" 34 #include "net/base/net_util.h"
34 #include "net/url_request/url_request_test_util.h" 35 #include "net/url_request/url_request_test_util.h"
36 #include "net/url_request/url_request_job_factory.h"
35 #include "testing/gtest/include/gtest/gtest.h" 37 #include "testing/gtest/include/gtest/gtest.h"
36 38
37 namespace helpers = extension_web_request_api_helpers; 39 namespace helpers = extension_web_request_api_helpers;
38 namespace keys = extension_web_request_api_constants; 40 namespace keys = extension_web_request_api_constants;
39 41
40 using helpers::CalculateOnAuthRequiredDelta; 42 using helpers::CalculateOnAuthRequiredDelta;
41 using helpers::CalculateOnBeforeRequestDelta; 43 using helpers::CalculateOnBeforeRequestDelta;
42 using helpers::CalculateOnBeforeSendHeadersDelta; 44 using helpers::CalculateOnBeforeSendHeadersDelta;
43 using helpers::CalculateOnHeadersReceivedDelta; 45 using helpers::CalculateOnHeadersReceivedDelta;
44 using helpers::CharListToString; 46 using helpers::CharListToString;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_); 162 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_);
161 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 163 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
162 &profile_, extension1_id, extension1_id, kEventName, kEventName + "/1", 164 &profile_, extension1_id, extension1_id, kEventName, kEventName + "/1",
163 filter, ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 165 filter, ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING,
164 ipc_sender_factory.GetWeakPtr()); 166 ipc_sender_factory.GetWeakPtr());
165 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 167 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
166 &profile_, extension2_id, extension2_id, kEventName, kEventName + "/2", 168 &profile_, extension2_id, extension2_id, kEventName, kEventName + "/2",
167 filter, ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 169 filter, ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING,
168 ipc_sender_factory.GetWeakPtr()); 170 ipc_sender_factory.GetWeakPtr());
169 171
172 net::URLRequestJobFactory job_factory;
173 job_factory.SetProtocolHandler("about", new net::AboutProtocolHandler());
174 context_->set_job_factory(&job_factory);
175
170 GURL redirect_url("about:redirected"); 176 GURL redirect_url("about:redirected");
171 GURL not_chosen_redirect_url("about:not_chosen"); 177 GURL not_chosen_redirect_url("about:not_chosen");
172 178
173 net::URLRequest request(GURL("about:blank"), &delegate_, context_.get()); 179 net::URLRequest request(GURL("about:blank"), &delegate_, context_.get());
174 { 180 {
175 // onBeforeRequest will be dispatched twice initially. The second response - 181 // onBeforeRequest will be dispatched twice initially. The second response -
176 // the redirect - should win, since it has a later |install_time|. The 182 // the redirect - should win, since it has a later |install_time|. The
177 // redirect will dispatch another pair of onBeforeRequest. There, the first 183 // redirect will dispatch another pair of onBeforeRequest. There, the first
178 // response should win (later |install_time|). 184 // response should win (later |install_time|).
179 ExtensionWebRequestEventRouter::EventResponse* response = NULL; 185 ExtensionWebRequestEventRouter::EventResponse* response = NULL;
(...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 deltas, &auth3, &conflicting_extensions, &net_log); 1639 deltas, &auth3, &conflicting_extensions, &net_log);
1634 EXPECT_TRUE(credentials_set); 1640 EXPECT_TRUE(credentials_set);
1635 EXPECT_FALSE(auth3.Empty()); 1641 EXPECT_FALSE(auth3.Empty());
1636 EXPECT_EQ(username, auth1.username()); 1642 EXPECT_EQ(username, auth1.username());
1637 EXPECT_EQ(password, auth1.password()); 1643 EXPECT_EQ(password, auth1.password());
1638 EXPECT_EQ(1u, conflicting_extensions.size()); 1644 EXPECT_EQ(1u, conflicting_extensions.size());
1639 EXPECT_TRUE(ContainsKey(conflicting_extensions, "extid2")); 1645 EXPECT_TRUE(ContainsKey(conflicting_extensions, "extid2"));
1640 EXPECT_EQ(3u, capturing_net_log.GetSize()); 1646 EXPECT_EQ(3u, capturing_net_log.GetSize());
1641 } 1647 }
1642 1648
OLDNEW
« no previous file with comments | « chrome/browser/android/android_protocol_adapter.cc ('k') | chrome/browser/net/about_protocol_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698