diff options
author | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-07 22:29:24 +0000 |
---|---|---|
committer | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-07 22:29:24 +0000 |
commit | 95f4165dbb9a7c74850ffe43c456666b4f0842f3 (patch) | |
tree | 030c2cce7d905e9ffec28f50e96de61629aee536 /chrome | |
parent | 69f5c80591159c7ee8f3de730a627a1b65d87721 (diff) | |
download | chromium_src-95f4165dbb9a7c74850ffe43c456666b4f0842f3.zip chromium_src-95f4165dbb9a7c74850ffe43c456666b4f0842f3.tar.gz chromium_src-95f4165dbb9a7c74850ffe43c456666b4f0842f3.tar.bz2 |
Adjusted icons, control sizes, etc.
BUG=44622
TEST=in the bug
Review URL: http://codereview.chromium.org/2638003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49108 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autofill/contact_info.cc | 26 | ||||
-rw-r--r-- | chrome/browser/autofill/contact_info.h | 5 | ||||
-rw-r--r-- | chrome/browser/autofill/contact_info_unittest.cc | 66 | ||||
-rw-r--r-- | chrome/browser/views/autofill_profiles_view_win.cc | 9 | ||||
-rw-r--r-- | chrome/browser/views/autofill_profiles_view_win.h | 3 | ||||
-rwxr-xr-x | chrome/chrome_tests.gypi | 1 |
6 files changed, 104 insertions, 6 deletions
diff --git a/chrome/browser/autofill/contact_info.cc b/chrome/browser/autofill/contact_info.cc index 8d4a08f..0355fd0 100644 --- a/chrome/browser/autofill/contact_info.cc +++ b/chrome/browser/autofill/contact_info.cc @@ -116,6 +116,8 @@ void ContactInfo::SetInfo(const AutoFillType& type, const string16& value) { email_ = value; else if (field_type == COMPANY_NAME) company_name_ = value; + else if (field_type == NAME_FULL) + SetFullName(value); else NOTREACHED(); } @@ -357,3 +359,27 @@ void ContactInfo::SetLast(const string16& last) { for (iter = last_tokens_.begin(); iter != last_tokens_.end(); ++iter) *iter = StringToLowerASCII(*iter); } + +void ContactInfo::SetFullName(const string16& full) { + NameTokens full_name_tokens; + Tokenize(full, ASCIIToUTF16(" "), &full_name_tokens); + // Clear the names. + SetFirst(string16()); + SetMiddle(string16()); + SetLast(string16()); + + // There are four possibilities: empty; first name; first and last names; + // first, middle (possibly multiple strings) and then the last name. + if (full_name_tokens.size() > 0) { + SetFirst(full_name_tokens[0]); + if (full_name_tokens.size() > 1) { + SetLast(full_name_tokens.back()); + if (full_name_tokens.size() > 2) { + full_name_tokens.erase(full_name_tokens.begin()); + full_name_tokens.pop_back(); + SetMiddle(JoinString(full_name_tokens, ' ')); + } + } + } +} + diff --git a/chrome/browser/autofill/contact_info.h b/chrome/browser/autofill/contact_info.h index adbc66a..a1325ea 100644 --- a/chrome/browser/autofill/contact_info.h +++ b/chrome/browser/autofill/contact_info.h @@ -28,6 +28,7 @@ class ContactInfo : public FormGroup { virtual void SetInfo(const AutoFillType& type, const string16& value); private: + friend class ContactInfoTest; explicit ContactInfo(const ContactInfo& contact_info); void operator=(const ContactInfo& info); @@ -89,6 +90,10 @@ class ContactInfo : public FormGroup { // made lowercase. void SetLast(const string16& last); + // Sets |first_|, |middle_|, |last_| and |*_tokens_| to the tokenized + // |full|. It is tokenized on a space only. + void SetFullName(const string16& full); + void set_suffix(const string16& suffix) { suffix_ = suffix; } // List of tokens in each part of the name. diff --git a/chrome/browser/autofill/contact_info_unittest.cc b/chrome/browser/autofill/contact_info_unittest.cc new file mode 100644 index 0000000..139c242 --- /dev/null +++ b/chrome/browser/autofill/contact_info_unittest.cc @@ -0,0 +1,66 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/autofill/contact_info.h" + +#include "base/basictypes.h" +#include "base/string_util.h" +#include "chrome/browser/autofill/autofill_type.h" +#include "chrome/browser/autofill/field_types.h" +#include "testing/gtest/include/gtest/gtest.h" + +class ContactInfoTest : public testing::Test { + public: + ContactInfoTest() {} + + string16 first(const ContactInfo& contact) { + return contact.first(); + } + string16 middle(const ContactInfo& contact) { + return contact.middle(); + } + string16 last(const ContactInfo& contact) { + return contact.last(); + } + string16 FullName(const ContactInfo& contact) { + return contact.FullName(); + } + void SetFullName(ContactInfo* contact, const string16& full_name) { + contact->SetFullName(full_name); + } + + private: + DISALLOW_COPY_AND_ASSIGN(ContactInfoTest); +}; + +TEST_F(ContactInfoTest, TestSetFullName) { + ContactInfo contact_info; + SetFullName(&contact_info, ASCIIToUTF16("Virgil")); + EXPECT_EQ(first(contact_info), ASCIIToUTF16("Virgil")); + EXPECT_EQ(middle(contact_info), ASCIIToUTF16("")); + EXPECT_EQ(last(contact_info), ASCIIToUTF16("")); + EXPECT_EQ(FullName(contact_info), ASCIIToUTF16("Virgil")); + + SetFullName(&contact_info, ASCIIToUTF16("Murray Gell-Mann")); + EXPECT_EQ(first(contact_info), ASCIIToUTF16("Murray")); + EXPECT_EQ(middle(contact_info), ASCIIToUTF16("")); + EXPECT_EQ(last(contact_info), ASCIIToUTF16("Gell-Mann")); + EXPECT_EQ(FullName(contact_info), ASCIIToUTF16("Murray Gell-Mann")); + + SetFullName(&contact_info, + ASCIIToUTF16("Mikhail Yevgrafovich Saltykov-Shchedrin")); + EXPECT_EQ(first(contact_info), ASCIIToUTF16("Mikhail")); + EXPECT_EQ(middle(contact_info), ASCIIToUTF16("Yevgrafovich")); + EXPECT_EQ(last(contact_info), ASCIIToUTF16("Saltykov-Shchedrin")); + EXPECT_EQ(FullName(contact_info), + ASCIIToUTF16("Mikhail Yevgrafovich Saltykov-Shchedrin")); + + SetFullName(&contact_info, ASCIIToUTF16("Arthur Ignatius Conan Doyle")); + EXPECT_EQ(first(contact_info), ASCIIToUTF16("Arthur")); + EXPECT_EQ(middle(contact_info), ASCIIToUTF16("Ignatius Conan")); + EXPECT_EQ(last(contact_info), ASCIIToUTF16("Doyle")); + EXPECT_EQ(FullName(contact_info), + ASCIIToUTF16("Arthur Ignatius Conan Doyle")); +} + diff --git a/chrome/browser/views/autofill_profiles_view_win.cc b/chrome/browser/views/autofill_profiles_view_win.cc index c7421c7..c887e29 100644 --- a/chrome/browser/views/autofill_profiles_view_win.cc +++ b/chrome/browser/views/autofill_profiles_view_win.cc @@ -25,6 +25,7 @@ #include "gfx/canvas.h" #include "gfx/native_theme_win.h" #include "gfx/size.h" +#include "grit/app_resources.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "views/border.h" @@ -192,12 +193,7 @@ void AutoFillProfilesView::ChildWindowClosed() { SkBitmap* AutoFillProfilesView::GetWarningBimap(bool good) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - // TODO(georgey) : change to correct icons when available. - if (good) { - return rb.GetBitmapNamed(ThemeResourcesUtil::GetId("update_uptodate")); - } else { - return rb.GetBitmapNamed(ThemeResourcesUtil::GetId("update_available")); - } + return rb.GetBitmapNamed(good ? IDR_INPUT_GOOD : IDR_INPUT_ALERT); } @@ -706,6 +702,7 @@ AutoFillProfilesView::EditableSetViewContents::GetWindowTitle() const { } void AutoFillProfilesView::EditableSetViewContents::WindowClosing() { + billing_model_->ClearComboBoxes(); observer_->ChildWindowClosed(); } diff --git a/chrome/browser/views/autofill_profiles_view_win.h b/chrome/browser/views/autofill_profiles_view_win.h index 02770a6..bdc1e48 100644 --- a/chrome/browser/views/autofill_profiles_view_win.h +++ b/chrome/browser/views/autofill_profiles_view_win.h @@ -357,6 +357,9 @@ class AutoFillProfilesView : public views::View, // Model does not own |combo_box|. void UsedWithComboBox(views::Combobox *combo_box); + // Need to be called when comboboxes are destroyed. + void ClearComboBoxes() { combo_boxes_.clear(); } + // Call this function if one of the labels has changed void LabelChanged(); diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 0d86ad6..3d39a03 100755 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -566,6 +566,7 @@ 'browser/autofill/autofill_type_unittest.cc', 'browser/autofill/autofill_xml_parser_unittest.cc', 'browser/autofill/billing_address_unittest.cc', + 'browser/autofill/contact_info_unittest.cc', 'browser/autofill/credit_card_field_unittest.cc', 'browser/autofill/credit_card_unittest.cc', 'browser/autofill/fax_field_unittest.cc', |