| OLD | NEW | 
 | (Empty) | 
|    1 // Copyright 2013 The Chromium Authors. All rights reserved. |  | 
|    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 "apps/shell/app_shell_extensions_browser_client.h" |  | 
|    6  |  | 
|    7 #include "apps/shell/app_shell_app_sorting.h" |  | 
|    8 #include "base/prefs/pref_service.h" |  | 
|    9 #include "base/prefs/pref_service_factory.h" |  | 
|   10 #include "base/prefs/testing_pref_store.h" |  | 
|   11 #include "components/user_prefs/pref_registry_syncable.h" |  | 
|   12 #include "components/user_prefs/user_prefs.h" |  | 
|   13 #include "extensions/browser/app_sorting.h" |  | 
|   14  |  | 
|   15 using content::BrowserContext; |  | 
|   16  |  | 
|   17 namespace { |  | 
|   18  |  | 
|   19 // See chrome::RegisterProfilePrefs() in chrome/browser/prefs/browser_prefs.cc |  | 
|   20 void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry) { |  | 
|   21   // TODO(jamescook): ExtensionPrefs::RegisterProfilePrefs(registry) |  | 
|   22 } |  | 
|   23  |  | 
|   24 }  // namespace |  | 
|   25  |  | 
|   26 namespace apps { |  | 
|   27  |  | 
|   28 AppShellExtensionsBrowserClient::AppShellExtensionsBrowserClient( |  | 
|   29     BrowserContext* context) |  | 
|   30     : browser_context_(context) { |  | 
|   31   // Set up the preferences service. |  | 
|   32   base::PrefServiceFactory factory; |  | 
|   33   factory.set_user_prefs(new TestingPrefStore); |  | 
|   34   factory.set_extension_prefs(new TestingPrefStore); |  | 
|   35   // app_shell should not require syncable preferences, but for now we need to |  | 
|   36   // recycle some of the RegisterProfilePrefs() code in Chrome. |  | 
|   37   // TODO(jamescook): Convert this to user_prefs::PrefRegistrySimple. |  | 
|   38   user_prefs::PrefRegistrySyncable* pref_registry = |  | 
|   39       new user_prefs::PrefRegistrySyncable; |  | 
|   40   // Prefs should be registered before the PrefService is created. |  | 
|   41   RegisterPrefs(pref_registry); |  | 
|   42   prefs_ = factory.Create(pref_registry).Pass(); |  | 
|   43   user_prefs::UserPrefs::Set(browser_context_, prefs_.get()); |  | 
|   44 } |  | 
|   45  |  | 
|   46 AppShellExtensionsBrowserClient::~AppShellExtensionsBrowserClient() {} |  | 
|   47  |  | 
|   48 bool AppShellExtensionsBrowserClient::IsShuttingDown() { |  | 
|   49   return false; |  | 
|   50 } |  | 
|   51  |  | 
|   52 bool AppShellExtensionsBrowserClient::AreExtensionsDisabled( |  | 
|   53     const CommandLine& command_line, |  | 
|   54     BrowserContext* context) { |  | 
|   55   return false; |  | 
|   56 } |  | 
|   57  |  | 
|   58 bool AppShellExtensionsBrowserClient::IsValidContext(BrowserContext* context) { |  | 
|   59   return context == browser_context_; |  | 
|   60 } |  | 
|   61  |  | 
|   62 bool AppShellExtensionsBrowserClient::IsSameContext(BrowserContext* first, |  | 
|   63                                                     BrowserContext* second) { |  | 
|   64   return first == second; |  | 
|   65 } |  | 
|   66  |  | 
|   67 bool AppShellExtensionsBrowserClient::HasOffTheRecordContext( |  | 
|   68     BrowserContext* context) { |  | 
|   69   return false; |  | 
|   70 } |  | 
|   71  |  | 
|   72 BrowserContext* AppShellExtensionsBrowserClient::GetOffTheRecordContext( |  | 
|   73     BrowserContext* context) { |  | 
|   74   // app_shell only supports a single context. |  | 
|   75   return NULL; |  | 
|   76 } |  | 
|   77  |  | 
|   78 BrowserContext* AppShellExtensionsBrowserClient::GetOriginalContext( |  | 
|   79     BrowserContext* context) { |  | 
|   80   return context; |  | 
|   81 } |  | 
|   82  |  | 
|   83 PrefService* AppShellExtensionsBrowserClient::GetPrefServiceForContext( |  | 
|   84     BrowserContext* context) { |  | 
|   85   return prefs_.get(); |  | 
|   86 } |  | 
|   87  |  | 
|   88 bool AppShellExtensionsBrowserClient::DeferLoadingBackgroundHosts( |  | 
|   89     BrowserContext* context) const { |  | 
|   90   return false; |  | 
|   91 } |  | 
|   92  |  | 
|   93 bool AppShellExtensionsBrowserClient::DidVersionUpdate( |  | 
|   94     BrowserContext* context) { |  | 
|   95   // TODO(jamescook): We might want to tell extensions when app_shell updates. |  | 
|   96   return false; |  | 
|   97 } |  | 
|   98  |  | 
|   99 scoped_ptr<extensions::AppSorting> |  | 
|  100 AppShellExtensionsBrowserClient::CreateAppSorting() { |  | 
|  101   return scoped_ptr<extensions::AppSorting>(new AppShellAppSorting).Pass(); |  | 
|  102 } |  | 
|  103  |  | 
|  104 bool AppShellExtensionsBrowserClient::IsRunningInForcedAppMode() { |  | 
|  105   return false; |  | 
|  106 } |  | 
|  107  |  | 
|  108 }  // namespace apps |  | 
| OLD | NEW |