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_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/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 items &= ~importer::FAVORITES; | 126 items &= ~importer::FAVORITES; |
127 if (!user_prefs->GetBoolean(prefs::kImportSavedPasswords)) | 127 if (!user_prefs->GetBoolean(prefs::kImportSavedPasswords)) |
128 items &= ~importer::PASSWORDS; | 128 items &= ~importer::PASSWORDS; |
129 | 129 |
130 // Preserves the observer and creates a task, since we do async import so that | 130 // Preserves the observer and creates a task, since we do async import so that |
131 // it doesn't block the UI. When the import is complete, observer will be | 131 // it doesn't block the UI. When the import is complete, observer will be |
132 // notified. | 132 // notified. |
133 writer_ = writer; | 133 writer_ = writer; |
134 importer_ = importer::CreateImporterByType(source_profile.importer_type); | 134 importer_ = importer::CreateImporterByType(source_profile.importer_type); |
135 // If we fail to create the Importer, exit, as we cannot do anything. | 135 // If we fail to create the Importer, exit, as we cannot do anything. |
136 if (!importer_) { | 136 if (!importer_.get()) { |
137 NotifyImportEnded(); | 137 NotifyImportEnded(); |
138 return; | 138 return; |
139 } | 139 } |
140 | 140 |
141 scoped_refptr<InProcessImporterBridge> bridge( | 141 scoped_refptr<InProcessImporterBridge> bridge( |
142 new InProcessImporterBridge(writer_.get(), | 142 new InProcessImporterBridge(writer_.get(), |
143 weak_ptr_factory_.GetWeakPtr())); | 143 weak_ptr_factory_.GetWeakPtr())); |
144 task_ = base::Bind( | 144 task_ = base::Bind( |
145 &Importer::StartImport, importer_, source_profile, items, bridge); | 145 &Importer::StartImport, importer_, source_profile, items, bridge); |
146 | 146 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 const content::NotificationDetails& details) { | 273 const content::NotificationDetails& details) { |
274 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); | 274 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); |
275 registrar_.RemoveAll(); | 275 registrar_.RemoveAll(); |
276 InvokeTaskIfDone(); | 276 InvokeTaskIfDone(); |
277 } | 277 } |
278 | 278 |
279 void ImporterHost::OnBrowserRemoved(Browser* browser) { | 279 void ImporterHost::OnBrowserRemoved(Browser* browser) { |
280 if (browser_ == browser) | 280 if (browser_ == browser) |
281 browser_ = NULL; | 281 browser_ = NULL; |
282 } | 282 } |
OLD | NEW |