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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/bookmarks/bookmark_model.h" | 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
14 #include "chrome/browser/password_manager/password_store.h" | 14 #include "chrome/browser/password_manager/password_store.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/search_engines/template_url.h" | 17 #include "chrome/browser/search_engines/template_url.h" |
18 #include "chrome/browser/search_engines/template_url_service.h" | 18 #include "chrome/browser/search_engines/template_url_service.h" |
19 #include "chrome/browser/search_engines/template_url_service_factory.h" | 19 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 20 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
21 #include "content/common/notification_service.h" | 22 #include "content/common/notification_service.h" |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 // Generates a unique folder name. If |folder_name| is not unique, then this | 26 // Generates a unique folder name. If |folder_name| is not unique, then this |
26 // repeatedly tests for '|folder_name| + (i)' until a unique name is found. | 27 // repeatedly tests for '|folder_name| + (i)' until a unique name is found. |
27 string16 GenerateUniqueFolderName(BookmarkModel* model, | 28 string16 GenerateUniqueFolderName(BookmarkModel* model, |
28 const string16& folder_name) { | 29 const string16& folder_name) { |
29 // Build a set containing the bookmark bar folder names. | 30 // Build a set containing the bookmark bar folder names. |
(...skipping 24 matching lines...) Expand all Loading... |
54 // Shows the bookmarks toolbar. | 55 // Shows the bookmarks toolbar. |
55 void ShowBookmarkBar(Profile* profile) { | 56 void ShowBookmarkBar(Profile* profile) { |
56 PrefService* prefs = profile->GetPrefs(); | 57 PrefService* prefs = profile->GetPrefs(); |
57 // Check whether the bookmark bar is shown in current pref. | 58 // Check whether the bookmark bar is shown in current pref. |
58 if (!prefs->GetBoolean(prefs::kShowBookmarkBar)) { | 59 if (!prefs->GetBoolean(prefs::kShowBookmarkBar)) { |
59 // Set the pref and notify the notification service. | 60 // Set the pref and notify the notification service. |
60 prefs->SetBoolean(prefs::kShowBookmarkBar, true); | 61 prefs->SetBoolean(prefs::kShowBookmarkBar, true); |
61 prefs->ScheduleSavePersistentPrefs(); | 62 prefs->ScheduleSavePersistentPrefs(); |
62 Source<Profile> source(profile); | 63 Source<Profile> source(profile); |
63 NotificationService::current()->Notify( | 64 NotificationService::current()->Notify( |
64 NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, source, | 65 chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, source, |
65 NotificationService::NoDetails()); | 66 NotificationService::NoDetails()); |
66 } | 67 } |
67 } | 68 } |
68 | 69 |
69 } // namespace | 70 } // namespace |
70 | 71 |
71 ProfileWriter::BookmarkEntry::BookmarkEntry() | 72 ProfileWriter::BookmarkEntry::BookmarkEntry() |
72 : in_toolbar(false), | 73 : in_toolbar(false), |
73 is_folder(false) {} | 74 is_folder(false) {} |
74 | 75 |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 if (default_keyword && TemplateURL::SupportsReplacement(t_url)) | 331 if (default_keyword && TemplateURL::SupportsReplacement(t_url)) |
331 model->SetDefaultSearchProvider(t_url); | 332 model->SetDefaultSearchProvider(t_url); |
332 } else { | 333 } else { |
333 // Don't add invalid TemplateURLs to the model. | 334 // Don't add invalid TemplateURLs to the model. |
334 delete t_url; | 335 delete t_url; |
335 } | 336 } |
336 } | 337 } |
337 } | 338 } |
338 | 339 |
339 ProfileWriter::~ProfileWriter() {} | 340 ProfileWriter::~ProfileWriter() {} |
OLD | NEW |