OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/default_apps.h" | 5 #include "chrome/browser/extensions/default_apps.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/first_run/first_run.h" | 14 #include "chrome/browser/first_run/first_run.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/chrome_version_info.h" | |
18 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
20 #include "components/pref_registry/pref_registry_syncable.h" | 19 #include "components/pref_registry/pref_registry_syncable.h" |
20 #include "components/version_info/version_info.h" | |
21 #include "extensions/common/extension.h" | 21 #include "extensions/common/extension.h" |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // Returns true if the app was a default app in Chrome 22 | 25 // Returns true if the app was a default app in Chrome 22 |
26 bool IsOldDefaultApp(const std::string& extension_id) { | 26 bool IsOldDefaultApp(const std::string& extension_id) { |
27 return extension_id == extension_misc::kGmailAppId || | 27 return extension_id == extension_misc::kGmailAppId || |
28 extension_id == extension_misc::kGoogleSearchAppId || | 28 extension_id == extension_misc::kGoogleSearchAppId || |
29 extension_id == extension_misc::kYoutubeAppId; | 29 extension_id == extension_misc::kYoutubeAppId; |
30 } | 30 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 static_cast<InstallState>(profile_->GetPrefs()->GetInteger( | 69 static_cast<InstallState>(profile_->GetPrefs()->GetInteger( |
70 prefs::kDefaultAppsInstallState)); | 70 prefs::kDefaultAppsInstallState)); |
71 | 71 |
72 is_migration_ = (state == kProvideLegacyDefaultApps); | 72 is_migration_ = (state == kProvideLegacyDefaultApps); |
73 | 73 |
74 switch (state) { | 74 switch (state) { |
75 case kUnknown: { | 75 case kUnknown: { |
76 // Only new installations and profiles get default apps. In theory the | 76 // Only new installations and profiles get default apps. In theory the |
77 // new profile checks should catch new installations, but that is not | 77 // new profile checks should catch new installations, but that is not |
78 // always the case (http:/crbug.com/145351). | 78 // always the case (http:/crbug.com/145351). |
79 chrome::VersionInfo version_info; | 79 bool is_new_profile = profile_->WasCreatedByVersionOrLater( |
80 bool is_new_profile = | 80 version_info::GetVersionNumber().c_str()); |
brettw
2015/07/31 21:13:16
Can you remove c_str() here? This just causes an u
| |
81 profile_->WasCreatedByVersionOrLater(version_info.Version().c_str()); | |
82 bool is_first_run = first_run::IsChromeFirstRun(); | 81 bool is_first_run = first_run::IsChromeFirstRun(); |
83 if (!is_first_run && !is_new_profile) | 82 if (!is_first_run && !is_new_profile) |
84 install_apps = false; | 83 install_apps = false; |
85 break; | 84 break; |
86 } | 85 } |
87 | 86 |
88 // The old default apps were provided as external extensions and were | 87 // The old default apps were provided as external extensions and were |
89 // installed everytime Chrome was run. Thus, changing the list of default | 88 // installed everytime Chrome was run. Thus, changing the list of default |
90 // apps affected all users. Migrate old default apps to new mechanism where | 89 // apps affected all users. Migrate old default apps to new mechanism where |
91 // they are installed only once as INTERNAL. | 90 // they are installed only once as INTERNAL. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 for (std::set<std::string>::iterator it = new_default_apps.begin(); | 156 for (std::set<std::string>::iterator it = new_default_apps.begin(); |
158 it != new_default_apps.end(); ++it) { | 157 it != new_default_apps.end(); ++it) { |
159 prefs->Remove(*it, NULL); | 158 prefs->Remove(*it, NULL); |
160 } | 159 } |
161 } | 160 } |
162 | 161 |
163 ExternalProviderImpl::SetPrefs(prefs); | 162 ExternalProviderImpl::SetPrefs(prefs); |
164 } | 163 } |
165 | 164 |
166 } // namespace default_apps | 165 } // namespace default_apps |
OLD | NEW |