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

Side by Side Diff: chrome/browser/history/shortcuts_backend.cc

Issue 10086021: Revert 132268 - Single URL Expires Were Not Being Deleted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
Property Changes:
Added: svn:mergeinfo
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/history/shortcuts_backend.h" 5 #include "chrome/browser/history/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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 void ShortcutsBackend::Observe(int type, 220 void ShortcutsBackend::Observe(int type,
221 const content::NotificationSource& source, 221 const content::NotificationSource& source,
222 const content::NotificationDetails& details) { 222 const content::NotificationDetails& details) {
223 if (current_state_ != INITIALIZED) 223 if (current_state_ != INITIALIZED)
224 return; 224 return;
225 if (type == chrome::NOTIFICATION_HISTORY_URLS_DELETED) { 225 if (type == chrome::NOTIFICATION_HISTORY_URLS_DELETED) {
226 if (content::Details<const history::URLsDeletedDetails>(details)-> 226 if (content::Details<const history::URLsDeletedDetails>(details)->
227 all_history) { 227 all_history) {
228 DeleteAllShortcuts(); 228 DeleteAllShortcuts();
229 } 229 }
230 const URLRows& rows( 230 const std::set<GURL>& urls =
231 content::Details<const history::URLsDeletedDetails>(details)->rows); 231 content::Details<const history::URLsDeletedDetails>(details)->urls;
232 std::vector<std::string> shortcut_ids; 232 std::vector<std::string> shortcut_ids;
233 233
234 for (GuidToShortcutsIteratorMap::iterator it = guid_map_.begin(); 234 for (GuidToShortcutsIteratorMap::iterator it = guid_map_.begin();
235 it != guid_map_.end(); ++it) { 235 it != guid_map_.end(); ++it) {
236 if (std::find_if(rows.begin(), rows.end(), 236 if (urls.find(it->second->second.url) != urls.end())
237 URLRow::URLRowHasURL(it->second->second.url)) !=
238 rows.end())
239 shortcut_ids.push_back(it->first); 237 shortcut_ids.push_back(it->first);
240 } 238 }
241 DeleteShortcutsWithIds(shortcut_ids); 239 DeleteShortcutsWithIds(shortcut_ids);
242 return; 240 return;
243 } 241 }
244 242
245 DCHECK(type == chrome::NOTIFICATION_OMNIBOX_OPENED_URL); 243 DCHECK(type == chrome::NOTIFICATION_OMNIBOX_OPENED_URL);
246 244
247 AutocompleteLog* log = content::Details<AutocompleteLog>(details).ptr(); 245 AutocompleteLog* log = content::Details<AutocompleteLog>(details).ptr();
248 string16 text_lowercase(base::i18n::ToLower(log->text)); 246 string16 text_lowercase(base::i18n::ToLower(log->text));
249 247
250 const AutocompleteMatch& match(log->result.match_at(log->selected_index)); 248 const AutocompleteMatch& match(log->result.match_at(log->selected_index));
251 for (ShortcutMap::iterator it = shortcuts_map_.lower_bound(text_lowercase); 249 for (ShortcutMap::iterator it = shortcuts_map_.lower_bound(text_lowercase);
252 it != shortcuts_map_.end() && 250 it != shortcuts_map_.end() &&
253 StartsWith(it->first, text_lowercase, true); ++it) { 251 StartsWith(it->first, text_lowercase, true); ++it) {
254 if (match.destination_url == it->second.url) { 252 if (match.destination_url == it->second.url) {
255 UpdateShortcut(Shortcut(it->second.id, log->text, match.destination_url, 253 UpdateShortcut(Shortcut(it->second.id, log->text, match.destination_url,
256 match.contents, match.contents_class, match.description, 254 match.contents, match.contents_class, match.description,
257 match.description_class, base::Time::Now(), 255 match.description_class, base::Time::Now(),
258 it->second.number_of_hits + 1)); 256 it->second.number_of_hits + 1));
259 return; 257 return;
260 } 258 }
261 } 259 }
262 AddShortcut(Shortcut(guid::GenerateGUID(), log->text, match.destination_url, 260 AddShortcut(Shortcut(guid::GenerateGUID(), log->text, match.destination_url,
263 match.contents, match.contents_class, match.description, 261 match.contents, match.contents_class, match.description,
264 match.description_class, base::Time::Now(), 1)); 262 match.description_class, base::Time::Now(), 1));
265 } 263 }
266 264
267 } // namespace history 265 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/in_memory_url_index_unittest.cc ('k') | chrome/browser/history/top_sites.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698