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

Unified Diff: chrome/browser/chromeos/login/ui/shared_web_view_factory.cc

Issue 2512473004: cros: Enable WebUILoginView reuse. (Closed)
Patch Set: Initial upload Created 4 years 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/chromeos/login/ui/shared_web_view_factory.cc
diff --git a/chrome/browser/chromeos/login/ui/shared_web_view_factory.cc b/chrome/browser/chromeos/login/ui/shared_web_view_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3a5f3c404c48ef8610cffb1f24a3c7c3b7889d42
--- /dev/null
+++ b/chrome/browser/chromeos/login/ui/shared_web_view_factory.cc
@@ -0,0 +1,47 @@
+// Copyright 2016 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/chromeos/login/ui/shared_web_view_factory.h"
+
+#include "chrome/browser/chromeos/login/ui/shared_web_view.h"
+#include "chrome/browser/profiles/incognito_helpers.h"
+#include "chrome/browser/profiles/profile.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+
+namespace chromeos {
+
+// static
+SharedWebView* SharedWebViewFactory::GetForProfile(Profile* profile) {
+ auto result = static_cast<SharedWebView*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true));
+ return result;
+}
+
+// static
+SharedWebViewFactory* SharedWebViewFactory::GetInstance() {
+ return base::Singleton<SharedWebViewFactory>::get();
+}
+
+SharedWebViewFactory::SharedWebViewFactory()
+ : BrowserContextKeyedServiceFactory(
+ "SharedWebViewFactory",
+ BrowserContextDependencyManager::GetInstance()) {}
+
+SharedWebViewFactory::~SharedWebViewFactory() {}
+
+content::BrowserContext* SharedWebViewFactory::GetBrowserContextToUse(
+ content::BrowserContext* context) const {
+ // This matches the logic in ExtensionSyncServiceFactory, which uses the
+ // orginal browser context.
+ return chrome::GetBrowserContextRedirectedInIncognito(context);
xiyuan 2016/12/09 22:37:30 |context| should be the incognito sign-in profile
jdufault 2016/12/12 18:23:09 Done.
+}
+
+KeyedService* SharedWebViewFactory::BuildServiceInstanceFor(
+ content::BrowserContext* context) const {
+ // By default, no service instances are built for the signin profile since it
+ // is considered incognito.
xiyuan 2016/12/09 22:37:30 After we override GetBrowserContextToUse above, th
jdufault 2016/12/12 18:23:09 Done.
+ return new SharedWebView(Profile::FromBrowserContext(context));
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698