Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 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/extension_with_management_policy_apitest.h" | |
| 6 | |
| 7 ExtensionApiTestWithManagementPolicy::ExtensionApiTestWithManagementPolicy() | |
| 8 : ExtensionApiTest() {} | |
| 9 | |
| 10 ExtensionApiTestWithManagementPolicy::~ExtensionApiTestWithManagementPolicy() {} | |
| 11 | |
| 12 void ExtensionApiTestWithManagementPolicy::SetUpInProcessBrowserTestFixture() { | |
| 13 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | |
| 14 embedded_test_server()->RegisterRequestMonitor( | |
| 15 base::Bind(&ExtensionApiTestWithManagementPolicy::MonitorRequestHandler, | |
| 16 base::Unretained(this))); | |
| 17 EXPECT_CALL(policy_provider_, IsInitializationComplete(testing::_)) | |
| 18 .WillRepeatedly(testing::Return(true)); | |
| 19 policy_provider_.SetAutoRefresh(); | |
| 20 policy::BrowserPolicyConnector::SetPolicyProviderForTesting( | |
| 21 &policy_provider_); | |
| 22 } | |
| 23 | |
| 24 void ExtensionApiTestWithManagementPolicy::MonitorRequestHandler( | |
| 25 const net::test_server::HttpRequest& request) { | |
| 26 auto host = request.headers.find("Host"); | |
| 27 if (host != request.headers.end()) { | |
| 28 ManagementPolicyRequestLog log; | |
| 29 size_t delimiter_pos = host->second.find(":"); | |
| 30 log.host = host->second.substr(0, delimiter_pos); | |
| 31 request_log_.push_back(log); | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 bool ExtensionApiTestWithManagementPolicy::BrowsedTo(const char* test_host) { | |
| 36 for (auto it = request_log_.begin(); it != request_log_.end(); ++it) { | |
|
dcheng
2017/02/06 07:05:29
Prefer range-based for loops.
nrpeter
2017/02/06 22:53:15
Done.
| |
| 37 if (it->host == test_host) | |
| 38 return true; | |
| 39 } | |
| 40 return false; | |
| 41 } | |
| 42 | |
| 43 void ExtensionApiTestWithManagementPolicy::ClearRequestLog() { | |
| 44 request_log_.clear(); | |
| 45 } | |
| OLD | NEW |