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

Side by Side Diff: components/omnibox/shortcuts_backend.cc

Issue 1220963005: Update base::StartsWith calls to new form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@starts_with
Patch Set: Created 5 years, 5 months 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
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 "components/omnibox/shortcuts_backend.h" 5 #include "components/omnibox/shortcuts_backend.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 observer_list_.RemoveObserver(obs); 112 observer_list_.RemoveObserver(obs);
113 } 113 }
114 114
115 void ShortcutsBackend::AddOrUpdateShortcut(const base::string16& text, 115 void ShortcutsBackend::AddOrUpdateShortcut(const base::string16& text,
116 const AutocompleteMatch& match) { 116 const AutocompleteMatch& match) {
117 const base::string16 text_lowercase(base::i18n::ToLower(text)); 117 const base::string16 text_lowercase(base::i18n::ToLower(text));
118 const base::Time now(base::Time::Now()); 118 const base::Time now(base::Time::Now());
119 for (ShortcutMap::const_iterator it( 119 for (ShortcutMap::const_iterator it(
120 shortcuts_map_.lower_bound(text_lowercase)); 120 shortcuts_map_.lower_bound(text_lowercase));
121 it != shortcuts_map_.end() && 121 it != shortcuts_map_.end() &&
122 base::StartsWith(it->first, text_lowercase, true); 122 base::StartsWith(it->first, text_lowercase,
123 base::CompareCase::SENSITIVE);
123 ++it) { 124 ++it) {
124 if (match.destination_url == it->second.match_core.destination_url) { 125 if (match.destination_url == it->second.match_core.destination_url) {
125 UpdateShortcut(ShortcutsDatabase::Shortcut( 126 UpdateShortcut(ShortcutsDatabase::Shortcut(
126 it->second.id, text, MatchToMatchCore(match, template_url_service_, 127 it->second.id, text, MatchToMatchCore(match, template_url_service_,
127 search_terms_data_.get()), 128 search_terms_data_.get()),
128 now, it->second.number_of_hits + 1)); 129 now, it->second.number_of_hits + 1));
129 return; 130 return;
130 } 131 }
131 } 132 }
132 AddShortcut(ShortcutsDatabase::Shortcut( 133 AddShortcut(ShortcutsDatabase::Shortcut(
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 base::IgnoreResult(&ShortcutsDatabase::DeleteShortcutsWithIDs), 280 base::IgnoreResult(&ShortcutsDatabase::DeleteShortcutsWithIDs),
280 db_.get(), shortcut_ids)); 281 db_.get(), shortcut_ids));
281 } 282 }
282 283
283 bool ShortcutsBackend::DeleteShortcutsWithURL(const GURL& url, 284 bool ShortcutsBackend::DeleteShortcutsWithURL(const GURL& url,
284 bool exact_match) { 285 bool exact_match) {
285 const std::string& url_spec = url.spec(); 286 const std::string& url_spec = url.spec();
286 ShortcutsDatabase::ShortcutIDs shortcut_ids; 287 ShortcutsDatabase::ShortcutIDs shortcut_ids;
287 for (GuidMap::iterator it(guid_map_.begin()); it != guid_map_.end(); ) { 288 for (GuidMap::iterator it(guid_map_.begin()); it != guid_map_.end(); ) {
288 if (exact_match ? (it->second->second.match_core.destination_url == url) 289 if (exact_match ? (it->second->second.match_core.destination_url == url)
289 : base::StartsWithASCII( 290 : base::StartsWith(
290 it->second->second.match_core.destination_url.spec(), 291 it->second->second.match_core.destination_url.spec(),
291 url_spec, true)) { 292 url_spec, base::CompareCase::SENSITIVE)) {
292 shortcut_ids.push_back(it->first); 293 shortcut_ids.push_back(it->first);
293 shortcuts_map_.erase(it->second); 294 shortcuts_map_.erase(it->second);
294 guid_map_.erase(it++); 295 guid_map_.erase(it++);
295 } else { 296 } else {
296 ++it; 297 ++it;
297 } 298 }
298 } 299 }
299 FOR_EACH_OBSERVER(ShortcutsBackendObserver, observer_list_, 300 FOR_EACH_OBSERVER(ShortcutsBackendObserver, observer_list_,
300 OnShortcutsChanged()); 301 OnShortcutsChanged());
301 return no_db_access_ || 302 return no_db_access_ ||
(...skipping 10 matching lines...) Expand all
312 shortcuts_map_.clear(); 313 shortcuts_map_.clear();
313 guid_map_.clear(); 314 guid_map_.clear();
314 FOR_EACH_OBSERVER(ShortcutsBackendObserver, observer_list_, 315 FOR_EACH_OBSERVER(ShortcutsBackendObserver, observer_list_,
315 OnShortcutsChanged()); 316 OnShortcutsChanged());
316 return no_db_access_ || 317 return no_db_access_ ||
317 db_runner_->PostTask( 318 db_runner_->PostTask(
318 FROM_HERE, base::Bind(base::IgnoreResult( 319 FROM_HERE, base::Bind(base::IgnoreResult(
319 &ShortcutsDatabase::DeleteAllShortcuts), 320 &ShortcutsDatabase::DeleteAllShortcuts),
320 db_.get())); 321 db_.get()));
321 } 322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698