Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: chrome/browser/bookmarks/bookmark_utils.cc

Issue 105193002: Replace string16 with base::string16. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/bookmarks/bookmark_utils.h" 5 #include "chrome/browser/bookmarks/bookmark_utils.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 } 54 }
55 55
56 // Comparison function that compares based on date modified of the two nodes. 56 // Comparison function that compares based on date modified of the two nodes.
57 bool MoreRecentlyModified(const BookmarkNode* n1, const BookmarkNode* n2) { 57 bool MoreRecentlyModified(const BookmarkNode* n1, const BookmarkNode* n2) {
58 return n1->date_folder_modified() > n2->date_folder_modified(); 58 return n1->date_folder_modified() > n2->date_folder_modified();
59 } 59 }
60 60
61 // Returns true if |text| contains each string in |words|. This is used when 61 // Returns true if |text| contains each string in |words|. This is used when
62 // searching for bookmarks. 62 // searching for bookmarks.
63 bool DoesBookmarkTextContainWords(const string16& text, 63 bool DoesBookmarkTextContainWords(const base::string16& text,
64 const std::vector<string16>& words) { 64 const std::vector<string16>& words) {
65 for (size_t i = 0; i < words.size(); ++i) { 65 for (size_t i = 0; i < words.size(); ++i) {
66 if (!base::i18n::StringSearchIgnoringCaseAndAccents( 66 if (!base::i18n::StringSearchIgnoringCaseAndAccents(
67 words[i], text, NULL, NULL)) { 67 words[i], text, NULL, NULL)) {
68 return false; 68 return false;
69 } 69 }
70 } 70 }
71 return true; 71 return true;
72 } 72 }
73 73
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } 208 }
209 } 209 }
210 } 210 }
211 } 211 }
212 212
213 bool MoreRecentlyAdded(const BookmarkNode* n1, const BookmarkNode* n2) { 213 bool MoreRecentlyAdded(const BookmarkNode* n1, const BookmarkNode* n2) {
214 return n1->date_added() > n2->date_added(); 214 return n1->date_added() > n2->date_added();
215 } 215 }
216 216
217 void GetBookmarksContainingText(BookmarkModel* model, 217 void GetBookmarksContainingText(BookmarkModel* model,
218 const string16& text, 218 const base::string16& text,
219 size_t max_count, 219 size_t max_count,
220 const std::string& languages, 220 const std::string& languages,
221 std::vector<const BookmarkNode*>* nodes) { 221 std::vector<const BookmarkNode*>* nodes) {
222 std::vector<string16> words; 222 std::vector<string16> words;
223 QueryParser parser; 223 QueryParser parser;
224 parser.ParseQueryWords(base::i18n::ToLower(text), &words); 224 parser.ParseQueryWords(base::i18n::ToLower(text), &words);
225 if (words.empty()) 225 if (words.empty())
226 return; 226 return;
227 227
228 ui::TreeNodeIterator<const BookmarkNode> iterator(model->root_node()); 228 ui::TreeNodeIterator<const BookmarkNode> iterator(model->root_node());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 const BookmarkNode* node = model->GetNodeByID(*iter); 286 const BookmarkNode* node = model->GetNodeByID(*iter);
287 if (!node) 287 if (!node)
288 continue; 288 continue;
289 const BookmarkNode* parent = node->parent(); 289 const BookmarkNode* parent = node->parent();
290 model->Remove(parent, parent->GetIndexOf(node)); 290 model->Remove(parent, parent->GetIndexOf(node));
291 } 291 }
292 } 292 }
293 293
294 void AddIfNotBookmarked(BookmarkModel* model, 294 void AddIfNotBookmarked(BookmarkModel* model,
295 const GURL& url, 295 const GURL& url,
296 const string16& title) { 296 const base::string16& title) {
297 std::vector<const BookmarkNode*> bookmarks; 297 std::vector<const BookmarkNode*> bookmarks;
298 model->GetNodesByURL(url, &bookmarks); 298 model->GetNodesByURL(url, &bookmarks);
299 if (!bookmarks.empty()) 299 if (!bookmarks.empty())
300 return; // Nothing to do, a bookmark with that url already exists. 300 return; // Nothing to do, a bookmark with that url already exists.
301 301
302 content::RecordAction(content::UserMetricsAction("BookmarkAdded")); 302 content::RecordAction(content::UserMetricsAction("BookmarkAdded"));
303 const BookmarkNode* parent = model->GetParentForNewNodes(); 303 const BookmarkNode* parent = model->GetParentForNewNodes();
304 model->AddURL(parent, parent->child_count(), title, url); 304 model->AddURL(parent, parent->child_count(), title, url);
305 } 305 }
306 306
307 void RemoveAllBookmarks(BookmarkModel* model, const GURL& url) { 307 void RemoveAllBookmarks(BookmarkModel* model, const GURL& url) {
308 std::vector<const BookmarkNode*> bookmarks; 308 std::vector<const BookmarkNode*> bookmarks;
309 model->GetNodesByURL(url, &bookmarks); 309 model->GetNodesByURL(url, &bookmarks);
310 310
311 // Remove all the bookmarks. 311 // Remove all the bookmarks.
312 for (size_t i = 0; i < bookmarks.size(); ++i) { 312 for (size_t i = 0; i < bookmarks.size(); ++i) {
313 const BookmarkNode* node = bookmarks[i]; 313 const BookmarkNode* node = bookmarks[i];
314 int index = node->parent()->GetIndexOf(node); 314 int index = node->parent()->GetIndexOf(node);
315 if (index > -1) 315 if (index > -1)
316 model->Remove(node->parent(), index); 316 model->Remove(node->parent(), index);
317 } 317 }
318 } 318 }
319 319
320 } // namespace bookmark_utils 320 } // namespace bookmark_utils
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_utils.h ('k') | chrome/browser/browsing_data/browsing_data_database_helper_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698