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

Unified Diff: chrome/browser/extensions/extension_with_management_policy_apitest.cc

Issue 2499493004: Communicate ExtensionSettings policy to renderers (Closed)
Patch Set: Fix effective TLD wildcard bug, move to Leaky LazyInstance in PermissionsData, removed unnecessary … Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_with_management_policy_apitest.cc
diff --git a/chrome/browser/extensions/extension_with_management_policy_apitest.cc b/chrome/browser/extensions/extension_with_management_policy_apitest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..75aed90a29035d4452bd3b386781f0449f3f494d
--- /dev/null
+++ b/chrome/browser/extensions/extension_with_management_policy_apitest.cc
@@ -0,0 +1,47 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/extension_with_management_policy_apitest.h"
+#include "components/policy/core/browser/browser_policy_connector.h"
+#include "net/test/embedded_test_server/http_request.h"
+
+ExtensionApiTestWithManagementPolicy::ExtensionApiTestWithManagementPolicy()
+ : ExtensionApiTest() {}
+
+ExtensionApiTestWithManagementPolicy::~ExtensionApiTestWithManagementPolicy() {}
+
+void ExtensionApiTestWithManagementPolicy::SetUpInProcessBrowserTestFixture() {
Devlin 2017/03/29 21:36:49 Why does this need to be done in SetUpInProcessBro
nrpeter 2017/03/30 00:06:05 This was moved from permissions_apitest.cc since w
Devlin 2017/03/30 00:33:53 Let's try moving it to SetUpOnMainThread(), which
nrpeter 2017/03/31 21:43:35 I tried moving this, but the policy connector isn'
Devlin 2017/04/03 15:58:21 Did you put the call before or after the call to E
nrpeter 2017/04/03 22:35:48 I put the call after.
Devlin 2017/04/04 16:29:10 Try putting it before.
nrpeter 2017/04/05 23:13:26 Tried putting it before, and I got the same error
Devlin 2017/04/07 00:40:26 Let's table it for now. I'd like to get to the bo
+ ExtensionApiTest::SetUpInProcessBrowserTestFixture();
+ embedded_test_server()->RegisterRequestMonitor(
+ base::Bind(&ExtensionApiTestWithManagementPolicy::MonitorRequestHandler,
+ base::Unretained(this)));
+ EXPECT_CALL(policy_provider_, IsInitializationComplete(testing::_))
+ .WillRepeatedly(testing::Return(true));
+ policy_provider_.SetAutoRefresh();
+ policy::BrowserPolicyConnector::SetPolicyProviderForTesting(
+ &policy_provider_);
+}
+
+void ExtensionApiTestWithManagementPolicy::MonitorRequestHandler(
+ const net::test_server::HttpRequest& request) {
+ auto host = request.headers.find("Host");
+ if (host != request.headers.end()) {
+ ManagementPolicyRequestLog log;
+ size_t delimiter_pos = host->second.find(":");
+ log.host = host->second.substr(0, delimiter_pos);
+ request_log_.push_back(log);
+ }
+}
+
+bool ExtensionApiTestWithManagementPolicy::BrowsedTo(const char* test_host) {
+ for (auto it : request_log_) {
Devlin 2017/03/29 21:36:49 this results in a copy for each entry; prefer cons
nrpeter 2017/03/30 00:06:05 Done.
+ if (it.host == test_host)
+ return true;
+ }
+ return false;
Devlin 2017/03/29 21:36:49 This would be simpler as: return std::find_if(requ
nrpeter 2017/03/30 00:06:05 Done.
+}
+
+void ExtensionApiTestWithManagementPolicy::ClearRequestLog() {
+ request_log_.clear();
+}

Powered by Google App Engine
This is Rietveld 408576698