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

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

Issue 10096015: 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
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 std::set<GURL>& urls = 230 const URLRows& rows(
231 content::Details<const history::URLsDeletedDetails>(details)->urls; 231 content::Details<const history::URLsDeletedDetails>(details)->rows);
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 (urls.find(it->second->second.url) != urls.end()) 236 if (std::find_if(rows.begin(), rows.end(),
237 URLRow::URLRowHasURL(it->second->second.url)) !=
238 rows.end())
237 shortcut_ids.push_back(it->first); 239 shortcut_ids.push_back(it->first);
238 } 240 }
239 DeleteShortcutsWithIds(shortcut_ids); 241 DeleteShortcutsWithIds(shortcut_ids);
240 return; 242 return;
241 } 243 }
242 244
243 DCHECK(type == chrome::NOTIFICATION_OMNIBOX_OPENED_URL); 245 DCHECK(type == chrome::NOTIFICATION_OMNIBOX_OPENED_URL);
244 246
245 AutocompleteLog* log = content::Details<AutocompleteLog>(details).ptr(); 247 AutocompleteLog* log = content::Details<AutocompleteLog>(details).ptr();
246 string16 text_lowercase(base::i18n::ToLower(log->text)); 248 string16 text_lowercase(base::i18n::ToLower(log->text));
247 249
248 const AutocompleteMatch& match(log->result.match_at(log->selected_index)); 250 const AutocompleteMatch& match(log->result.match_at(log->selected_index));
249 for (ShortcutMap::iterator it = shortcuts_map_.lower_bound(text_lowercase); 251 for (ShortcutMap::iterator it = shortcuts_map_.lower_bound(text_lowercase);
250 it != shortcuts_map_.end() && 252 it != shortcuts_map_.end() &&
251 StartsWith(it->first, text_lowercase, true); ++it) { 253 StartsWith(it->first, text_lowercase, true); ++it) {
252 if (match.destination_url == it->second.url) { 254 if (match.destination_url == it->second.url) {
253 UpdateShortcut(Shortcut(it->second.id, log->text, match.destination_url, 255 UpdateShortcut(Shortcut(it->second.id, log->text, match.destination_url,
254 match.contents, match.contents_class, match.description, 256 match.contents, match.contents_class, match.description,
255 match.description_class, base::Time::Now(), 257 match.description_class, base::Time::Now(),
256 it->second.number_of_hits + 1)); 258 it->second.number_of_hits + 1));
257 return; 259 return;
258 } 260 }
259 } 261 }
260 AddShortcut(Shortcut(guid::GenerateGUID(), log->text, match.destination_url, 262 AddShortcut(Shortcut(guid::GenerateGUID(), log->text, match.destination_url,
261 match.contents, match.contents_class, match.description, 263 match.contents, match.contents_class, match.description,
262 match.description_class, base::Time::Now(), 1)); 264 match.description_class, base::Time::Now(), 1));
263 } 265 }
264 266
265 } // namespace history 267 } // 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