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