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

Side by Side Diff: chrome/browser/extensions/extension_with_management_policy_apitest.cc

Issue 2499493004: Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: Style fixes, prevent heap leak. Created 3 years, 10 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
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
Devlin 2017/02/14 23:17:09 no (c)
nrpeter 2017/03/22 23:47:38 Done.
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 #include "components/policy/core/browser/browser_policy_connector.h"
7 #include "net/test/embedded_test_server/http_request.h"
8
9 ExtensionApiTestWithManagementPolicy::ExtensionApiTestWithManagementPolicy()
10 : ExtensionApiTest() {}
11
12 ExtensionApiTestWithManagementPolicy::~ExtensionApiTestWithManagementPolicy() {}
13
14 void ExtensionApiTestWithManagementPolicy::SetUpInProcessBrowserTestFixture() {
15 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
16 embedded_test_server()->RegisterRequestMonitor(
17 base::Bind(&ExtensionApiTestWithManagementPolicy::MonitorRequestHandler,
18 base::Unretained(this)));
19 EXPECT_CALL(policy_provider_, IsInitializationComplete(testing::_))
20 .WillRepeatedly(testing::Return(true));
21 policy_provider_.SetAutoRefresh();
22 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(
23 &policy_provider_);
24 }
25
26 void ExtensionApiTestWithManagementPolicy::MonitorRequestHandler(
27 const net::test_server::HttpRequest& request) {
28 auto host = request.headers.find("Host");
29 if (host != request.headers.end()) {
30 ManagementPolicyRequestLog log;
31 size_t delimiter_pos = host->second.find(":");
32 log.host = host->second.substr(0, delimiter_pos);
33 request_log_.push_back(log);
34 }
35 }
36
37 bool ExtensionApiTestWithManagementPolicy::BrowsedTo(const char* test_host) {
38 for (auto it : request_log_) {
39 if (it.host == test_host)
40 return true;
41 }
42 return false;
43 }
44
45 void ExtensionApiTestWithManagementPolicy::ClearRequestLog() {
46 request_log_.clear();
47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698