OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_host.h" | 5 #include "chrome/browser/importer/importer_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/importer/firefox_profile_lock.h" | 11 #include "chrome/browser/importer/firefox_profile_lock.h" |
12 #include "chrome/browser/importer/importer.h" | 12 #include "chrome/browser/importer/importer.h" |
13 #include "chrome/browser/importer/importer_lock_dialog.h" | 13 #include "chrome/browser/importer/importer_lock_dialog.h" |
14 #include "chrome/browser/importer/importer_progress_observer.h" | 14 #include "chrome/browser/importer/importer_progress_observer.h" |
15 #include "chrome/browser/importer/importer_type.h" | 15 #include "chrome/browser/importer/importer_type.h" |
16 #include "chrome/browser/importer/in_process_importer_bridge.h" | 16 #include "chrome/browser/importer/in_process_importer_bridge.h" |
17 #include "chrome/browser/importer/toolbar_importer_utils.h" | 17 #include "chrome/browser/importer/toolbar_importer_utils.h" |
| 18 #include "chrome/browser/prefs/pref_service.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/search_engines/template_url.h" | 20 #include "chrome/browser/search_engines/template_url.h" |
20 #include "chrome/browser/search_engines/template_url_service.h" | 21 #include "chrome/browser/search_engines/template_url_service.h" |
21 #include "chrome/browser/search_engines/template_url_service_factory.h" | 22 #include "chrome/browser/search_engines/template_url_service_factory.h" |
22 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
23 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
| 25 #include "chrome/common/pref_names.h" |
24 #include "content/browser/browser_thread.h" | 26 #include "content/browser/browser_thread.h" |
25 #include "content/common/notification_source.h" | 27 #include "content/common/notification_source.h" |
26 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
27 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
28 | 30 |
29 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
30 // TODO(port): Port this file. | 32 // TODO(port): Port this file. |
31 #include "ui/base/message_box_win.h" | 33 #include "ui/base/message_box_win.h" |
32 #endif | 34 #endif |
33 | 35 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 const importer::SourceProfile& source_profile, | 104 const importer::SourceProfile& source_profile, |
103 Profile* target_profile, | 105 Profile* target_profile, |
104 uint16 items, | 106 uint16 items, |
105 ProfileWriter* writer, | 107 ProfileWriter* writer, |
106 bool first_run) { | 108 bool first_run) { |
107 // We really only support importing from one host at a time. | 109 // We really only support importing from one host at a time. |
108 DCHECK(!profile_); | 110 DCHECK(!profile_); |
109 DCHECK(target_profile); | 111 DCHECK(target_profile); |
110 | 112 |
111 profile_ = target_profile; | 113 profile_ = target_profile; |
| 114 PrefService* user_prefs = profile_->GetPrefs(); |
| 115 |
| 116 // Make sure only items that were not disabled by policy are imported. |
| 117 if (!user_prefs->GetBoolean(prefs::kImportHistory)) |
| 118 items &= ~importer::HISTORY; |
| 119 if (!user_prefs->GetBoolean(prefs::kImportSearchEngine)) |
| 120 items &= ~importer::SEARCH_ENGINES; |
| 121 if (!user_prefs->GetBoolean(prefs::kImportBookmarks)) |
| 122 items &= ~importer::FAVORITES; |
| 123 if (!user_prefs->GetBoolean(prefs::kImportSavedPasswords)) |
| 124 items &= ~importer::PASSWORDS; |
| 125 |
112 // Preserves the observer and creates a task, since we do async import so that | 126 // Preserves the observer and creates a task, since we do async import so that |
113 // it doesn't block the UI. When the import is complete, observer will be | 127 // it doesn't block the UI. When the import is complete, observer will be |
114 // notified. | 128 // notified. |
115 writer_ = writer; | 129 writer_ = writer; |
116 importer_ = importer::CreateImporterByType(source_profile.importer_type); | 130 importer_ = importer::CreateImporterByType(source_profile.importer_type); |
117 // If we fail to create the Importer, exit, as we cannot do anything. | 131 // If we fail to create the Importer, exit, as we cannot do anything. |
118 if (!importer_) { | 132 if (!importer_) { |
119 NotifyImportEnded(); | 133 NotifyImportEnded(); |
120 return; | 134 return; |
121 } | 135 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 void ImporterHost::BookmarkModelChanged() { | 262 void ImporterHost::BookmarkModelChanged() { |
249 } | 263 } |
250 | 264 |
251 void ImporterHost::Observe(int type, | 265 void ImporterHost::Observe(int type, |
252 const NotificationSource& source, | 266 const NotificationSource& source, |
253 const NotificationDetails& details) { | 267 const NotificationDetails& details) { |
254 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); | 268 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); |
255 registrar_.RemoveAll(); | 269 registrar_.RemoveAll(); |
256 InvokeTaskIfDone(); | 270 InvokeTaskIfDone(); |
257 } | 271 } |
OLD | NEW |