Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5114)

Unified Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 1396923003: Autofill: Replace "save credit card" infobar with a bubble (Views only). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak SaveCardBubbleControllerImpl::DidNavigateMainFrame logic. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/location_bar/location_bar_view.cc
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index 423a35ded026a266405cc9d08a617d387251c25f..17c7e47662719e01d29ebb10fd8bb01a6c78d921 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -27,6 +27,7 @@
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/translate/chrome_translate_client.h"
#include "chrome/browser/translate/translate_service.h"
+#include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_instant_controller.h"
@@ -45,6 +46,7 @@
#include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h"
#include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
#include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h"
+#include "chrome/browser/ui/views/location_bar/save_credit_card_icon_view.h"
#include "chrome/browser/ui/views/location_bar/selected_keyword_view.h"
#include "chrome/browser/ui/views/location_bar/star_view.h"
#include "chrome/browser/ui/views/location_bar/translate_icon_view.h"
@@ -143,6 +145,7 @@ LocationBarView::LocationBarView(Browser* browser,
zoom_view_(NULL),
open_pdf_in_reader_view_(NULL),
manage_passwords_icon_view_(NULL),
+ save_credit_card_icon_view_(NULL),
sky 2015/10/26 20:56:26 nullptr
bondd 2015/10/27 01:06:39 Done. I had originally used NULL to match the surr
translate_icon_view_(NULL),
star_view_(NULL),
size_animation_(this),
@@ -307,6 +310,11 @@ void LocationBarView::Init() {
manage_passwords_icon_view_ = new ManagePasswordsIconViews(command_updater());
AddChildView(manage_passwords_icon_view_);
+ save_credit_card_icon_view_ =
+ new SaveCreditCardIconView(command_updater(), browser_);
+ save_credit_card_icon_view_->SetVisible(false);
+ AddChildView(save_credit_card_icon_view_);
+
translate_icon_view_ = new TranslateIconView(command_updater());
translate_icon_view_->SetVisible(false);
AddChildView(translate_icon_view_);
@@ -573,6 +581,7 @@ gfx::Size LocationBarView::GetPreferredSize() const {
trailing_width += IncrementalMinimumWidth(star_view_) +
IncrementalMinimumWidth(translate_icon_view_) +
IncrementalMinimumWidth(open_pdf_in_reader_view_) +
+ IncrementalMinimumWidth(save_credit_card_icon_view_) +
IncrementalMinimumWidth(manage_passwords_icon_view_) +
IncrementalMinimumWidth(zoom_view_) +
IncrementalMinimumWidth(mic_search_view_);
@@ -671,6 +680,10 @@ void LocationBarView::Layout() {
trailing_decorations.AddDecoration(vertical_padding, location_height,
open_pdf_in_reader_view_);
}
+ if (save_credit_card_icon_view_->visible()) {
+ trailing_decorations.AddDecoration(vertical_padding, location_height,
+ save_credit_card_icon_view_);
+ }
if (manage_passwords_icon_view_->visible()) {
trailing_decorations.AddDecoration(vertical_padding, location_height,
manage_passwords_icon_view_);
@@ -816,6 +829,7 @@ void LocationBarView::Update(const WebContents* contents) {
RefreshZoomView();
RefreshPageActionViews();
RefreshTranslateIcon();
+ RefreshSaveCreditCardIconView();
RefreshManagePasswordsIconView();
content::WebContents* web_contents_for_sub_views =
GetToolbarModel()->input_in_progress() ? NULL : GetWebContents();
@@ -989,6 +1003,25 @@ void LocationBarView::OnDefaultZoomLevelChanged() {
RefreshZoomView();
}
+bool LocationBarView::RefreshSaveCreditCardIconView() {
+ WebContents* web_contents = GetWebContents();
+ if (!web_contents)
+ return false;
+
+ const bool was_visible = save_credit_card_icon_view_->visible();
+ // |controller| may be nullptr due to lazy initialization.
+ autofill::SaveCardBubbleControllerImpl* controller =
+ autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents);
+ bool enabled = controller && controller->IsIconVisible();
+ command_updater()->UpdateCommandEnabled(IDC_SAVE_CREDIT_CARD_FOR_PAGE,
+ enabled);
+ save_credit_card_icon_view_->SetVisible(enabled);
+ if (enabled)
+ save_credit_card_icon_view_->SetToggled(controller->IsIconToggled());
+
+ return was_visible != save_credit_card_icon_view_->visible();
+}
+
void LocationBarView::RefreshTranslateIcon() {
WebContents* web_contents = GetWebContents();
if (!web_contents)
@@ -1094,6 +1127,13 @@ void LocationBarView::UpdateManagePasswordsIconAndBubble() {
}
}
+void LocationBarView::UpdateSaveCreditCardIcon() {
+ if (RefreshSaveCreditCardIconView()) {
+ Layout();
+ SchedulePaint();
+ }
+}
+
void LocationBarView::UpdatePageActions() {
if (RefreshPageActionViews()) { // Changed.
Layout();

Powered by Google App Engine
This is Rietveld 408576698