Commit ccdf38d1 authored by npentrel@chromium.org's avatar npentrel@chromium.org

Save password bubble pops up automatically when the save password icon is...

Save password bubble pops up automatically when the save password icon is triggered upon logging in to a page.

BUG=261628

Review URL: https://chromiumcodereview.appspot.com/23557004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221414 0039d316-1c4b-4281-b951-d872f2087c98
parent 62904287
...@@ -64,6 +64,7 @@ class ContentSettingSavePasswordImageModel : public ContentSettingImageModel { ...@@ -64,6 +64,7 @@ class ContentSettingSavePasswordImageModel : public ContentSettingImageModel {
ContentSettingSavePasswordImageModel(); ContentSettingSavePasswordImageModel();
virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE;
virtual bool ShouldShowBubbleOnBlockage() OVERRIDE;
}; };
namespace { namespace {
...@@ -233,6 +234,10 @@ void ContentSettingSavePasswordImageModel::UpdateFromWebContents( ...@@ -233,6 +234,10 @@ void ContentSettingSavePasswordImageModel::UpdateFromWebContents(
} }
} }
bool ContentSettingSavePasswordImageModel::ShouldShowBubbleOnBlockage() {
return true;
}
ContentSettingMediaImageModel::ContentSettingMediaImageModel( ContentSettingMediaImageModel::ContentSettingMediaImageModel(
ContentSettingsType type) ContentSettingsType type)
: ContentSettingImageModel(type) { : ContentSettingImageModel(type) {
...@@ -377,6 +382,10 @@ ContentSettingImageModel::ContentSettingImageModel( ...@@ -377,6 +382,10 @@ ContentSettingImageModel::ContentSettingImageModel(
explanatory_string_id_(0) { explanatory_string_id_(0) {
} }
bool ContentSettingImageModel::ShouldShowBubbleOnBlockage() {
return false;
}
// static // static
ContentSettingImageModel* ContentSettingImageModel*
ContentSettingImageModel::CreateContentSettingImageModel( ContentSettingImageModel::CreateContentSettingImageModel(
......
...@@ -28,6 +28,10 @@ class ContentSettingImageModel { ...@@ -28,6 +28,10 @@ class ContentSettingImageModel {
// update its visibility, icon and tooltip. // update its visibility, icon and tooltip.
virtual void UpdateFromWebContents(content::WebContents* web_contents) = 0; virtual void UpdateFromWebContents(content::WebContents* web_contents) = 0;
// Returns true if the icon should automatically show its bubble as part of
// indicating that the relevant content was blocked.
virtual bool ShouldShowBubbleOnBlockage();
ContentSettingsType get_content_settings_type() const { ContentSettingsType get_content_settings_type() const {
return content_settings_type_; return content_settings_type_;
} }
......
...@@ -94,7 +94,8 @@ ContentSettingImageView::~ContentSettingImageView() { ...@@ -94,7 +94,8 @@ ContentSettingImageView::~ContentSettingImageView() {
bubble_widget_->RemoveObserver(this); bubble_widget_->RemoveObserver(this);
} }
void ContentSettingImageView::Update(content::WebContents* web_contents) { void ContentSettingImageView::UpdatePreLayout(
content::WebContents* web_contents) {
// Note: We explicitly want to call this even if |web_contents| is NULL, so we // Note: We explicitly want to call this even if |web_contents| is NULL, so we
// get hidden properly while the user is editing the omnibox. // get hidden properly while the user is editing the omnibox.
content_setting_image_model_->UpdateFromWebContents(web_contents); content_setting_image_model_->UpdateFromWebContents(web_contents);
...@@ -127,9 +128,29 @@ void ContentSettingImageView::Update(content::WebContents* web_contents) { ...@@ -127,9 +128,29 @@ void ContentSettingImageView::Update(content::WebContents* web_contents) {
text_label_->SetVisible(true); text_label_->SetVisible(true);
slide_animator_.Show(); slide_animator_.Show();
} }
// Since indicating blockage may include showing a bubble, which must be done
// in UpdatePostLayout() in order for the bubble to have the right anchor
// coordinates, we delay calling SetBlockageHasBeeenIndicated() until that
// function completes.
}
void ContentSettingImageView::UpdatePostLayout(
content::WebContents* web_contents) {
if (!content_setting_image_model_->is_visible())
return;
TabSpecificContentSettings* content_settings = web_contents ?
TabSpecificContentSettings::FromWebContents(web_contents) : NULL;
if (!content_settings)
return;
content_settings->SetBlockageHasBeenIndicated( if (!content_settings->IsBlockageIndicated(
content_setting_image_model_->get_content_settings_type()); content_setting_image_model_->get_content_settings_type())) {
if (content_setting_image_model_->ShouldShowBubbleOnBlockage())
CreateBubble(web_contents);
content_settings->SetBlockageHasBeenIndicated(
content_setting_image_model_->get_content_settings_type());
}
} }
// static // static
...@@ -246,14 +267,19 @@ void ContentSettingImageView::OnClick() { ...@@ -246,14 +267,19 @@ void ContentSettingImageView::OnClick() {
content::WebContents* web_contents = parent_->GetWebContents(); content::WebContents* web_contents = parent_->GetWebContents();
if (web_contents && !bubble_widget_) { if (web_contents && !bubble_widget_) {
bubble_widget_ = CreateBubble(web_contents);
parent_->delegate()->CreateViewsBubble(new ContentSettingBubbleContents(
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
parent_->delegate()->GetContentSettingBubbleModelDelegate(),
web_contents, parent_->profile(),
content_setting_image_model_->get_content_settings_type()),
web_contents, this, views::BubbleBorder::TOP_RIGHT));
bubble_widget_->AddObserver(this);
bubble_widget_->Show();
} }
} }
void ContentSettingImageView::CreateBubble(content::WebContents* web_contents) {
bubble_widget_ =
parent_->delegate()->CreateViewsBubble(new ContentSettingBubbleContents(
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
parent_->delegate()->GetContentSettingBubbleModelDelegate(),
web_contents, parent_->profile(),
content_setting_image_model_->get_content_settings_type()),
web_contents, this, views::BubbleBorder::TOP_RIGHT));
bubble_widget_->AddObserver(this);
bubble_widget_->Show();
}
...@@ -41,8 +41,12 @@ class ContentSettingImageView : public ui::AnimationDelegate, ...@@ -41,8 +41,12 @@ class ContentSettingImageView : public ui::AnimationDelegate,
SkColor parent_background_color); SkColor parent_background_color);
virtual ~ContentSettingImageView(); virtual ~ContentSettingImageView();
// Update the decoration from the shown WebContents. // Updates the decoration from the shown WebContents.
void Update(content::WebContents* web_contents); void UpdatePreLayout(content::WebContents* web_contents);
// Performs any updates which depend on the image having already been laid out
// by the owning LocationBarView.
void UpdatePostLayout(content::WebContents* web_contents);
private: private:
// Number of milliseconds spent animating open; also the time spent animating // Number of milliseconds spent animating open; also the time spent animating
...@@ -82,6 +86,7 @@ class ContentSettingImageView : public ui::AnimationDelegate, ...@@ -82,6 +86,7 @@ class ContentSettingImageView : public ui::AnimationDelegate,
int GetTotalSpacingWhileAnimating() const; int GetTotalSpacingWhileAnimating() const;
void OnClick(); void OnClick();
void CreateBubble(content::WebContents* web_contents);
LocationBarView* parent_; // Weak, owns us. LocationBarView* parent_; // Weak, owns us.
scoped_ptr<ContentSettingImageModel> content_setting_image_model_; scoped_ptr<ContentSettingImageModel> content_setting_image_model_;
......
...@@ -385,8 +385,6 @@ void LocationBarView::Init() { ...@@ -385,8 +385,6 @@ void LocationBarView::Init() {
// Initialize the location entry. We do this to avoid a black flash which is // Initialize the location entry. We do this to avoid a black flash which is
// visible when the location entry has just been initialized. // visible when the location entry has just been initialized.
Update(NULL); Update(NULL);
OnChanged();
} }
bool LocationBarView::IsInitialized() const { bool LocationBarView::IsInitialized() const {
...@@ -498,7 +496,7 @@ void LocationBarView::Update(const WebContents* contents) { ...@@ -498,7 +496,7 @@ void LocationBarView::Update(const WebContents* contents) {
mic_search_view_->SetVisible( mic_search_view_->SetVisible(
!GetToolbarModel()->input_in_progress() && browser_ && !GetToolbarModel()->input_in_progress() && browser_ &&
browser_->search_model()->voice_search_supported()); browser_->search_model()->voice_search_supported());
RefreshContentSettingViews(); UpdateContentSettingViewsPreLayout();
generated_credit_card_view_->Update(); generated_credit_card_view_->Update();
ZoomBubbleView::CloseBubble(); ZoomBubbleView::CloseBubble();
RefreshZoomView(); RefreshZoomView();
...@@ -522,13 +520,14 @@ void LocationBarView::Update(const WebContents* contents) { ...@@ -522,13 +520,14 @@ void LocationBarView::Update(const WebContents* contents) {
else else
location_entry_->Update(); location_entry_->Update();
OnChanged(); OnChanged(); // NOTE: Calls Layout().
UpdateContentSettingViewsPostLayout();
} }
void LocationBarView::UpdateContentSettingsIcons() { void LocationBarView::UpdateContentSettingsIcons() {
RefreshContentSettingViews(); UpdateContentSettingViewsPreLayout();
Layout(); Layout();
UpdateContentSettingViewsPostLayout();
SchedulePaint(); SchedulePaint();
} }
...@@ -1134,10 +1133,18 @@ int LocationBarView::GetHorizontalEdgeThickness() const { ...@@ -1134,10 +1133,18 @@ int LocationBarView::GetHorizontalEdgeThickness() const {
browser_->window()->IsMaximized()) ? 0 : vertical_edge_thickness(); browser_->window()->IsMaximized()) ? 0 : vertical_edge_thickness();
} }
void LocationBarView::RefreshContentSettingViews() { void LocationBarView::UpdateContentSettingViewsPreLayout() {
for (ContentSettingViews::const_iterator i(content_setting_views_.begin());
i != content_setting_views_.end(); ++i) {
(*i)->UpdatePreLayout(GetToolbarModel()->input_in_progress() ?
NULL : GetWebContents());
}
}
void LocationBarView::UpdateContentSettingViewsPostLayout() {
for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); for (ContentSettingViews::const_iterator i(content_setting_views_.begin());
i != content_setting_views_.end(); ++i) { i != content_setting_views_.end(); ++i) {
(*i)->Update(GetToolbarModel()->input_in_progress() ? (*i)->UpdatePostLayout(GetToolbarModel()->input_in_progress() ?
NULL : GetWebContents()); NULL : GetWebContents());
} }
} }
......
...@@ -383,9 +383,18 @@ class LocationBarView : public LocationBar, ...@@ -383,9 +383,18 @@ class LocationBarView : public LocationBar,
return is_popup_mode_ ? kPopupEdgeThickness : kNormalEdgeThickness; return is_popup_mode_ ? kPopupEdgeThickness : kNormalEdgeThickness;
} }
// Update the visibility state of the Content Blocked icons to reflect what is // Updates the visibility state of the Content Blocked icons to reflect what
// actually blocked on the current page. // is actually blocked on the current page. Calling this function should
void RefreshContentSettingViews(); // always eventually be followed by calling Layout() and then
// UpdateContentSettingViewsPostLayout(), to ensure the icons can completely
// update their states.
void UpdateContentSettingViewsPreLayout();
// Updates after the correct screen coordinates have been set for icons.
// Allows content setting icons to perform any updating which can't complete
// until after the icons have been correctly laid out. This should be called
// after UpdateContentSettingViewsPreLayout() and a subsequent Layout().
void UpdateContentSettingViewsPostLayout();
// Delete all page action views that we have created. // Delete all page action views that we have created.
void DeletePageActionViews(); void DeletePageActionViews();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment