autofill_dialog_types.cc revision d0247b1b59f9c528cb6df88b4f2b9afaf80d181e
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#include "base/strings/string_split.h" 9#include "base/strings/string_util.h" 10#include "grit/generated_resources.h" 11#include "ui/base/l10n/l10n_util.h" 12#include "ui/base/resource/resource_bundle.h" 13 14namespace autofill { 15 16static const base::char16 kRangeSeparator = '|'; 17 18DialogNotification::DialogNotification() : type_(NONE) {} 19 20DialogNotification::DialogNotification(Type type, const string16& display_text) 21 : type_(type), 22 display_text_(display_text), 23 checked_(false) { 24 // If there's a range separated by bars, mark that as the anchor text. 25 std::vector<base::string16> pieces; 26 base::SplitStringDontTrim(display_text, kRangeSeparator, &pieces); 27 if (pieces.size() > 1) { 28 link_range_ = gfx::Range(pieces[0].size(), pieces[1].size()); 29 display_text_ = JoinString(pieces, string16()); 30 } 31} 32 33DialogNotification::~DialogNotification() {} 34 35SkColor DialogNotification::GetBackgroundColor() const { 36 switch (type_) { 37 case DialogNotification::EXPLANATORY_MESSAGE: 38 case DialogNotification::WALLET_USAGE_CONFIRMATION: 39 return SkColorSetRGB(0xf5, 0xf5, 0xf5); 40 case DialogNotification::REQUIRED_ACTION: 41 case DialogNotification::WALLET_ERROR: 42 return SkColorSetRGB(0xfc, 0xf3, 0xbf); 43 case DialogNotification::DEVELOPER_WARNING: 44 case DialogNotification::SECURITY_WARNING: 45 case DialogNotification::VALIDATION_ERROR: 46 return kWarningColor; 47 case DialogNotification::NONE: 48 return SK_ColorTRANSPARENT; 49 } 50 51 NOTREACHED(); 52 return SK_ColorTRANSPARENT; 53} 54 55SkColor DialogNotification::GetBorderColor() const { 56 switch (type_) { 57 case DialogNotification::EXPLANATORY_MESSAGE: 58 case DialogNotification::WALLET_USAGE_CONFIRMATION: 59 return SkColorSetRGB(0xe5, 0xe5, 0xe5); 60 case DialogNotification::REQUIRED_ACTION: 61 case DialogNotification::WALLET_ERROR: 62 case DialogNotification::DEVELOPER_WARNING: 63 case DialogNotification::SECURITY_WARNING: 64 case DialogNotification::VALIDATION_ERROR: 65 case DialogNotification::NONE: 66 return GetBackgroundColor(); 67 } 68 69 NOTREACHED(); 70 return SK_ColorTRANSPARENT; 71} 72 73SkColor DialogNotification::GetTextColor() const { 74 switch (type_) { 75 case DialogNotification::REQUIRED_ACTION: 76 case DialogNotification::WALLET_ERROR: 77 case DialogNotification::EXPLANATORY_MESSAGE: 78 case DialogNotification::WALLET_USAGE_CONFIRMATION: 79 return SkColorSetRGB(102, 102, 102); 80 case DialogNotification::DEVELOPER_WARNING: 81 case DialogNotification::SECURITY_WARNING: 82 case DialogNotification::VALIDATION_ERROR: 83 return SK_ColorWHITE; 84 case DialogNotification::NONE: 85 return SK_ColorTRANSPARENT; 86 } 87 88 NOTREACHED(); 89 return SK_ColorTRANSPARENT; 90} 91 92bool DialogNotification::HasArrow() const { 93 return type_ == DialogNotification::EXPLANATORY_MESSAGE || 94 type_ == DialogNotification::WALLET_ERROR || 95 type_ == DialogNotification::WALLET_USAGE_CONFIRMATION; 96} 97 98bool DialogNotification::HasCheckbox() const { 99 return type_ == DialogNotification::WALLET_USAGE_CONFIRMATION; 100} 101 102SkColor const kWarningColor = SkColorSetRGB(0xde, 0x49, 0x32); 103 104SuggestionState::SuggestionState() 105 : visible(false) {} 106SuggestionState::SuggestionState(bool visible, 107 const string16& vertically_compact_text, 108 const string16& horizontally_compact_text, 109 const gfx::Image& icon, 110 const string16& extra_text, 111 const gfx::Image& extra_icon) 112 : visible(visible), 113 vertically_compact_text(vertically_compact_text), 114 horizontally_compact_text(horizontally_compact_text), 115 icon(icon), 116 extra_text(extra_text), 117 extra_icon(extra_icon) {} 118SuggestionState::~SuggestionState() {} 119 120DialogOverlayString::DialogOverlayString() : alignment(gfx::ALIGN_LEFT) {} 121DialogOverlayString::~DialogOverlayString() {} 122 123DialogOverlayState::DialogOverlayState() {} 124DialogOverlayState::~DialogOverlayState() {} 125 126} // namespace autofill 127