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

Side by Side Diff: chrome/browser/autocomplete/shortcuts_provider.cc

Issue 10071036: RefCounted types should not have public destructors, chrome/browser/ part 6 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implementation fixes Created 8 years, 7 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/autocomplete/shortcuts_provider.h" 5 #include "chrome/browser/autocomplete/shortcuts_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), 54 languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)),
55 initialized_(false), 55 initialized_(false),
56 shortcuts_backend_(profile->GetShortcutsBackend()) { 56 shortcuts_backend_(profile->GetShortcutsBackend()) {
57 if (shortcuts_backend_.get()) { 57 if (shortcuts_backend_.get()) {
58 shortcuts_backend_->AddObserver(this); 58 shortcuts_backend_->AddObserver(this);
59 if (shortcuts_backend_->initialized()) 59 if (shortcuts_backend_->initialized())
60 initialized_ = true; 60 initialized_ = true;
61 } 61 }
62 } 62 }
63 63
64 ShortcutsProvider::~ShortcutsProvider() {
65 if (shortcuts_backend_.get())
66 shortcuts_backend_->RemoveObserver(this);
67 }
68
69 void ShortcutsProvider::Start(const AutocompleteInput& input, 64 void ShortcutsProvider::Start(const AutocompleteInput& input,
70 bool minimal_changes) { 65 bool minimal_changes) {
71 matches_.clear(); 66 matches_.clear();
72 67
73 if (input.type() == AutocompleteInput::INVALID) 68 if (input.type() == AutocompleteInput::INVALID)
74 return; 69 return;
75 70
76 if (input.text().empty()) 71 if (input.text().empty())
77 return; 72 return;
78 73
(...skipping 25 matching lines...) Expand all
104 99
105 // Delete the match from the history DB. This will eventually result in a 100 // Delete the match from the history DB. This will eventually result in a
106 // second call to DeleteShortcutsWithURLs(), which is harmless. 101 // second call to DeleteShortcutsWithURLs(), which is harmless.
107 HistoryService* const history_service = 102 HistoryService* const history_service =
108 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); 103 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
109 104
110 DCHECK(history_service && match.destination_url.is_valid()); 105 DCHECK(history_service && match.destination_url.is_valid());
111 history_service->DeleteURL(match.destination_url); 106 history_service->DeleteURL(match.destination_url);
112 } 107 }
113 108
109 ShortcutsProvider::~ShortcutsProvider() {
110 if (shortcuts_backend_.get())
111 shortcuts_backend_->RemoveObserver(this);
112 }
113
114 void ShortcutsProvider::OnShortcutsLoaded() { 114 void ShortcutsProvider::OnShortcutsLoaded() {
115 initialized_ = true; 115 initialized_ = true;
116 } 116 }
117 117
118 void ShortcutsProvider::DeleteMatchesWithURLs(const std::set<GURL>& urls) { 118 void ShortcutsProvider::DeleteMatchesWithURLs(const std::set<GURL>& urls) {
119 std::remove_if(matches_.begin(), matches_.end(), RemoveMatchPredicate(urls)); 119 std::remove_if(matches_.begin(), matches_.end(), RemoveMatchPredicate(urls));
120 listener_->OnProviderUpdate(true); 120 listener_->OnProviderUpdate(true);
121 } 121 }
122 122
123 void ShortcutsProvider::DeleteShortcutsWithURLs(const std::set<GURL>& urls) { 123 void ShortcutsProvider::DeleteShortcutsWithURLs(const std::set<GURL>& urls) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 302 }
303 303
304 void ShortcutsProvider::set_shortcuts_backend( 304 void ShortcutsProvider::set_shortcuts_backend(
305 history::ShortcutsBackend* shortcuts_backend) { 305 history::ShortcutsBackend* shortcuts_backend) {
306 DCHECK(shortcuts_backend); 306 DCHECK(shortcuts_backend);
307 shortcuts_backend_ = shortcuts_backend; 307 shortcuts_backend_ = shortcuts_backend;
308 shortcuts_backend_->AddObserver(this); 308 shortcuts_backend_->AddObserver(this);
309 if (shortcuts_backend_->initialized()) 309 if (shortcuts_backend_->initialized())
310 initialized_ = true; 310 initialized_ = true;
311 } 311 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/shortcuts_provider.h ('k') | chrome/browser/autocomplete_history_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698