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/toolbar_importer.h" | 5 #include "chrome/browser/importer/toolbar_importer.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 | 69 |
70 void Toolbar5Importer::StartImport( | 70 void Toolbar5Importer::StartImport( |
71 const importer::SourceProfile& source_profile, | 71 const importer::SourceProfile& source_profile, |
72 uint16 items, | 72 uint16 items, |
73 ImporterBridge* bridge) { | 73 ImporterBridge* bridge) { |
74 DCHECK(bridge); | 74 DCHECK(bridge); |
75 | 75 |
76 bridge_ = bridge; | 76 bridge_ = bridge; |
77 items_to_import_ = items; | 77 items_to_import_ = items; |
78 DCHECK(source_profile.request_context_getter); | 78 DCHECK(source_profile.request_context_getter.get()); |
79 request_context_getter_ = source_profile.request_context_getter; | 79 request_context_getter_ = source_profile.request_context_getter; |
80 state_ = INITIALIZED; | 80 state_ = INITIALIZED; |
81 | 81 |
82 bridge_->NotifyStarted(); | 82 bridge_->NotifyStarted(); |
83 ContinueImport(); | 83 ContinueImport(); |
84 } | 84 } |
85 | 85 |
86 // The public cancel method serves two functions, as a callback from the UI | 86 // The public cancel method serves two functions, as a callback from the UI |
87 // as well as an internal callback in case of cancel. An internal callback | 87 // as well as an internal callback in case of cancel. An internal callback |
88 // is required since the URLFetcher must be destroyed from the thread it was | 88 // is required since the URLFetcher must be destroyed from the thread it was |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 if (NULL != token_fetcher_) { | 166 if (NULL != token_fetcher_) { |
167 delete token_fetcher_; | 167 delete token_fetcher_; |
168 token_fetcher_ = NULL; | 168 token_fetcher_ = NULL; |
169 } | 169 } |
170 | 170 |
171 if (NULL != data_fetcher_) { | 171 if (NULL != data_fetcher_) { |
172 delete data_fetcher_; | 172 delete data_fetcher_; |
173 data_fetcher_ = NULL; | 173 data_fetcher_ = NULL; |
174 } | 174 } |
175 | 175 |
176 if (bridge_) | 176 if (bridge_.get()) |
177 bridge_->NotifyEnded(); | 177 bridge_->NotifyEnded(); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 void Toolbar5Importer::BeginImportBookmarks() { | 181 void Toolbar5Importer::BeginImportBookmarks() { |
182 bridge_->NotifyItemStarted(importer::FAVORITES); | 182 bridge_->NotifyItemStarted(importer::FAVORITES); |
183 GetAuthenticationFromServer(); | 183 GetAuthenticationFromServer(); |
184 } | 184 } |
185 | 185 |
186 void Toolbar5Importer::EndImportBookmarks() { | 186 void Toolbar5Importer::EndImportBookmarks() { |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 } | 564 } |
565 | 565 |
566 void Toolbar5Importer::AddBookmarksToChrome( | 566 void Toolbar5Importer::AddBookmarksToChrome( |
567 const std::vector<ImportedBookmarkEntry>& bookmarks) { | 567 const std::vector<ImportedBookmarkEntry>& bookmarks) { |
568 if (!bookmarks.empty() && !cancelled()) { | 568 if (!bookmarks.empty() && !cancelled()) { |
569 const string16& first_folder_name = | 569 const string16& first_folder_name = |
570 bridge_->GetLocalizedString(IDS_BOOKMARK_GROUP_FROM_GOOGLE_TOOLBAR); | 570 bridge_->GetLocalizedString(IDS_BOOKMARK_GROUP_FROM_GOOGLE_TOOLBAR); |
571 bridge_->AddBookmarks(bookmarks, first_folder_name); | 571 bridge_->AddBookmarks(bookmarks, first_folder_name); |
572 } | 572 } |
573 } | 573 } |
OLD | NEW |