[go: nahoru, domu]

Make SavedFileService non-null in incognito

The chrome.fileSystem API functions that use this service could be
called from an incognito context (e.g. in guest sessions), so the
incognito profile should be properly handled - this cl redirects
the to the original browser context's service (given that the
SavedFilesService depends on ExtensionPrefs service, which is
redirected to original browser context in incognito).

BUG=788986

Change-Id: I04ff197acffd531d388a009aecb2993177c1ca7b
Reviewed-on: https://chromium-review.googlesource.com/854979
Commit-Queue: Toni Barzic <tbarzic@chromium.org>
Reviewed-by: Ben Wells <benwells@chromium.org>
Cr-Commit-Position: refs/heads/master@{#528874}
diff --git a/apps/saved_files_service_factory.cc b/apps/saved_files_service_factory.cc
index 00e9e00a..5a545fa9 100644
--- a/apps/saved_files_service_factory.cc
+++ b/apps/saved_files_service_factory.cc
@@ -7,6 +7,7 @@
 #include "apps/saved_files_service.h"
 #include "components/keyed_service/content/browser_context_dependency_manager.h"
 #include "content/public/browser/browser_context.h"
+#include "extensions/browser/extensions_browser_client.h"
 
 namespace apps {
 
@@ -41,4 +42,14 @@
   return new SavedFilesService(context);
 }
 
+content::BrowserContext* SavedFilesServiceFactory::GetBrowserContextToUse(
+    content::BrowserContext* context) const {
+  // Make sure that the service is created even for incognito profile. The goal
+  // is to make this service available in guest sessions, where it could be used
+  // when apps white-listed in guest sessions attempt to use chrome.fileSystem
+  // API.
+  return extensions::ExtensionsBrowserClient::Get()->GetOriginalContext(
+      context);
+}
+
 }  // namespace apps