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/profile_resetter/profile_resetter.h" | 5 #include "chrome/browser/profile_resetter/profile_resetter.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | |
| 10 | 11 |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/synchronization/cancellation_flag.h" | 13 #include "base/synchronization/cancellation_flag.h" |
| 13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 14 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 16 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 17 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 18 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/google/google_url_tracker_factory.h" | 20 #include "chrome/browser/google/google_url_tracker_factory.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 30 #include "components/content_settings/core/browser/host_content_settings_map.h" | 31 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 31 #include "components/content_settings/core/browser/website_settings_info.h" | 32 #include "components/content_settings/core/browser/website_settings_info.h" |
| 32 #include "components/content_settings/core/browser/website_settings_registry.h" | 33 #include "components/content_settings/core/browser/website_settings_registry.h" |
| 33 #include "components/google/core/browser/google_url_tracker.h" | 34 #include "components/google/core/browser/google_url_tracker.h" |
| 34 #include "components/prefs/pref_service.h" | 35 #include "components/prefs/pref_service.h" |
| 35 #include "components/prefs/scoped_user_pref_update.h" | 36 #include "components/prefs/scoped_user_pref_update.h" |
| 36 #include "components/search_engines/search_engines_pref_names.h" | 37 #include "components/search_engines/search_engines_pref_names.h" |
| 37 #include "components/search_engines/template_url_prepopulate_data.h" | 38 #include "components/search_engines/template_url_prepopulate_data.h" |
| 38 #include "components/search_engines/template_url_service.h" | 39 #include "components/search_engines/template_url_service.h" |
| 39 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
| 41 #include "extensions/browser/extension_registry.h" | |
| 40 #include "extensions/browser/extension_system.h" | 42 #include "extensions/browser/extension_system.h" |
| 41 #include "extensions/browser/management_policy.h" | 43 #include "extensions/browser/management_policy.h" |
| 44 #include "extensions/common/manifest.h" | |
| 42 | 45 |
| 43 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| 44 #include "base/base_paths.h" | 47 #include "base/base_paths.h" |
| 45 #include "base/path_service.h" | 48 #include "base/path_service.h" |
| 46 #include "chrome/installer/util/shell_util.h" | 49 #include "chrome/installer/util/shell_util.h" |
| 47 | 50 |
| 48 namespace { | 51 namespace { |
| 49 | 52 |
| 50 void ResetShortcutsOnFileThread() { | 53 void ResetShortcutsOnFileThread() { |
| 51 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 54 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 DCHECK(CalledOnValidThread()); | 267 DCHECK(CalledOnValidThread()); |
| 265 | 268 |
| 266 std::vector<std::string> brandcode_extensions; | 269 std::vector<std::string> brandcode_extensions; |
| 267 master_settings_->GetExtensions(&brandcode_extensions); | 270 master_settings_->GetExtensions(&brandcode_extensions); |
| 268 | 271 |
| 269 ExtensionService* extension_service = | 272 ExtensionService* extension_service = |
| 270 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 273 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| 271 DCHECK(extension_service); | 274 DCHECK(extension_service); |
| 272 extension_service->DisableUserExtensions(brandcode_extensions); | 275 extension_service->DisableUserExtensions(brandcode_extensions); |
| 273 | 276 |
| 277 // Reenable all disabled external component extensions. | |
| 278 // BrandcodedDefaultSettings does not contain information about component | |
| 279 // extensions, so fetch them from the existing registry. This may be not very | |
| 280 // robust, as the profile resetter may be invoked when the registry is in some | |
| 281 // iffy state. However, we can't enable an extension which is not in the | |
| 282 // registry anyway. | |
| 283 extensions::ExtensionRegistry* extension_registry = | |
| 284 extensions::ExtensionRegistry::Get(profile_); | |
| 285 DCHECK(extension_registry); | |
| 286 std::vector<std::string> extension_ids_to_reenable; | |
|
lazyboy
2017/01/24 03:30:01
nit: new codes shoudl use ExtensionId instead of s
mtomasz
2017/01/26 08:47:06
Done.
| |
| 287 for (const auto& extension : extension_registry->disabled_extensions()) { | |
| 288 if (extension->location() == extensions::Manifest::EXTERNAL_COMPONENT) { | |
|
lazyboy
2017/01/24 03:30:01
nit: no {}
mtomasz
2017/01/26 08:47:06
Done.
| |
| 289 extension_ids_to_reenable.push_back(extension->id()); | |
| 290 } | |
| 291 } | |
| 292 for (const auto& extension_id : extension_ids_to_reenable) { | |
| 293 extension_service->EnableExtension(extension_id); | |
| 294 } | |
| 295 | |
| 274 MarkAsDone(EXTENSIONS); | 296 MarkAsDone(EXTENSIONS); |
| 275 } | 297 } |
| 276 | 298 |
| 277 void ProfileResetter::ResetStartupPages() { | 299 void ProfileResetter::ResetStartupPages() { |
| 278 DCHECK(CalledOnValidThread()); | 300 DCHECK(CalledOnValidThread()); |
| 279 PrefService* prefs = profile_->GetPrefs(); | 301 PrefService* prefs = profile_->GetPrefs(); |
| 280 DCHECK(prefs); | 302 DCHECK(prefs); |
| 281 std::unique_ptr<base::ListValue> url_list( | 303 std::unique_ptr<base::ListValue> url_list( |
| 282 master_settings_->GetUrlsToRestoreOnStartup()); | 304 master_settings_->GetUrlsToRestoreOnStartup()); |
| 283 if (url_list) | 305 if (url_list) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 chrome_exe, | 381 chrome_exe, |
| 360 false, | 382 false, |
| 361 cancel, | 383 cancel, |
| 362 &shortcuts); | 384 &shortcuts); |
| 363 } | 385 } |
| 364 return shortcuts; | 386 return shortcuts; |
| 365 #else | 387 #else |
| 366 return std::vector<ShortcutCommand>(); | 388 return std::vector<ShortcutCommand>(); |
| 367 #endif | 389 #endif |
| 368 } | 390 } |
| OLD | NEW |