Chromium Code Reviews| 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/importer/importer_list.h" | 5 #include "chrome/browser/importer/importer_list.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/shell_integration.h" | 8 #include "chrome/browser/shell_integration.h" |
| 9 #include "chrome/common/importer/firefox_importer_utils.h" | 9 #include "chrome/common/importer/firefox_importer_utils.h" |
| 10 #include "chrome/common/importer/importer_bridge.h" | 10 #include "chrome/common/importer/importer_bridge.h" |
| 11 #include "chrome/common/importer/importer_data_types.h" | 11 #include "chrome/common/importer/importer_data_types.h" |
| 12 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 | 15 |
| 16 #if defined(OS_MACOSX) | 16 #if defined(OS_MACOSX) |
| 17 #include <CoreFoundation/CoreFoundation.h> | 17 #include <CoreFoundation/CoreFoundation.h> |
| 18 | 18 |
| 19 #include "base/mac/foundation_util.h" | 19 #include "base/mac/foundation_util.h" |
| 20 #include "chrome/common/importer/safari_importer_utils.h" | 20 #include "chrome/common/importer/safari_importer_utils.h" |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 #if defined(OS_WIN) | |
| 24 #include "chrome/common/importer/edge_importer_utils_win.h" | |
| 25 #endif | |
| 26 | |
| 23 using content::BrowserThread; | 27 using content::BrowserThread; |
| 24 | 28 |
| 25 namespace { | 29 namespace { |
| 26 | 30 |
| 27 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 28 void DetectIEProfiles(std::vector<importer::SourceProfile*>* profiles) { | 32 void DetectIEProfiles(std::vector<importer::SourceProfile*>* profiles) { |
| 29 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 33 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 30 // IE always exists and doesn't have multiple profiles. | 34 // IE always exists and doesn't have multiple profiles. |
|
Ilya Sherman
2015/11/26 02:04:43
Is it still true that IE always exists on Windows
forshaw
2015/11/30 12:57:57
Yes it's still there, things like the favorites ar
| |
| 31 importer::SourceProfile* ie = new importer::SourceProfile; | 35 importer::SourceProfile* ie = new importer::SourceProfile; |
| 32 ie->importer_name = l10n_util::GetStringUTF16(IDS_IMPORT_FROM_IE); | 36 ie->importer_name = l10n_util::GetStringUTF16(IDS_IMPORT_FROM_IE); |
| 33 ie->importer_type = importer::TYPE_IE; | 37 ie->importer_type = importer::TYPE_IE; |
| 34 ie->source_path.clear(); | 38 ie->source_path.clear(); |
| 35 ie->app_path.clear(); | 39 ie->app_path.clear(); |
| 36 ie->services_supported = importer::HISTORY | importer::FAVORITES | | 40 ie->services_supported = importer::HISTORY | importer::FAVORITES | |
| 37 importer::COOKIES | importer::PASSWORDS | importer::SEARCH_ENGINES; | 41 importer::COOKIES | importer::PASSWORDS | importer::SEARCH_ENGINES; |
| 38 profiles->push_back(ie); | 42 profiles->push_back(ie); |
| 39 } | 43 } |
| 44 | |
| 45 void DetectEdgeProfiles(std::vector<importer::SourceProfile*>* profiles) { | |
| 46 importer::SourceProfile* edge = new importer::SourceProfile; | |
|
Ilya Sherman
2015/11/26 02:04:43
Hrm. Not as part of this CL, but if you have time
forshaw
2015/11/30 12:57:57
Will look at it, does seem pretty nasty.
| |
| 47 edge->importer_name = l10n_util::GetStringUTF16(IDS_IMPORT_FROM_EDGE); | |
| 48 edge->importer_type = importer::TYPE_EDGE; | |
| 49 edge->source_path.clear(); | |
| 50 edge->app_path.clear(); | |
|
Ilya Sherman
2015/11/26 02:04:43
These two lines don't do anything -- right? I do
forshaw
2015/11/30 12:57:57
Nope probably not, just copied again from above.
| |
| 51 edge->services_supported = importer::FAVORITES; | |
| 52 profiles->push_back(edge); | |
| 53 } | |
| 54 | |
| 55 void DetectBuiltinWindowsProfiles( | |
| 56 std::vector<importer::SourceProfile*>* profiles) { | |
| 57 // Make the assumption on Windows 10 that Edge exists and is probably default. | |
| 58 if (importer::EdgeImporterCanImport()) | |
| 59 DetectEdgeProfiles(profiles); | |
| 60 DetectIEProfiles(profiles); | |
| 61 } | |
| 62 | |
| 40 #endif // defined(OS_WIN) | 63 #endif // defined(OS_WIN) |
| 41 | 64 |
| 42 #if defined(OS_MACOSX) | 65 #if defined(OS_MACOSX) |
| 43 void DetectSafariProfiles(std::vector<importer::SourceProfile*>* profiles) { | 66 void DetectSafariProfiles(std::vector<importer::SourceProfile*>* profiles) { |
| 44 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 67 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 45 uint16 items = importer::NONE; | 68 uint16 items = importer::NONE; |
| 46 if (!SafariImporterCanImport(base::mac::GetUserLibraryPath(), &items)) | 69 if (!SafariImporterCanImport(base::mac::GetUserLibraryPath(), &items)) |
| 47 return; | 70 return; |
| 48 | 71 |
| 49 importer::SourceProfile* safari = new importer::SourceProfile; | 72 importer::SourceProfile* safari = new importer::SourceProfile; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 bool include_interactive_profiles) { | 127 bool include_interactive_profiles) { |
| 105 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 128 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 106 | 129 |
| 107 std::vector<importer::SourceProfile*> profiles; | 130 std::vector<importer::SourceProfile*> profiles; |
| 108 | 131 |
| 109 // The first run import will automatically take settings from the first | 132 // The first run import will automatically take settings from the first |
| 110 // profile detected, which should be the user's current default. | 133 // profile detected, which should be the user's current default. |
| 111 #if defined(OS_WIN) | 134 #if defined(OS_WIN) |
| 112 if (ShellIntegration::IsFirefoxDefaultBrowser()) { | 135 if (ShellIntegration::IsFirefoxDefaultBrowser()) { |
| 113 DetectFirefoxProfiles(locale, &profiles); | 136 DetectFirefoxProfiles(locale, &profiles); |
| 114 DetectIEProfiles(&profiles); | 137 DetectBuiltinWindowsProfiles(&profiles); |
| 115 } else { | 138 } else { |
| 116 DetectIEProfiles(&profiles); | 139 DetectBuiltinWindowsProfiles(&profiles); |
| 117 DetectFirefoxProfiles(locale, &profiles); | 140 DetectFirefoxProfiles(locale, &profiles); |
| 118 } | 141 } |
| 119 #elif defined(OS_MACOSX) | 142 #elif defined(OS_MACOSX) |
| 120 if (ShellIntegration::IsFirefoxDefaultBrowser()) { | 143 if (ShellIntegration::IsFirefoxDefaultBrowser()) { |
| 121 DetectFirefoxProfiles(locale, &profiles); | 144 DetectFirefoxProfiles(locale, &profiles); |
| 122 DetectSafariProfiles(&profiles); | 145 DetectSafariProfiles(&profiles); |
| 123 } else { | 146 } else { |
| 124 DetectSafariProfiles(&profiles); | 147 DetectSafariProfiles(&profiles); |
| 125 DetectFirefoxProfiles(locale, &profiles); | 148 DetectFirefoxProfiles(locale, &profiles); |
| 126 } | 149 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 } | 196 } |
| 174 | 197 |
| 175 void ImporterList::SourceProfilesLoaded( | 198 void ImporterList::SourceProfilesLoaded( |
| 176 const base::Closure& profiles_loaded_callback, | 199 const base::Closure& profiles_loaded_callback, |
| 177 const std::vector<importer::SourceProfile*>& profiles) { | 200 const std::vector<importer::SourceProfile*>& profiles) { |
| 178 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 201 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 179 | 202 |
| 180 source_profiles_.assign(profiles.begin(), profiles.end()); | 203 source_profiles_.assign(profiles.begin(), profiles.end()); |
| 181 profiles_loaded_callback.Run(); | 204 profiles_loaded_callback.Run(); |
| 182 } | 205 } |
| OLD | NEW |