Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/browser/importer/importer_list.cc

Issue 1465853002: Implement support for importing favorites from Edge on Windows 10. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing include files Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.
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;
47 edge->importer_name = l10n_util::GetStringUTF16(IDS_IMPORT_FROM_EDGE);
48 edge->importer_type = importer::TYPE_EDGE;
49 edge->services_supported = importer::FAVORITES;
50 edge->source_path = importer::GetEdgeDataFilePath();
51 profiles->push_back(edge);
52 }
53
54 void DetectBuiltinWindowsProfiles(
55 std::vector<importer::SourceProfile*>* profiles) {
56 // Make the assumption on Windows 10 that Edge exists and is probably default.
57 if (importer::EdgeImporterCanImport())
58 DetectEdgeProfiles(profiles);
59 DetectIEProfiles(profiles);
60 }
61
40 #endif // defined(OS_WIN) 62 #endif // defined(OS_WIN)
41 63
42 #if defined(OS_MACOSX) 64 #if defined(OS_MACOSX)
43 void DetectSafariProfiles(std::vector<importer::SourceProfile*>* profiles) { 65 void DetectSafariProfiles(std::vector<importer::SourceProfile*>* profiles) {
44 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 66 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
45 uint16 items = importer::NONE; 67 uint16 items = importer::NONE;
46 if (!SafariImporterCanImport(base::mac::GetUserLibraryPath(), &items)) 68 if (!SafariImporterCanImport(base::mac::GetUserLibraryPath(), &items))
47 return; 69 return;
48 70
49 importer::SourceProfile* safari = new importer::SourceProfile; 71 importer::SourceProfile* safari = new importer::SourceProfile;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 bool include_interactive_profiles) { 126 bool include_interactive_profiles) {
105 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 127 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
106 128
107 std::vector<importer::SourceProfile*> profiles; 129 std::vector<importer::SourceProfile*> profiles;
108 130
109 // The first run import will automatically take settings from the first 131 // The first run import will automatically take settings from the first
110 // profile detected, which should be the user's current default. 132 // profile detected, which should be the user's current default.
111 #if defined(OS_WIN) 133 #if defined(OS_WIN)
112 if (ShellIntegration::IsFirefoxDefaultBrowser()) { 134 if (ShellIntegration::IsFirefoxDefaultBrowser()) {
113 DetectFirefoxProfiles(locale, &profiles); 135 DetectFirefoxProfiles(locale, &profiles);
114 DetectIEProfiles(&profiles); 136 DetectBuiltinWindowsProfiles(&profiles);
115 } else { 137 } else {
116 DetectIEProfiles(&profiles); 138 DetectBuiltinWindowsProfiles(&profiles);
117 DetectFirefoxProfiles(locale, &profiles); 139 DetectFirefoxProfiles(locale, &profiles);
118 } 140 }
119 #elif defined(OS_MACOSX) 141 #elif defined(OS_MACOSX)
120 if (ShellIntegration::IsFirefoxDefaultBrowser()) { 142 if (ShellIntegration::IsFirefoxDefaultBrowser()) {
121 DetectFirefoxProfiles(locale, &profiles); 143 DetectFirefoxProfiles(locale, &profiles);
122 DetectSafariProfiles(&profiles); 144 DetectSafariProfiles(&profiles);
123 } else { 145 } else {
124 DetectSafariProfiles(&profiles); 146 DetectSafariProfiles(&profiles);
125 DetectFirefoxProfiles(locale, &profiles); 147 DetectFirefoxProfiles(locale, &profiles);
126 } 148 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 195 }
174 196
175 void ImporterList::SourceProfilesLoaded( 197 void ImporterList::SourceProfilesLoaded(
176 const base::Closure& profiles_loaded_callback, 198 const base::Closure& profiles_loaded_callback,
177 const std::vector<importer::SourceProfile*>& profiles) { 199 const std::vector<importer::SourceProfile*>& profiles) {
178 DCHECK_CURRENTLY_ON(BrowserThread::UI); 200 DCHECK_CURRENTLY_ON(BrowserThread::UI);
179 201
180 source_profiles_.assign(profiles.begin(), profiles.end()); 202 source_profiles_.assign(profiles.begin(), profiles.end());
181 profiles_loaded_callback.Run(); 203 profiles_loaded_callback.Run();
182 } 204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698