Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/extensions/external_component_loader.h" | 5 #include "chrome/browser/extensions/external_component_loader.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 7 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" | 8 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" |
| 8 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
| 10 #include "chrome/common/extensions/extension_constants.h" | 11 #include "chrome/common/extensions/extension_constants.h" |
| 11 #include "components/signin/core/browser/signin_manager.h" | 12 #include "components/signin/core/browser/signin_manager.h" |
| 12 | 13 |
| 13 // TODO(thestig): Remove after extensions are disabled on mobile. | 14 // TODO(thestig): Remove after extensions are disabled on mobile. |
| 14 #if defined(ENABLE_EXTENSIONS) | 15 #if defined(ENABLE_EXTENSIONS) |
| 15 #include "chrome/browser/search/hotword_service_factory.h" | 16 #include "chrome/browser/search/hotword_service_factory.h" |
| 16 #endif | 17 #endif |
| 17 | 18 |
| 19 #if defined(OS_CHROMEOS) | |
| 20 #include "chromeos/chromeos_switches.h" | |
| 21 #endif | |
| 22 | |
| 18 namespace { | 23 namespace { |
| 19 | 24 |
| 20 bool IsUserSignedin(Profile* profile) { | 25 bool IsUserSignedin(Profile* profile) { |
| 21 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); | 26 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); |
| 22 return signin && !signin->GetAuthenticatedUsername().empty(); | 27 return signin && !signin->GetAuthenticatedUsername().empty(); |
| 23 } | 28 } |
| 24 | 29 |
| 25 } // namespace | 30 } // namespace |
| 26 | 31 |
| 27 namespace extensions { | 32 namespace extensions { |
| 28 | 33 |
| 29 ExternalComponentLoader::ExternalComponentLoader(Profile* profile) | 34 ExternalComponentLoader::ExternalComponentLoader(Profile* profile) |
| 30 : profile_(profile) { | 35 : profile_(profile) { |
| 31 } | 36 } |
| 32 | 37 |
| 33 ExternalComponentLoader::~ExternalComponentLoader() {} | 38 ExternalComponentLoader::~ExternalComponentLoader() {} |
| 34 | 39 |
| 35 void ExternalComponentLoader::StartLoading() { | 40 void ExternalComponentLoader::StartLoading() { |
| 36 prefs_.reset(new base::DictionaryValue()); | 41 prefs_.reset(new base::DictionaryValue()); |
| 37 std::string appId = extension_misc::kInAppPaymentsSupportAppId; | 42 std::string appId = extension_misc::kInAppPaymentsSupportAppId; |
| 38 prefs_->SetString(appId + ".external_update_url", | 43 prefs_->SetString(appId + ".external_update_url", |
| 39 extension_urls::GetWebstoreUpdateUrl().spec()); | 44 extension_urls::GetWebstoreUpdateUrl().spec()); |
| 40 | 45 |
| 41 #if defined(ENABLE_EXTENSIONS) | 46 #if defined(ENABLE_EXTENSIONS) |
| 42 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) { | 47 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) { |
| 43 std::string hotwordId = extension_misc::kHotwordExtensionId; | 48 std::string hotwordId = extension_misc::kHotwordExtensionId; |
| 44 prefs_->SetString(hotwordId + ".external_update_url", | 49 #if defined(OS_CHROMEOS) |
| 45 extension_urls::GetWebstoreUpdateUrl().spec()); | 50 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
|
James Hawkins
2014/08/05 08:59:45
Same as component_loader, create a ChromeOS-specif
| |
| 51 if (command_line->HasSwitch( | |
| 52 chromeos::switches::kEnableOkGoogleVoiceSearch)) { | |
| 53 // TODO(amistry): Load the hotword shared module. | |
| 54 hotwordId = ""; | |
| 55 } | |
| 56 #endif | |
| 57 if (!hotwordId.empty()) { | |
| 58 prefs_->SetString(hotwordId + ".external_update_url", | |
| 59 extension_urls::GetWebstoreUpdateUrl().spec()); | |
| 60 } | |
| 46 } | 61 } |
| 47 #endif | 62 #endif |
| 48 | 63 |
| 49 UpdateBookmarksExperimentState( | 64 UpdateBookmarksExperimentState( |
| 50 profile_->GetPrefs(), | 65 profile_->GetPrefs(), |
| 51 g_browser_process->local_state(), | 66 g_browser_process->local_state(), |
| 52 IsUserSignedin(profile_), | 67 IsUserSignedin(profile_), |
| 53 BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN); | 68 BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN); |
| 54 std::string ext_id; | 69 std::string ext_id; |
| 55 if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) && | 70 if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) && |
| 56 !ext_id.empty()) { | 71 !ext_id.empty()) { |
| 57 prefs_->SetString(ext_id + ".external_update_url", | 72 prefs_->SetString(ext_id + ".external_update_url", |
| 58 extension_urls::GetWebstoreUpdateUrl().spec()); | 73 extension_urls::GetWebstoreUpdateUrl().spec()); |
| 59 } | 74 } |
| 60 | 75 |
| 61 LoadFinished(); | 76 LoadFinished(); |
| 62 } | 77 } |
| 63 | 78 |
| 64 } // namespace extensions | 79 } // namespace extensions |
| OLD | NEW |