| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/profile_writer.h" | 5 #include "chrome/browser/importer/profile_writer.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/thread.h" | 8 #include "base/thread.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 11 #include "chrome/browser/importer/importer.h" | 11 #include "chrome/browser/importer/importer.h" |
| 12 #include "chrome/browser/password_manager/password_store.h" | 12 #include "chrome/browser/password_manager/password_store.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/profile.h" | 14 #include "chrome/browser/profile.h" |
| 15 #include "chrome/browser/search_engines/template_url.h" | 15 #include "chrome/browser/search_engines/template_url.h" |
| 16 #include "chrome/browser/search_engines/template_url_model.h" | 16 #include "chrome/browser/search_engines/template_url_model.h" |
| 17 #include "chrome/common/notification_service.h" | 17 #include "chrome/common/notification_service.h" |
| 18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 19 | 19 |
| 20 using webkit_glue::PasswordForm; | 20 using webkit_glue::PasswordForm; |
| 21 | 21 |
| 22 ProfileWriter::BookmarkEntry::BookmarkEntry() : in_toolbar(false) {} |
| 23 |
| 24 ProfileWriter::BookmarkEntry::~BookmarkEntry() {} |
| 25 |
| 26 ProfileWriter::ProfileWriter(Profile* profile) : profile_(profile) {} |
| 27 |
| 22 bool ProfileWriter::BookmarkModelIsLoaded() const { | 28 bool ProfileWriter::BookmarkModelIsLoaded() const { |
| 23 return profile_->GetBookmarkModel()->IsLoaded(); | 29 return profile_->GetBookmarkModel()->IsLoaded(); |
| 24 } | 30 } |
| 25 | 31 |
| 26 bool ProfileWriter::TemplateURLModelIsLoaded() const { | 32 bool ProfileWriter::TemplateURLModelIsLoaded() const { |
| 27 return profile_->GetTemplateURLModel()->loaded(); | 33 return profile_->GetTemplateURLModel()->loaded(); |
| 28 } | 34 } |
| 29 | 35 |
| 30 void ProfileWriter::AddPasswordForm(const PasswordForm& form) { | 36 void ProfileWriter::AddPasswordForm(const PasswordForm& form) { |
| 31 profile_->GetPasswordStore(Profile::EXPLICIT_ACCESS)->AddLogin(form); | 37 profile_->GetPasswordStore(Profile::EXPLICIT_ACCESS)->AddLogin(form); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // Set the pref and notify the notification service. | 276 // Set the pref and notify the notification service. |
| 271 prefs->SetBoolean(prefs::kShowBookmarkBar, true); | 277 prefs->SetBoolean(prefs::kShowBookmarkBar, true); |
| 272 prefs->ScheduleSavePersistentPrefs(); | 278 prefs->ScheduleSavePersistentPrefs(); |
| 273 Source<Profile> source(profile_); | 279 Source<Profile> source(profile_); |
| 274 NotificationService::current()->Notify( | 280 NotificationService::current()->Notify( |
| 275 NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, source, | 281 NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, source, |
| 276 NotificationService::NoDetails()); | 282 NotificationService::NoDetails()); |
| 277 } | 283 } |
| 278 } | 284 } |
| 279 | 285 |
| 286 ProfileWriter::~ProfileWriter() {} |
| 287 |
| 280 std::wstring ProfileWriter::GenerateUniqueFolderName( | 288 std::wstring ProfileWriter::GenerateUniqueFolderName( |
| 281 BookmarkModel* model, | 289 BookmarkModel* model, |
| 282 const std::wstring& folder_name) { | 290 const std::wstring& folder_name) { |
| 283 // Build a set containing the folder names of the other folder. | 291 // Build a set containing the folder names of the other folder. |
| 284 std::set<std::wstring> other_folder_names; | 292 std::set<std::wstring> other_folder_names; |
| 285 const BookmarkNode* other = model->other_node(); | 293 const BookmarkNode* other = model->other_node(); |
| 286 | 294 |
| 287 for (int i = 0, child_count = other->GetChildCount(); i < child_count; ++i) { | 295 for (int i = 0, child_count = other->GetChildCount(); i < child_count; ++i) { |
| 288 const BookmarkNode* node = other->GetChild(i); | 296 const BookmarkNode* node = other->GetChild(i); |
| 289 if (node->is_folder()) | 297 if (node->is_folder()) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 ((!import_to_bookmark_bar || !entry.in_toolbar) && | 351 ((!import_to_bookmark_bar || !entry.in_toolbar) && |
| 344 parent != model->other_node()))) { | 352 parent != model->other_node()))) { |
| 345 found_match = false; | 353 found_match = false; |
| 346 } | 354 } |
| 347 | 355 |
| 348 if (found_match) | 356 if (found_match) |
| 349 return true; // Found a match with the same url path and title. | 357 return true; // Found a match with the same url path and title. |
| 350 } | 358 } |
| 351 return false; | 359 return false; |
| 352 } | 360 } |
| OLD | NEW |