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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #if !defined(OS_ANDROID) |
10 #include "chrome/browser/first_run/first_run.h" | 11 #include "chrome/browser/first_run/first_run.h" |
| 12 #endif |
11 #include "chrome/browser/extensions/default_apps_trial.h" | 13 #include "chrome/browser/extensions/default_apps_trial.h" |
12 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/chrome_version_info.h" | 17 #include "chrome/common/chrome_version_info.h" |
16 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
17 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
18 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
19 | 21 |
20 namespace { | 22 namespace { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 profile_->GetPrefs()->GetString(prefs::kDefaultApps) == "install"; | 70 profile_->GetPrefs()->GetString(prefs::kDefaultApps) == "install"; |
69 | 71 |
70 InstallState state = | 72 InstallState state = |
71 static_cast<InstallState>(profile_->GetPrefs()->GetInteger( | 73 static_cast<InstallState>(profile_->GetPrefs()->GetInteger( |
72 prefs::kDefaultAppsInstallState)); | 74 prefs::kDefaultAppsInstallState)); |
73 | 75 |
74 is_migration_ = (state == kProvideLegacyDefaultApps); | 76 is_migration_ = (state == kProvideLegacyDefaultApps); |
75 | 77 |
76 switch (state) { | 78 switch (state) { |
77 case kUnknown: { | 79 case kUnknown: { |
78 // This is the first time the default apps feature runs on this profile. | 80 // Only new installations and profiles get default apps. In theory the |
79 // Determine if we want to install them or not. | 81 // new profile checks should catch new installations, but that is not |
| 82 // always the case (http:/crbug.com/145351). |
80 chrome::VersionInfo version_info; | 83 chrome::VersionInfo version_info; |
81 if (!profile_->WasCreatedByVersionOrLater(version_info.Version().c_str())) | 84 bool is_new_profile = |
| 85 profile_->WasCreatedByVersionOrLater(version_info.Version().c_str()); |
| 86 // Android excludes most of the first run code, so it can't determine |
| 87 // if this is a first run. That's OK though, because Android doesn't |
| 88 // use default apps in general. |
| 89 #if defined(OS_ANDROID) |
| 90 bool is_first_run = false; |
| 91 #else |
| 92 bool is_first_run = first_run::IsChromeFirstRun(); |
| 93 #endif |
| 94 if (!is_first_run && !is_new_profile) |
82 install_apps = false; | 95 install_apps = false; |
83 break; | 96 break; |
84 } | 97 } |
85 | 98 |
86 // The old default apps were provided as external extensions and were | 99 // The old default apps were provided as external extensions and were |
87 // installed everytime Chrome was run. Thus, changing the list of default | 100 // installed everytime Chrome was run. Thus, changing the list of default |
88 // apps affected all users. Migrate old default apps to new mechanism where | 101 // apps affected all users. Migrate old default apps to new mechanism where |
89 // they are installed only once as INTERNAL. | 102 // they are installed only once as INTERNAL. |
90 // TODO(grv) : remove after Q1-2013. | 103 // TODO(grv) : remove after Q1-2013. |
91 case kProvideLegacyDefaultApps: | 104 case kProvideLegacyDefaultApps: |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 for (std::set<std::string>::iterator it = new_default_apps.begin(); | 181 for (std::set<std::string>::iterator it = new_default_apps.begin(); |
169 it != new_default_apps.end(); ++it) { | 182 it != new_default_apps.end(); ++it) { |
170 prefs->Remove(*it, NULL); | 183 prefs->Remove(*it, NULL); |
171 } | 184 } |
172 } | 185 } |
173 | 186 |
174 ExternalProviderImpl::SetPrefs(prefs); | 187 ExternalProviderImpl::SetPrefs(prefs); |
175 } | 188 } |
176 | 189 |
177 } // namespace default_apps | 190 } // namespace default_apps |
OLD | NEW |