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

Side by Side Diff: chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate_browsertest.cc

Issue 648653003: Standardize usage of virtual/override/final in chrome/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/strings/string_util.h" 6 #include "base/strings/string_util.h"
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/policy/cloud/policy_header_service_factory.h" 8 #include "chrome/browser/policy/cloud/policy_header_service_factory.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h" 10 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 } 51 }
52 52
53 class TestDispatcherHostDelegate : public ChromeResourceDispatcherHostDelegate { 53 class TestDispatcherHostDelegate : public ChromeResourceDispatcherHostDelegate {
54 public: 54 public:
55 explicit TestDispatcherHostDelegate( 55 explicit TestDispatcherHostDelegate(
56 prerender::PrerenderTracker* prerender_tracker) 56 prerender::PrerenderTracker* prerender_tracker)
57 : ChromeResourceDispatcherHostDelegate(prerender_tracker) { 57 : ChromeResourceDispatcherHostDelegate(prerender_tracker) {
58 } 58 }
59 59
60 virtual ~TestDispatcherHostDelegate() {} 60 ~TestDispatcherHostDelegate() override {}
61 61
62 virtual void RequestBeginning( 62 void RequestBeginning(
63 net::URLRequest* request, 63 net::URLRequest* request,
64 content::ResourceContext* resource_context, 64 content::ResourceContext* resource_context,
65 content::AppCacheService* appcache_service, 65 content::AppCacheService* appcache_service,
66 ResourceType resource_type, 66 ResourceType resource_type,
67 ScopedVector<content::ResourceThrottle>* throttles) override { 67 ScopedVector<content::ResourceThrottle>* throttles) override {
68 ChromeResourceDispatcherHostDelegate::RequestBeginning( 68 ChromeResourceDispatcherHostDelegate::RequestBeginning(
69 request, 69 request,
70 resource_context, 70 resource_context,
71 appcache_service, 71 appcache_service,
72 resource_type, 72 resource_type,
73 throttles); 73 throttles);
74 request_headers_.MergeFrom(request->extra_request_headers()); 74 request_headers_.MergeFrom(request->extra_request_headers());
75 } 75 }
76 76
77 virtual void OnRequestRedirected( 77 void OnRequestRedirected(const GURL& redirect_url,
78 const GURL& redirect_url, 78 net::URLRequest* request,
79 net::URLRequest* request, 79 content::ResourceContext* resource_context,
80 content::ResourceContext* resource_context, 80 content::ResourceResponse* response) override {
81 content::ResourceResponse* response) override {
82 ChromeResourceDispatcherHostDelegate::OnRequestRedirected( 81 ChromeResourceDispatcherHostDelegate::OnRequestRedirected(
83 redirect_url, 82 redirect_url,
84 request, 83 request,
85 resource_context, 84 resource_context,
86 response); 85 response);
87 request_headers_.MergeFrom(request->extra_request_headers()); 86 request_headers_.MergeFrom(request->extra_request_headers());
88 } 87 }
89 88
90 net::HttpRequestHeaders request_headers_; 89 net::HttpRequestHeaders request_headers_;
91 90
92 private: 91 private:
93 DISALLOW_COPY_AND_ASSIGN(TestDispatcherHostDelegate); 92 DISALLOW_COPY_AND_ASSIGN(TestDispatcherHostDelegate);
94 }; 93 };
95 94
96 } // namespace 95 } // namespace
97 96
98 class ChromeResourceDispatcherHostDelegateBrowserTest : 97 class ChromeResourceDispatcherHostDelegateBrowserTest :
99 public InProcessBrowserTest { 98 public InProcessBrowserTest {
100 public: 99 public:
101 ChromeResourceDispatcherHostDelegateBrowserTest() {} 100 ChromeResourceDispatcherHostDelegateBrowserTest() {}
102 101
103 virtual void SetUpOnMainThread() override { 102 void SetUpOnMainThread() override {
104 InProcessBrowserTest::SetUpOnMainThread(); 103 InProcessBrowserTest::SetUpOnMainThread();
105 // Hook navigations with our delegate. 104 // Hook navigations with our delegate.
106 dispatcher_host_delegate_.reset(new TestDispatcherHostDelegate( 105 dispatcher_host_delegate_.reset(new TestDispatcherHostDelegate(
107 g_browser_process->prerender_tracker())); 106 g_browser_process->prerender_tracker()));
108 content::ResourceDispatcherHost::Get()->SetDelegate( 107 content::ResourceDispatcherHost::Get()->SetDelegate(
109 dispatcher_host_delegate_.get()); 108 dispatcher_host_delegate_.get());
110 109
111 embedded_test_server()->RegisterRequestHandler( 110 embedded_test_server()->RegisterRequestHandler(
112 base::Bind(&HandleTestRequest)); 111 base::Bind(&HandleTestRequest));
113 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 112 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
114 // Tell chrome that this is our DM server. 113 // Tell chrome that this is our DM server.
115 dm_url_ = embedded_test_server()->GetURL("/DeviceManagement"); 114 dm_url_ = embedded_test_server()->GetURL("/DeviceManagement");
116 115
117 // At this point, the Profile is already initialized and it's too 116 // At this point, the Profile is already initialized and it's too
118 // late to set the DMServer URL via command line flags, so directly 117 // late to set the DMServer URL via command line flags, so directly
119 // inject it to the PolicyHeaderIOHelper. 118 // inject it to the PolicyHeaderIOHelper.
120 policy::PolicyHeaderService* policy_header_service = 119 policy::PolicyHeaderService* policy_header_service =
121 policy::PolicyHeaderServiceFactory::GetForBrowserContext( 120 policy::PolicyHeaderServiceFactory::GetForBrowserContext(
122 browser()->profile()); 121 browser()->profile());
123 std::vector<policy::PolicyHeaderIOHelper*> helpers = 122 std::vector<policy::PolicyHeaderIOHelper*> helpers =
124 policy_header_service->GetHelpersForTest(); 123 policy_header_service->GetHelpersForTest();
125 for (std::vector<policy::PolicyHeaderIOHelper*>::const_iterator it = 124 for (std::vector<policy::PolicyHeaderIOHelper*>::const_iterator it =
126 helpers.begin(); 125 helpers.begin();
127 it != helpers.end(); ++it) { 126 it != helpers.end(); ++it) {
128 (*it)->SetServerURLForTest(dm_url_.spec()); 127 (*it)->SetServerURLForTest(dm_url_.spec());
129 (*it)->UpdateHeader(kTestPolicyHeader); 128 (*it)->UpdateHeader(kTestPolicyHeader);
130 } 129 }
131 } 130 }
132 131
133 virtual void TearDownOnMainThread() override { 132 void TearDownOnMainThread() override {
134 content::ResourceDispatcherHost::Get()->SetDelegate(NULL); 133 content::ResourceDispatcherHost::Get()->SetDelegate(NULL);
135 dispatcher_host_delegate_.reset(); 134 dispatcher_host_delegate_.reset();
136 } 135 }
137 136
138 protected: 137 protected:
139 // The fake URL for DMServer we are using. 138 // The fake URL for DMServer we are using.
140 GURL dm_url_; 139 GURL dm_url_;
141 scoped_ptr<TestDispatcherHostDelegate> dispatcher_host_delegate_; 140 scoped_ptr<TestDispatcherHostDelegate> dispatcher_host_delegate_;
142 141
143 private: 142 private:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 redirect_url += kServerRedirectUrl; 174 redirect_url += kServerRedirectUrl;
176 redirect_url += "?"; 175 redirect_url += "?";
177 redirect_url += dm_url_.spec(); 176 redirect_url += dm_url_.spec();
178 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( 177 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL(
179 redirect_url)); 178 redirect_url));
180 std::string value; 179 std::string value;
181 ASSERT_TRUE(dispatcher_host_delegate_->request_headers_.GetHeader( 180 ASSERT_TRUE(dispatcher_host_delegate_->request_headers_.GetHeader(
182 policy::kChromePolicyHeader, &value)); 181 policy::kChromePolicyHeader, &value));
183 ASSERT_EQ(kTestPolicyHeader, value); 182 ASSERT_EQ(kTestPolicyHeader, value);
184 } 183 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698