autofill_dialog_types.cc revision 868fa2fe829687343ffae624259930155e16dbd8
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 3// found in the LICENSE file. 4 5#include "chrome/browser/ui/autofill/autofill_dialog_types.h" 6 7#include "base/logging.h" 8 9namespace autofill { 10 11DialogNotification::DialogNotification() : type_(NONE) {} 12 13DialogNotification::DialogNotification(Type type, const string16& display_text) 14 : type_(type), 15 display_text_(display_text), 16 checked_(false), 17 interactive_(true) {} 18 19SkColor DialogNotification::GetBackgroundColor() const { 20 switch (type_) { 21 case DialogNotification::EXPLANATORY_MESSAGE: 22 case DialogNotification::WALLET_USAGE_CONFIRMATION: 23 return SkColorSetRGB(0x47, 0x89, 0xfa); 24 case DialogNotification::REQUIRED_ACTION: 25 case DialogNotification::WALLET_ERROR: 26 case DialogNotification::AUTOCHECKOUT_ERROR: 27 return SkColorSetRGB(0xfc, 0xf3, 0xbf); 28 case DialogNotification::DEVELOPER_WARNING: 29 case DialogNotification::SECURITY_WARNING: 30 case DialogNotification::VALIDATION_ERROR: 31 return kWarningColor; 32 case DialogNotification::AUTOCHECKOUT_SUCCESS: 33 case DialogNotification::NONE: 34 return SK_ColorTRANSPARENT; 35 } 36 37 NOTREACHED(); 38 return SK_ColorTRANSPARENT; 39} 40 41SkColor DialogNotification::GetTextColor() const { 42 switch (type_) { 43 case DialogNotification::AUTOCHECKOUT_SUCCESS: 44 case DialogNotification::REQUIRED_ACTION: 45 case DialogNotification::WALLET_ERROR: 46 case DialogNotification::AUTOCHECKOUT_ERROR: 47 return SK_ColorBLACK; 48 case DialogNotification::DEVELOPER_WARNING: 49 case DialogNotification::EXPLANATORY_MESSAGE: 50 case DialogNotification::WALLET_USAGE_CONFIRMATION: 51 case DialogNotification::SECURITY_WARNING: 52 case DialogNotification::VALIDATION_ERROR: 53 return SK_ColorWHITE; 54 case DialogNotification::NONE: 55 return SK_ColorTRANSPARENT; 56 } 57 58 NOTREACHED(); 59 return SK_ColorTRANSPARENT; 60} 61 62bool DialogNotification::HasArrow() const { 63 return type_ == DialogNotification::EXPLANATORY_MESSAGE || 64 type_ == DialogNotification::WALLET_ERROR || 65 type_ == DialogNotification::WALLET_USAGE_CONFIRMATION; 66} 67 68bool DialogNotification::HasCheckbox() const { 69 return type_ == DialogNotification::WALLET_USAGE_CONFIRMATION; 70} 71 72SkColor const kWarningColor = SkColorSetRGB(0xde, 0x49, 0x32); 73 74SuggestionState::SuggestionState(const string16& text, 75 gfx::Font::FontStyle text_style, 76 const gfx::Image& icon, 77 const string16& extra_text, 78 const gfx::Image& extra_icon, 79 bool editable) 80 : text(text), 81 text_style(text_style), 82 icon(icon), 83 extra_text(extra_text), 84 extra_icon(extra_icon), 85 editable(editable) {} 86SuggestionState::~SuggestionState() {} 87 88AutofillMetrics::DialogUiEvent DialogSectionToUiEditEvent( 89 DialogSection section) { 90 switch (section) { 91 case SECTION_EMAIL: 92 return AutofillMetrics::DIALOG_UI_EMAIL_EDIT_UI_SHOWN; 93 94 case SECTION_BILLING: 95 return AutofillMetrics::DIALOG_UI_BILLING_EDIT_UI_SHOWN; 96 97 case SECTION_CC_BILLING: 98 return AutofillMetrics::DIALOG_UI_CC_BILLING_EDIT_UI_SHOWN; 99 100 case SECTION_SHIPPING: 101 return AutofillMetrics::DIALOG_UI_SHIPPING_EDIT_UI_SHOWN; 102 103 case SECTION_CC: 104 return AutofillMetrics::DIALOG_UI_CC_EDIT_UI_SHOWN; 105 } 106 107 NOTREACHED(); 108 return AutofillMetrics::NUM_DIALOG_UI_EVENTS; 109} 110 111AutofillMetrics::DialogUiEvent DialogSectionToUiItemAddedEvent( 112 DialogSection section) { 113 switch (section) { 114 case SECTION_EMAIL: 115 return AutofillMetrics::DIALOG_UI_EMAIL_ITEM_ADDED; 116 117 case SECTION_BILLING: 118 return AutofillMetrics::DIALOG_UI_BILLING_ITEM_ADDED; 119 120 case SECTION_CC_BILLING: 121 return AutofillMetrics::DIALOG_UI_CC_BILLING_ITEM_ADDED; 122 123 case SECTION_SHIPPING: 124 return AutofillMetrics::DIALOG_UI_SHIPPING_ITEM_ADDED; 125 126 case SECTION_CC: 127 return AutofillMetrics::DIALOG_UI_CC_ITEM_ADDED; 128 } 129 130 NOTREACHED(); 131 return AutofillMetrics::NUM_DIALOG_UI_EVENTS; 132} 133 134AutofillMetrics::DialogUiEvent DialogSectionToUiSelectionChangedEvent( 135 DialogSection section) { 136 switch (section) { 137 case SECTION_EMAIL: 138 return AutofillMetrics::DIALOG_UI_EMAIL_SELECTED_SUGGESTION_CHANGED; 139 140 case SECTION_BILLING: 141 return AutofillMetrics::DIALOG_UI_BILLING_SELECTED_SUGGESTION_CHANGED; 142 143 case SECTION_CC_BILLING: 144 return AutofillMetrics::DIALOG_UI_CC_BILLING_SELECTED_SUGGESTION_CHANGED; 145 146 case SECTION_SHIPPING: 147 return AutofillMetrics::DIALOG_UI_SHIPPING_SELECTED_SUGGESTION_CHANGED; 148 149 case SECTION_CC: 150 return AutofillMetrics::DIALOG_UI_CC_SELECTED_SUGGESTION_CHANGED; 151 } 152 153 NOTREACHED(); 154 return AutofillMetrics::NUM_DIALOG_UI_EVENTS; 155} 156 157} // namespace autofill 158