summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill
diff options
context:
space:
mode:
authorcsharp@chromium.org <csharp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-15 14:55:33 +0000
committercsharp@chromium.org <csharp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-15 14:55:33 +0000
commit723be5d0ebfe0e1b3c0974f6b61078701c5c14c3 (patch)
tree311ac9f92afb893493739ad3678249d579e9a9e1 /chrome/browser/autofill
parent6c45ea836ab965ca5993128af9e8e71b86527d27 (diff)
downloadchromium_src-723be5d0ebfe0e1b3c0974f6b61078701c5c14c3.zip
chromium_src-723be5d0ebfe0e1b3c0974f6b61078701c5c14c3.tar.gz
chromium_src-723be5d0ebfe0e1b3c0974f6b61078701c5c14c3.tar.bz2
Add Icon Support for New Autofill Gtk UI
Show credit card icons for the new Autofill Gtk popup. BUG=51644 TEST= Review URL: https://chromiumcodereview.appspot.com/10396003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137126 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r--chrome/browser/autofill/autofill_external_delegate.cc1
-rw-r--r--chrome/browser/autofill/autofill_external_delegate.h5
-rw-r--r--chrome/browser/autofill/autofill_external_delegate_gtk.cc2
-rw-r--r--chrome/browser/autofill/autofill_popup_view.cc27
-rw-r--r--chrome/browser/autofill/autofill_popup_view.h4
5 files changed, 37 insertions, 2 deletions
diff --git a/chrome/browser/autofill/autofill_external_delegate.cc b/chrome/browser/autofill/autofill_external_delegate.cc
index 3420018..a675a29 100644
--- a/chrome/browser/autofill/autofill_external_delegate.cc
+++ b/chrome/browser/autofill/autofill_external_delegate.cc
@@ -6,7 +6,6 @@
#include "chrome/browser/autocomplete_history_manager.h"
#include "chrome/browser/autofill/autofill_external_delegate.h"
#include "chrome/browser/autofill/autofill_manager.h"
-#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/autofill_messages.h"
#include "chrome/common/chrome_constants.h"
#include "content/public/browser/render_view_host.h"
diff --git a/chrome/browser/autofill/autofill_external_delegate.h b/chrome/browser/autofill/autofill_external_delegate.h
index 803485d8..652f9ee 100644
--- a/chrome/browser/autofill/autofill_external_delegate.h
+++ b/chrome/browser/autofill/autofill_external_delegate.h
@@ -11,12 +11,12 @@
#include "base/compiler_specific.h"
#include "base/string16.h"
#include "chrome/browser/autofill/password_autofill_manager.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "webkit/forms/form_data.h"
#include "webkit/forms/form_field.h"
#include "webkit/forms/password_form_dom_manager.h"
class AutofillManager;
-class TabContentsWrapper;
namespace gfx {
class Rect;
@@ -125,6 +125,9 @@ class AutofillExternalDelegate {
// Set the bounds of the Autofill element being worked with.
virtual void SetBounds(const gfx::Rect& bounds) = 0;
+ // Return the profile that this autofill delegate is currently working with.
+ Profile* profile() { return tab_contents_wrapper_->profile(); }
+
private:
// Fills the form with the Autofill data corresponding to |unique_id|.
// If |is_preview| is true then this is just a preview to show the user what
diff --git a/chrome/browser/autofill/autofill_external_delegate_gtk.cc b/chrome/browser/autofill/autofill_external_delegate_gtk.cc
index 89d2107..bbb3f00 100644
--- a/chrome/browser/autofill/autofill_external_delegate_gtk.cc
+++ b/chrome/browser/autofill/autofill_external_delegate_gtk.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/autofill/autofill_external_delegate_gtk.h"
#include "chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.h"
+#include "chrome/browser/ui/gtk/gtk_theme_service.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
@@ -69,6 +70,7 @@ void AutofillExternalDelegateGtk::CreateViewIfNeeded() {
return;
view_.reset(new AutofillPopupViewGtk(web_contents_,
+ GtkThemeService::GetFrom(profile()),
this,
tab_native_view_));
diff --git a/chrome/browser/autofill/autofill_popup_view.cc b/chrome/browser/autofill/autofill_popup_view.cc
index 7f3d5ea..0a146f5 100644
--- a/chrome/browser/autofill/autofill_popup_view.cc
+++ b/chrome/browser/autofill/autofill_popup_view.cc
@@ -5,12 +5,14 @@
#include "chrome/browser/autofill/autofill_popup_view.h"
#include "base/logging.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/autofill/autofill_external_delegate.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
+#include "grit/webkit_resources.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h"
using WebKit::WebAutofillClient;
@@ -20,6 +22,22 @@ namespace {
// Used to indicate that no line is currently selected by the user.
const int kNoSelection = -1;
+struct DataResource {
+ const char* name;
+ int id;
+};
+
+const DataResource kDataResources[] = {
+ { "americanExpressCC", IDR_AUTOFILL_CC_AMEX },
+ { "dinersCC", IDR_AUTOFILL_CC_DINERS },
+ { "discoverCC", IDR_AUTOFILL_CC_DISCOVER },
+ { "genericCC", IDR_AUTOFILL_CC_GENERIC },
+ { "jcbCC", IDR_AUTOFILL_CC_JCB },
+ { "masterCardCC", IDR_AUTOFILL_CC_MASTERCARD },
+ { "soloCC", IDR_AUTOFILL_CC_SOLO },
+ { "visaCC", IDR_AUTOFILL_CC_VISA },
+};
+
} // end namespace
AutofillPopupView::AutofillPopupView(
@@ -151,6 +169,15 @@ bool AutofillPopupView::IsSeparatorIndex(int index) {
autofill_unique_ids_[index] < 0);
}
+int AutofillPopupView::GetIconResourceID(const string16& resource_name) {
+ for (size_t i = 0; i < arraysize(kDataResources); ++i) {
+ if (resource_name == ASCIIToUTF16(kDataResources[i].name))
+ return kDataResources[i].id;
+ }
+
+ return -1;
+}
+
bool AutofillPopupView::CanDelete(int id) {
return id > 0 ||
id == WebAutofillClient::MenuItemIDAutocompleteEntry ||
diff --git a/chrome/browser/autofill/autofill_popup_view.h b/chrome/browser/autofill/autofill_popup_view.h
index 7d1771d..4fac024 100644
--- a/chrome/browser/autofill/autofill_popup_view.h
+++ b/chrome/browser/autofill/autofill_popup_view.h
@@ -92,6 +92,10 @@ class AutofillPopupView : public content::NotificationObserver {
// have a separator above it.
bool IsSeparatorIndex(int index);
+ // Get the resource value for the given resource, returning -1 if the
+ // resource isn't recognized.
+ int GetIconResourceID(const string16& resource_name);
+
private:
// Returns true if the given id refers to an element that can be deleted.
bool CanDelete(int id);