| 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/profile_writer.h" | 5 #include "chrome/browser/importer/profile_writer.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 if (existing_folder_names.find(name) == existing_folder_names.end()) | 48 if (existing_folder_names.find(name) == existing_folder_names.end()) |
| 49 return name; | 49 return name; |
| 50 } | 50 } |
| 51 | 51 |
| 52 NOTREACHED(); | 52 NOTREACHED(); |
| 53 return folder_name; | 53 return folder_name; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // Shows the bookmarks toolbar. | 56 // Shows the bookmarks toolbar. |
| 57 void ShowBookmarkBar(Profile* profile) { | 57 void ShowBookmarkBar(Profile* profile) { |
| 58 PrefService* prefs = profile->GetPrefs(); | 58 profile->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); |
| 59 // Check whether the bookmark bar is shown in current pref. | |
| 60 if (!prefs->GetBoolean(prefs::kShowBookmarkBar)) { | |
| 61 prefs->SetBoolean(prefs::kShowBookmarkBar, true); | |
| 62 prefs->ScheduleSavePersistentPrefs(); | |
| 63 } | |
| 64 } | 59 } |
| 65 | 60 |
| 66 } // namespace | 61 } // namespace |
| 67 | 62 |
| 68 ProfileWriter::BookmarkEntry::BookmarkEntry() | 63 ProfileWriter::BookmarkEntry::BookmarkEntry() |
| 69 : in_toolbar(false), | 64 : in_toolbar(false), |
| 70 is_folder(false) {} | 65 is_folder(false) {} |
| 71 | 66 |
| 72 ProfileWriter::BookmarkEntry::~BookmarkEntry() {} | 67 ProfileWriter::BookmarkEntry::~BookmarkEntry() {} |
| 73 | 68 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 103 } |
| 109 | 104 |
| 110 void ProfileWriter::AddHomepage(const GURL& home_page) { | 105 void ProfileWriter::AddHomepage(const GURL& home_page) { |
| 111 DCHECK(profile_); | 106 DCHECK(profile_); |
| 112 | 107 |
| 113 PrefService* prefs = profile_->GetPrefs(); | 108 PrefService* prefs = profile_->GetPrefs(); |
| 114 // NOTE: We set the kHomePage value, but keep the NewTab page as the homepage. | 109 // NOTE: We set the kHomePage value, but keep the NewTab page as the homepage. |
| 115 const PrefService::Preference* pref = prefs->FindPreference(prefs::kHomePage); | 110 const PrefService::Preference* pref = prefs->FindPreference(prefs::kHomePage); |
| 116 if (pref && !pref->IsManaged()) { | 111 if (pref && !pref->IsManaged()) { |
| 117 prefs->SetString(prefs::kHomePage, home_page.spec()); | 112 prefs->SetString(prefs::kHomePage, home_page.spec()); |
| 118 prefs->ScheduleSavePersistentPrefs(); | |
| 119 } | 113 } |
| 120 } | 114 } |
| 121 | 115 |
| 122 void ProfileWriter::AddBookmarks(const std::vector<BookmarkEntry>& bookmarks, | 116 void ProfileWriter::AddBookmarks(const std::vector<BookmarkEntry>& bookmarks, |
| 123 const string16& top_level_folder_name) { | 117 const string16& top_level_folder_name) { |
| 124 if (bookmarks.empty()) | 118 if (bookmarks.empty()) |
| 125 return; | 119 return; |
| 126 | 120 |
| 127 BookmarkModel* model = profile_->GetBookmarkModel(); | 121 BookmarkModel* model = profile_->GetBookmarkModel(); |
| 128 DCHECK(model->IsLoaded()); | 122 DCHECK(model->IsLoaded()); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 if (default_keyword && TemplateURL::SupportsReplacement(t_url)) | 341 if (default_keyword && TemplateURL::SupportsReplacement(t_url)) |
| 348 model->SetDefaultSearchProvider(t_url); | 342 model->SetDefaultSearchProvider(t_url); |
| 349 } else { | 343 } else { |
| 350 // Don't add invalid TemplateURLs to the model. | 344 // Don't add invalid TemplateURLs to the model. |
| 351 delete t_url; | 345 delete t_url; |
| 352 } | 346 } |
| 353 } | 347 } |
| 354 } | 348 } |
| 355 | 349 |
| 356 ProfileWriter::~ProfileWriter() {} | 350 ProfileWriter::~ProfileWriter() {} |
| OLD | NEW |