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

Side by Side Diff: chrome/browser/autocomplete_history_manager.cc

Issue 8353025: External autofill delegates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: feedback Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_history_manager.h" 5 #include "chrome/browser/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"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/autofill/autofill_external_delegate.h"
12 #include "chrome/browser/autofill/credit_card.h" 13 #include "chrome/browser/autofill/credit_card.h"
13 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/autofill_messages.h" 16 #include "chrome/common/autofill_messages.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "content/browser/renderer_host/render_view_host.h" 18 #include "content/browser/renderer_host/render_view_host.h"
18 #include "content/browser/tab_contents/tab_contents.h" 19 #include "content/browser/tab_contents/tab_contents.h"
19 #include "webkit/glue/form_data.h" 20 #include "webkit/glue/form_data.h"
20 21
21 using webkit_glue::FormData; 22 using webkit_glue::FormData;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 field.form_control_type == ASCIIToUTF16("email") || 96 field.form_control_type == ASCIIToUTF16("email") ||
96 field.form_control_type == ASCIIToUTF16("text"); 97 field.form_control_type == ASCIIToUTF16("text");
97 } 98 }
98 99
99 } // namespace 100 } // namespace
100 101
101 AutocompleteHistoryManager::AutocompleteHistoryManager( 102 AutocompleteHistoryManager::AutocompleteHistoryManager(
102 TabContents* tab_contents) 103 TabContents* tab_contents)
103 : TabContentsObserver(tab_contents), 104 : TabContentsObserver(tab_contents),
104 pending_query_handle_(0), 105 pending_query_handle_(0),
105 query_id_(0) { 106 query_id_(0),
107 external_delegate_(NULL) {
106 profile_ = Profile::FromBrowserContext(tab_contents->browser_context()); 108 profile_ = Profile::FromBrowserContext(tab_contents->browser_context());
107 // May be NULL in unit tests. 109 // May be NULL in unit tests.
108 web_data_service_ = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); 110 web_data_service_ = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
109 autofill_enabled_.Init(prefs::kAutofillEnabled, profile_->GetPrefs(), NULL); 111 autofill_enabled_.Init(prefs::kAutofillEnabled, profile_->GetPrefs(), NULL);
110 } 112 }
111 113
112 AutocompleteHistoryManager::~AutocompleteHistoryManager() { 114 AutocompleteHistoryManager::~AutocompleteHistoryManager() {
113 CancelPendingQuery(); 115 CancelPendingQuery();
114 } 116 }
115 117
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 257
256 if (unique) { 258 if (unique) {
257 autofill_values_.push_back((*suggestions)[i]); 259 autofill_values_.push_back((*suggestions)[i]);
258 autofill_labels_.push_back(string16()); 260 autofill_labels_.push_back(string16());
259 autofill_icons_.push_back(string16()); 261 autofill_icons_.push_back(string16());
260 autofill_unique_ids_.push_back(0); // 0 means no profile. 262 autofill_unique_ids_.push_back(0); // 0 means no profile.
261 } 263 }
262 } 264 }
263 } 265 }
264 266
267 if (external_delegate_) {
268 external_delegate_->OnSuggestionsReturned(
269 query_id_,
270 autofill_values_,
271 autofill_labels_,
272 autofill_icons_,
273 autofill_unique_ids_);
274 }
275
265 Send(new AutofillMsg_SuggestionsReturned(routing_id(), 276 Send(new AutofillMsg_SuggestionsReturned(routing_id(),
266 query_id_, 277 query_id_,
267 autofill_values_, 278 autofill_values_,
268 autofill_labels_, 279 autofill_labels_,
269 autofill_icons_, 280 autofill_icons_,
270 autofill_unique_ids_)); 281 autofill_unique_ids_));
271 282
272 query_id_ = 0; 283 query_id_ = 0;
273 autofill_values_.clear(); 284 autofill_values_.clear();
274 autofill_labels_.clear(); 285 autofill_labels_.clear();
275 autofill_icons_.clear(); 286 autofill_icons_.clear();
276 autofill_unique_ids_.clear(); 287 autofill_unique_ids_.clear();
277 } 288 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698