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/first_run/first_run.h" | |
9 #include "chrome/browser/importer/firefox_importer_utils.h" | 8 #include "chrome/browser/importer/firefox_importer_utils.h" |
10 #include "chrome/browser/importer/importer_bridge.h" | 9 #include "chrome/browser/importer/importer_bridge.h" |
11 #include "chrome/browser/importer/importer_data_types.h" | 10 #include "chrome/browser/importer/importer_data_types.h" |
12 #include "chrome/browser/importer/importer_list_observer.h" | 11 #include "chrome/browser/importer/importer_list_observer.h" |
13 #include "chrome/browser/shell_integration.h" | 12 #include "chrome/browser/shell_integration.h" |
14 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
15 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
16 | 15 |
17 #if defined(OS_MACOSX) | 16 #if defined(OS_MACOSX) |
18 #include <CoreFoundation/CoreFoundation.h> | 17 #include <CoreFoundation/CoreFoundation.h> |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 firefox->app_path = GetFirefoxInstallPathFromRegistry(); | 88 firefox->app_path = GetFirefoxInstallPathFromRegistry(); |
90 #endif | 89 #endif |
91 if (firefox->app_path.empty()) | 90 if (firefox->app_path.empty()) |
92 firefox->app_path = app_path; | 91 firefox->app_path = app_path; |
93 firefox->services_supported = importer::HISTORY | importer::FAVORITES | | 92 firefox->services_supported = importer::HISTORY | importer::FAVORITES | |
94 importer::PASSWORDS | importer::SEARCH_ENGINES; | 93 importer::PASSWORDS | importer::SEARCH_ENGINES; |
95 firefox->locale = locale; | 94 firefox->locale = locale; |
96 profiles->push_back(firefox); | 95 profiles->push_back(firefox); |
97 } | 96 } |
98 | 97 |
99 #if defined(OS_WIN) | |
100 void DetectGoogleToolbarProfiles( | |
101 std::vector<importer::SourceProfile*>* profiles, | |
102 scoped_refptr<net::URLRequestContextGetter> request_context_getter) { | |
103 if (first_run::IsChromeFirstRun()) | |
104 return; | |
105 | |
106 importer::SourceProfile* google_toolbar = new importer::SourceProfile; | |
107 google_toolbar->importer_name = | |
108 l10n_util::GetStringUTF16(IDS_IMPORT_FROM_GOOGLE_TOOLBAR); | |
109 google_toolbar->importer_type = importer::TYPE_GOOGLE_TOOLBAR5; | |
110 google_toolbar->source_path.clear(); | |
111 google_toolbar->app_path.clear(); | |
112 google_toolbar->services_supported = importer::FAVORITES; | |
113 google_toolbar->request_context_getter = request_context_getter; | |
114 profiles->push_back(google_toolbar); | |
115 } | |
116 #endif | |
117 | |
118 } // namespace | 98 } // namespace |
119 | 99 |
120 ImporterList::ImporterList( | 100 ImporterList::ImporterList() |
121 net::URLRequestContextGetter* request_context_getter) | |
122 : source_thread_id_(BrowserThread::UI), | 101 : source_thread_id_(BrowserThread::UI), |
123 observer_(NULL), | 102 observer_(NULL), |
124 is_observed_(false), | 103 is_observed_(false), |
125 source_profiles_loaded_(false) { | 104 source_profiles_loaded_(false) { |
126 request_context_getter_ = make_scoped_refptr(request_context_getter); | |
127 } | 105 } |
128 | 106 |
129 void ImporterList::DetectSourceProfiles( | 107 void ImporterList::DetectSourceProfiles( |
130 const std::string& locale, | 108 const std::string& locale, |
131 importer::ImporterListObserver* observer) { | 109 importer::ImporterListObserver* observer) { |
132 DCHECK(observer); | 110 DCHECK(observer); |
133 observer_ = observer; | 111 observer_ = observer; |
134 is_observed_ = true; | 112 is_observed_ = true; |
135 | 113 |
136 bool res = BrowserThread::GetCurrentThreadIdentifier(&source_thread_id_); | 114 bool res = BrowserThread::GetCurrentThreadIdentifier(&source_thread_id_); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // The first run import will automatically take settings from the first | 161 // The first run import will automatically take settings from the first |
184 // profile detected, which should be the user's current default. | 162 // profile detected, which should be the user's current default. |
185 #if defined(OS_WIN) | 163 #if defined(OS_WIN) |
186 if (ShellIntegration::IsFirefoxDefaultBrowser()) { | 164 if (ShellIntegration::IsFirefoxDefaultBrowser()) { |
187 DetectFirefoxProfiles(locale, &profiles); | 165 DetectFirefoxProfiles(locale, &profiles); |
188 DetectIEProfiles(&profiles); | 166 DetectIEProfiles(&profiles); |
189 } else { | 167 } else { |
190 DetectIEProfiles(&profiles); | 168 DetectIEProfiles(&profiles); |
191 DetectFirefoxProfiles(locale, &profiles); | 169 DetectFirefoxProfiles(locale, &profiles); |
192 } | 170 } |
193 // TODO(brg) : Current UI requires win_util. | |
194 DetectGoogleToolbarProfiles(&profiles, request_context_getter_); | |
195 #elif defined(OS_MACOSX) | 171 #elif defined(OS_MACOSX) |
196 if (ShellIntegration::IsFirefoxDefaultBrowser()) { | 172 if (ShellIntegration::IsFirefoxDefaultBrowser()) { |
197 DetectFirefoxProfiles(locale, &profiles); | 173 DetectFirefoxProfiles(locale, &profiles); |
198 DetectSafariProfiles(&profiles); | 174 DetectSafariProfiles(&profiles); |
199 } else { | 175 } else { |
200 DetectSafariProfiles(&profiles); | 176 DetectSafariProfiles(&profiles); |
201 DetectFirefoxProfiles(locale, &profiles); | 177 DetectFirefoxProfiles(locale, &profiles); |
202 } | 178 } |
203 #else | 179 #else |
204 DetectFirefoxProfiles(locale, &profiles); | 180 DetectFirefoxProfiles(locale, &profiles); |
(...skipping 25 matching lines...) Expand all Loading... |
230 source_profiles_.assign(profiles.begin(), profiles.end()); | 206 source_profiles_.assign(profiles.begin(), profiles.end()); |
231 source_profiles_loaded_ = true; | 207 source_profiles_loaded_ = true; |
232 source_thread_id_ = BrowserThread::UI; | 208 source_thread_id_ = BrowserThread::UI; |
233 | 209 |
234 observer_->OnSourceProfilesLoaded(); | 210 observer_->OnSourceProfilesLoaded(); |
235 observer_ = NULL; | 211 observer_ = NULL; |
236 | 212 |
237 // TODO(jhawkins): Remove once DetectSourceProfilesHack is removed. | 213 // TODO(jhawkins): Remove once DetectSourceProfilesHack is removed. |
238 is_observed_ = false; | 214 is_observed_ = false; |
239 } | 215 } |
OLD | NEW |