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

Unified Diff: ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager.cc

Issue 2622913002: Simplify registration of a test ChromeBrowserStateManager. (Closed)
Patch Set: Fix typo in naming variable. Created 3 years, 11 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
« no previous file with comments | « ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager.cc
diff --git a/ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager.cc b/ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5cd0c8749db4f50c22c47a2040ece653f78d88d4
--- /dev/null
+++ b/ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager.cc
@@ -0,0 +1,25 @@
+// 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 "ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager.h"
+
+#include "ios/chrome/browser/application_context.h"
+#include "ios/chrome/browser/browser_state/chrome_browser_state_manager.h"
+#include "ios/chrome/test/testing_application_context.h"
+
+IOSChromeScopedTestingChromeBrowserStateManager::
+ IOSChromeScopedTestingChromeBrowserStateManager(
+ std::unique_ptr<ios::ChromeBrowserStateManager> browser_state_manager)
+ : browser_state_manager_(std::move(browser_state_manager)),
+ saved_browser_state_manager_(
+ GetApplicationContext()->GetChromeBrowserStateManager()) {
+ TestingApplicationContext::GetGlobal()->SetChromeBrowserStateManager(
+ browser_state_manager_.get());
+}
+
+IOSChromeScopedTestingChromeBrowserStateManager::
+ ~IOSChromeScopedTestingChromeBrowserStateManager() {
+ TestingApplicationContext::GetGlobal()->SetChromeBrowserStateManager(
+ saved_browser_state_manager_);
+}
« no previous file with comments | « ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698