| OLD | NEW |
| 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/autofill/autocomplete_history_manager.h" | 5 #include "chrome/browser/autofill/autocomplete_history_manager.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } // namespace | 109 } // namespace |
| 110 | 110 |
| 111 AutocompleteHistoryManager::AutocompleteHistoryManager( | 111 AutocompleteHistoryManager::AutocompleteHistoryManager( |
| 112 WebContents* web_contents) | 112 WebContents* web_contents) |
| 113 : content::WebContentsObserver(web_contents), | 113 : content::WebContentsObserver(web_contents), |
| 114 pending_query_handle_(0), | 114 pending_query_handle_(0), |
| 115 query_id_(0), | 115 query_id_(0), |
| 116 external_delegate_(NULL) { | 116 external_delegate_(NULL) { |
| 117 browser_context_ = web_contents->GetBrowserContext(); | 117 browser_context_ = web_contents->GetBrowserContext(); |
| 118 // May be NULL in unit tests. | 118 // May be NULL in unit tests. |
| 119 autofill_data_ = AutofillWebDataService::ForContext(browser_context_); | 119 autofill_data_ = AutofillWebDataService::FromBrowserContext(browser_context_); |
| 120 autofill_enabled_.Init(prefs::kAutofillEnabled, | 120 autofill_enabled_.Init(prefs::kAutofillEnabled, |
| 121 PrefServiceBase::ForContext(browser_context_), | 121 PrefServiceBase::FromBrowserContext(browser_context_), |
| 122 NULL); | 122 NULL); |
| 123 } | 123 } |
| 124 | 124 |
| 125 AutocompleteHistoryManager::~AutocompleteHistoryManager() { | 125 AutocompleteHistoryManager::~AutocompleteHistoryManager() { |
| 126 CancelPendingQuery(); | 126 CancelPendingQuery(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 bool AutocompleteHistoryManager::OnMessageReceived( | 129 bool AutocompleteHistoryManager::OnMessageReceived( |
| 130 const IPC::Message& message) { | 130 const IPC::Message& message) { |
| 131 bool handled = true; | 131 bool handled = true; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 WebContents* web_contents, | 239 WebContents* web_contents, |
| 240 BrowserContext* browser_context, | 240 BrowserContext* browser_context, |
| 241 scoped_ptr<AutofillWebDataService> awd) | 241 scoped_ptr<AutofillWebDataService> awd) |
| 242 : content::WebContentsObserver(web_contents), | 242 : content::WebContentsObserver(web_contents), |
| 243 browser_context_(browser_context), | 243 browser_context_(browser_context), |
| 244 autofill_data_(awd.Pass()), | 244 autofill_data_(awd.Pass()), |
| 245 pending_query_handle_(0), | 245 pending_query_handle_(0), |
| 246 query_id_(0), | 246 query_id_(0), |
| 247 external_delegate_(NULL) { | 247 external_delegate_(NULL) { |
| 248 autofill_enabled_.Init(prefs::kAutofillEnabled, | 248 autofill_enabled_.Init(prefs::kAutofillEnabled, |
| 249 PrefServiceBase::ForContext(browser_context_), | 249 PrefServiceBase::FromBrowserContext(browser_context_), |
| 250 NULL); | 250 NULL); |
| 251 } | 251 } |
| 252 | 252 |
| 253 void AutocompleteHistoryManager::CancelPendingQuery() { | 253 void AutocompleteHistoryManager::CancelPendingQuery() { |
| 254 if (pending_query_handle_) { | 254 if (pending_query_handle_) { |
| 255 SendSuggestions(NULL); | 255 SendSuggestions(NULL); |
| 256 if (autofill_data_.get()) | 256 if (autofill_data_.get()) |
| 257 autofill_data_->CancelRequest(pending_query_handle_); | 257 autofill_data_->CancelRequest(pending_query_handle_); |
| 258 pending_query_handle_ = 0; | 258 pending_query_handle_ = 0; |
| 259 } | 259 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 autofill_icons_, | 297 autofill_icons_, |
| 298 autofill_unique_ids_)); | 298 autofill_unique_ids_)); |
| 299 } | 299 } |
| 300 | 300 |
| 301 query_id_ = 0; | 301 query_id_ = 0; |
| 302 autofill_values_.clear(); | 302 autofill_values_.clear(); |
| 303 autofill_labels_.clear(); | 303 autofill_labels_.clear(); |
| 304 autofill_icons_.clear(); | 304 autofill_icons_.clear(); |
| 305 autofill_unique_ids_.clear(); | 305 autofill_unique_ids_.clear(); |
| 306 } | 306 } |
| OLD | NEW |