| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 if (existing_folder_names.find(name) == existing_folder_names.end()) | 49 if (existing_folder_names.find(name) == existing_folder_names.end()) |
| 50 return name; | 50 return name; |
| 51 } | 51 } |
| 52 | 52 |
| 53 NOTREACHED(); | 53 NOTREACHED(); |
| 54 return folder_name; | 54 return folder_name; |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Shows the bookmarks toolbar. | 57 // Shows the bookmarks toolbar. |
| 58 void ShowBookmarkBar(Profile* profile) { | 58 void ShowBookmarkBar(Profile* profile) { |
| 59 PrefService* prefs = profile->GetPrefs(); | 59 profile->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); |
| 60 // Check whether the bookmark bar is shown in current pref. | |
| 61 if (!prefs->GetBoolean(prefs::kShowBookmarkBar)) { | |
| 62 prefs->SetBoolean(prefs::kShowBookmarkBar, true); | |
| 63 prefs->ScheduleSavePersistentPrefs(); | |
| 64 } | |
| 65 } | 60 } |
| 66 | 61 |
| 67 } // namespace | 62 } // namespace |
| 68 | 63 |
| 69 ProfileWriter::BookmarkEntry::BookmarkEntry() | 64 ProfileWriter::BookmarkEntry::BookmarkEntry() |
| 70 : in_toolbar(false), | 65 : in_toolbar(false), |
| 71 is_folder(false) {} | 66 is_folder(false) {} |
| 72 | 67 |
| 73 ProfileWriter::BookmarkEntry::~BookmarkEntry() {} | 68 ProfileWriter::BookmarkEntry::~BookmarkEntry() {} |
| 74 | 69 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 99 } | 94 } |
| 100 | 95 |
| 101 void ProfileWriter::AddHomepage(const GURL& home_page) { | 96 void ProfileWriter::AddHomepage(const GURL& home_page) { |
| 102 DCHECK(profile_); | 97 DCHECK(profile_); |
| 103 | 98 |
| 104 PrefService* prefs = profile_->GetPrefs(); | 99 PrefService* prefs = profile_->GetPrefs(); |
| 105 // NOTE: We set the kHomePage value, but keep the NewTab page as the homepage. | 100 // NOTE: We set the kHomePage value, but keep the NewTab page as the homepage. |
| 106 const PrefService::Preference* pref = prefs->FindPreference(prefs::kHomePage); | 101 const PrefService::Preference* pref = prefs->FindPreference(prefs::kHomePage); |
| 107 if (pref && !pref->IsManaged()) { | 102 if (pref && !pref->IsManaged()) { |
| 108 prefs->SetString(prefs::kHomePage, home_page.spec()); | 103 prefs->SetString(prefs::kHomePage, home_page.spec()); |
| 109 prefs->ScheduleSavePersistentPrefs(); | |
| 110 } | 104 } |
| 111 } | 105 } |
| 112 | 106 |
| 113 void ProfileWriter::AddBookmarks(const std::vector<BookmarkEntry>& bookmarks, | 107 void ProfileWriter::AddBookmarks(const std::vector<BookmarkEntry>& bookmarks, |
| 114 const string16& top_level_folder_name) { | 108 const string16& top_level_folder_name) { |
| 115 if (bookmarks.empty()) | 109 if (bookmarks.empty()) |
| 116 return; | 110 return; |
| 117 | 111 |
| 118 BookmarkModel* model = profile_->GetBookmarkModel(); | 112 BookmarkModel* model = profile_->GetBookmarkModel(); |
| 119 DCHECK(model->IsLoaded()); | 113 DCHECK(model->IsLoaded()); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 if (default_keyword && TemplateURL::SupportsReplacement(t_url)) | 322 if (default_keyword && TemplateURL::SupportsReplacement(t_url)) |
| 329 model->SetDefaultSearchProvider(t_url); | 323 model->SetDefaultSearchProvider(t_url); |
| 330 } else { | 324 } else { |
| 331 // Don't add invalid TemplateURLs to the model. | 325 // Don't add invalid TemplateURLs to the model. |
| 332 delete t_url; | 326 delete t_url; |
| 333 } | 327 } |
| 334 } | 328 } |
| 335 } | 329 } |
| 336 | 330 |
| 337 ProfileWriter::~ProfileWriter() {} | 331 ProfileWriter::~ProfileWriter() {} |
| OLD | NEW |