Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_external_delegate.h" | 5 #include "components/autofill/core/browser/autofill_external_delegate.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/metrics/histogram.h" | |
| 8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 9 #include "components/autofill/core/browser/autocomplete_history_manager.h" | 10 #include "components/autofill/core/browser/autocomplete_history_manager.h" |
| 10 #include "components/autofill/core/browser/autofill_driver.h" | 11 #include "components/autofill/core/browser/autofill_driver.h" |
| 11 #include "components/autofill/core/browser/autofill_manager.h" | 12 #include "components/autofill/core/browser/autofill_manager.h" |
| 12 #include "components/autofill/core/browser/popup_item_ids.h" | 13 #include "components/autofill/core/browser/popup_item_ids.h" |
| 13 #include "grit/components_strings.h" | 14 #include "grit/components_strings.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 15 | 16 |
| 17 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
| 18 namespace { | |
| 19 | |
| 20 enum AccessAddressBookEventType { | |
| 21 // An autofill entry was shown that prompts the user to give Chrome access to | |
|
Ilya Sherman
2014/06/02 22:54:27
nit: "autofill" -> "Autofill"
erikchen
2014/06/03 01:34:19
I've gone through the CL and replaced all instance
| |
| 22 // the user's Address Book. | |
| 23 SHOWED_ACCESS_AB_ENTRY = 0, | |
|
Ilya Sherman
2014/06/02 22:54:27
nit: "AB" -> "ADDRESS_BOOK"
erikchen
2014/06/03 01:34:19
Done.
| |
| 24 | |
| 25 // The user selected the autofill entry which prompts Chrome to access the | |
| 26 // user's Address Book. | |
| 27 SELECTED_ACCESS_AB_ENTRY, | |
| 28 | |
| 29 // Always keep this at the end. | |
| 30 ACCESS_AB_ENTRY_MAX, | |
| 31 }; | |
| 32 | |
| 33 } // namespace | |
| 34 #endif | |
| 35 | |
| 16 namespace autofill { | 36 namespace autofill { |
| 17 | 37 |
| 18 AutofillExternalDelegate::AutofillExternalDelegate(AutofillManager* manager, | 38 AutofillExternalDelegate::AutofillExternalDelegate(AutofillManager* manager, |
| 19 AutofillDriver* driver) | 39 AutofillDriver* driver) |
| 20 : manager_(manager), | 40 : manager_(manager), |
| 21 driver_(driver), | 41 driver_(driver), |
| 22 query_id_(0), | 42 query_id_(0), |
| 23 display_warning_if_disabled_(false), | 43 display_warning_if_disabled_(false), |
| 24 has_suggestion_(false), | 44 has_suggestion_(false), |
| 25 has_shown_popup_for_current_edit_(false), | 45 has_shown_popup_for_current_edit_(false), |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 // updated to match. | 111 // updated to match. |
| 92 InsertDataListValues(&values, &labels, &icons, &ids); | 112 InsertDataListValues(&values, &labels, &icons, &ids); |
| 93 | 113 |
| 94 #if defined(OS_MACOSX) && !defined(OS_IOS) | 114 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 95 if (values.empty() && | 115 if (values.empty() && |
| 96 manager_->ShouldShowAccessAddressBookSuggestion(query_form_, | 116 manager_->ShouldShowAccessAddressBookSuggestion(query_form_, |
| 97 query_field_)) { | 117 query_field_)) { |
| 98 values.push_back( | 118 values.push_back( |
| 99 l10n_util::GetStringUTF16(IDS_AUTOFILL_ACCESS_MAC_CONTACTS)); | 119 l10n_util::GetStringUTF16(IDS_AUTOFILL_ACCESS_MAC_CONTACTS)); |
| 100 labels.push_back(base::string16()); | 120 labels.push_back(base::string16()); |
| 101 icons.push_back(base::string16()); | 121 icons.push_back(base::ASCIIToUTF16("macContactsIcon")); |
| 102 ids.push_back(POPUP_ITEM_ID_MAC_ACCESS_CONTACTS); | 122 ids.push_back(POPUP_ITEM_ID_MAC_ACCESS_CONTACTS); |
| 123 | |
| 124 UMA_HISTOGRAM_ENUMERATION("Autofill.MacAccessAddressBook", | |
|
Ilya Sherman
2014/06/02 22:54:27
Optional nit: I'd drop "Access" from the histogram
erikchen
2014/06/03 01:34:19
Done.
| |
| 125 SHOWED_ACCESS_AB_ENTRY, | |
| 126 ACCESS_AB_ENTRY_MAX); | |
|
Ilya Sherman
2014/06/02 22:54:27
nit: Please define a wrapper function for emitting
erikchen
2014/06/03 01:34:19
Done.
| |
| 103 } | 127 } |
| 104 #endif | 128 #endif |
| 105 | 129 |
| 106 if (values.empty()) { | 130 if (values.empty()) { |
| 107 // No suggestions, any popup currently showing is obsolete. | 131 // No suggestions, any popup currently showing is obsolete. |
| 108 manager_->delegate()->HideAutofillPopup(); | 132 manager_->delegate()->HideAutofillPopup(); |
| 109 return; | 133 return; |
| 110 } | 134 } |
| 111 | 135 |
| 112 // Send to display. | 136 // Send to display. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 driver_->RendererShouldClearFilledForm(); | 188 driver_->RendererShouldClearFilledForm(); |
| 165 } else if (identifier == POPUP_ITEM_ID_PASSWORD_ENTRY) { | 189 } else if (identifier == POPUP_ITEM_ID_PASSWORD_ENTRY) { |
| 166 NOTREACHED(); // Should be handled elsewhere. | 190 NOTREACHED(); // Should be handled elsewhere. |
| 167 } else if (identifier == POPUP_ITEM_ID_DATALIST_ENTRY) { | 191 } else if (identifier == POPUP_ITEM_ID_DATALIST_ENTRY) { |
| 168 driver_->RendererShouldAcceptDataListSuggestion(value); | 192 driver_->RendererShouldAcceptDataListSuggestion(value); |
| 169 } else if (identifier == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) { | 193 } else if (identifier == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) { |
| 170 // User selected an Autocomplete, so we fill directly. | 194 // User selected an Autocomplete, so we fill directly. |
| 171 driver_->RendererShouldFillFieldWithValue(value); | 195 driver_->RendererShouldFillFieldWithValue(value); |
| 172 } else if (identifier == POPUP_ITEM_ID_MAC_ACCESS_CONTACTS) { | 196 } else if (identifier == POPUP_ITEM_ID_MAC_ACCESS_CONTACTS) { |
| 173 #if defined(OS_MACOSX) && !defined(OS_IOS) | 197 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 198 UMA_HISTOGRAM_ENUMERATION("Autofill.MacAccessAddressBook", | |
| 199 SELECTED_ACCESS_AB_ENTRY, | |
| 200 ACCESS_AB_ENTRY_MAX); | |
| 201 | |
| 174 // User wants to give Chrome access to user's address book. | 202 // User wants to give Chrome access to user's address book. |
| 175 manager_->AccessAddressBook(); | 203 manager_->AccessAddressBook(); |
| 176 | 204 |
| 177 // There is no deterministic method for deciding whether a blocking dialog | 205 // There is no deterministic method for deciding whether a blocking dialog |
| 178 // was presented. The following comments and code assume that a blocking | 206 // was presented. The following comments and code assume that a blocking |
| 179 // dialog was presented, but still behave correctly if no dialog was | 207 // dialog was presented, but still behave correctly if no dialog was |
| 180 // presented. | 208 // presented. |
| 181 | 209 |
| 182 // A blocking dialog was presented, and the user has already responded to | 210 // A blocking dialog was presented, and the user has already responded to |
| 183 // the dialog. The presentation of the dialog added an NSEvent to the | 211 // the dialog. The presentation of the dialog added an NSEvent to the |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 POPUP_ITEM_ID_DATALIST_ENTRY); | 389 POPUP_ITEM_ID_DATALIST_ENTRY); |
| 362 } | 390 } |
| 363 | 391 |
| 364 #if defined(OS_MACOSX) && !defined(OS_IOS) | 392 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 365 void AutofillExternalDelegate::PingRenderer() { | 393 void AutofillExternalDelegate::PingRenderer() { |
| 366 driver_->PingRenderer(); | 394 driver_->PingRenderer(); |
| 367 } | 395 } |
| 368 #endif | 396 #endif |
| 369 | 397 |
| 370 } // namespace autofill | 398 } // namespace autofill |
| OLD | NEW |