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 "base/command_line.h" |
8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" | 10 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/search/hotword_service_factory.h" | 12 #include "chrome/browser/search/hotword_service_factory.h" |
13 #include "chrome/browser/signin/signin_manager_factory.h" | 13 #include "chrome/browser/signin/signin_manager_factory.h" |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/extensions/extension_constants.h" | 15 #include "chrome/common/extensions/extension_constants.h" |
16 #include "components/signin/core/browser/signin_manager.h" | 16 #include "components/signin/core/browser/signin_manager.h" |
17 | 17 |
18 namespace { | |
19 | |
20 bool IsUserSignedin(Profile* profile) { | |
21 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); | |
22 return signin && signin->IsAuthenticated(); | |
23 } | |
24 | |
25 } // namespace | |
26 | |
27 namespace extensions { | 18 namespace extensions { |
28 | 19 |
29 ExternalComponentLoader::ExternalComponentLoader(Profile* profile) | 20 ExternalComponentLoader::ExternalComponentLoader(Profile* profile) |
30 : profile_(profile) { | 21 : profile_(profile) { |
31 } | 22 } |
32 | 23 |
33 ExternalComponentLoader::~ExternalComponentLoader() {} | 24 ExternalComponentLoader::~ExternalComponentLoader() {} |
34 | 25 |
35 // static | 26 // static |
36 bool ExternalComponentLoader::IsModifiable(const Extension* extension) { | 27 bool ExternalComponentLoader::IsModifiable(const Extension* extension) { |
(...skipping 22 matching lines...) Expand all Loading... |
59 std::string hotwordId = extension_misc::kHotwordExtensionId; | 50 std::string hotwordId = extension_misc::kHotwordExtensionId; |
60 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 51 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
61 // TODO(amistry): Load the hotword shared module when enabling built-in | 52 // TODO(amistry): Load the hotword shared module when enabling built-in |
62 // hotword detection. | 53 // hotword detection. |
63 if (!command_line->HasSwitch(switches::kEnableExperimentalHotwording)) { | 54 if (!command_line->HasSwitch(switches::kEnableExperimentalHotwording)) { |
64 prefs_->SetString(hotwordId + ".external_update_url", | 55 prefs_->SetString(hotwordId + ".external_update_url", |
65 extension_urls::GetWebstoreUpdateUrl().spec()); | 56 extension_urls::GetWebstoreUpdateUrl().spec()); |
66 } | 57 } |
67 } | 58 } |
68 | 59 |
69 UpdateBookmarksExperimentState( | 60 InitBookmarksExperimentState(profile_); |
70 profile_->GetPrefs(), | 61 |
71 g_browser_process->local_state(), | |
72 IsUserSignedin(profile_), | |
73 BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN); | |
74 std::string ext_id; | 62 std::string ext_id; |
75 if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) && | 63 if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) && |
76 !ext_id.empty()) { | 64 !ext_id.empty()) { |
77 prefs_->SetString(ext_id + ".external_update_url", | 65 prefs_->SetString(ext_id + ".external_update_url", |
78 extension_urls::GetWebstoreUpdateUrl().spec()); | 66 extension_urls::GetWebstoreUpdateUrl().spec()); |
79 } | 67 } |
80 | 68 |
81 LoadFinished(); | 69 LoadFinished(); |
82 } | 70 } |
83 | 71 |
84 } // namespace extensions | 72 } // namespace extensions |
OLD | NEW |