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

Side by Side Diff: chrome/browser/ui/views/location_bar/content_setting_image_view.cc

Issue 23557004: Save password bubble pops up automatically (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Readding UpdatePostLayout Created 7 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" 5 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
9 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" 9 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" 10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 slide_animator_.SetSlideDuration(kAnimationDurationMS); 88 slide_animator_.SetSlideDuration(kAnimationDurationMS);
89 slide_animator_.SetTweenType(ui::Tween::LINEAR); 89 slide_animator_.SetTweenType(ui::Tween::LINEAR);
90 } 90 }
91 91
92 ContentSettingImageView::~ContentSettingImageView() { 92 ContentSettingImageView::~ContentSettingImageView() {
93 if (bubble_widget_) 93 if (bubble_widget_)
94 bubble_widget_->RemoveObserver(this); 94 bubble_widget_->RemoveObserver(this);
95 } 95 }
96 96
97 void ContentSettingImageView::Update(content::WebContents* web_contents) { 97 void ContentSettingImageView::UpdatePreLayout(
98 content::WebContents* web_contents) {
98 // Note: We explicitly want to call this even if |web_contents| is NULL, so we 99 // Note: We explicitly want to call this even if |web_contents| is NULL, so we
99 // get hidden properly while the user is editing the omnibox. 100 // get hidden properly while the user is editing the omnibox.
100 content_setting_image_model_->UpdateFromWebContents(web_contents); 101 content_setting_image_model_->UpdateFromWebContents(web_contents);
101 102
102 if (!content_setting_image_model_->is_visible()) { 103 if (!content_setting_image_model_->is_visible()) {
103 SetVisible(false); 104 SetVisible(false);
104 return; 105 return;
105 } 106 }
106 107
107 icon_->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 108 icon_->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
(...skipping 12 matching lines...) Expand all
120 121
121 // We just ignore this blockage if we're already showing some other string to 122 // We just ignore this blockage if we're already showing some other string to
122 // the user. If this becomes a problem, we could design some sort of queueing 123 // the user. If this becomes a problem, we could design some sort of queueing
123 // mechanism to show one after the other, but it doesn't seem important now. 124 // mechanism to show one after the other, but it doesn't seem important now.
124 int string_id = content_setting_image_model_->explanatory_string_id(); 125 int string_id = content_setting_image_model_->explanatory_string_id();
125 if (string_id && !background_showing()) { 126 if (string_id && !background_showing()) {
126 text_label_->SetText(l10n_util::GetStringUTF16(string_id)); 127 text_label_->SetText(l10n_util::GetStringUTF16(string_id));
127 text_label_->SetVisible(true); 128 text_label_->SetVisible(true);
128 slide_animator_.Show(); 129 slide_animator_.Show();
129 } 130 }
131 }
130 132
131 content_settings->SetBlockageHasBeenIndicated( 133 void ContentSettingImageView::UpdatePostLayout(
132 content_setting_image_model_->get_content_settings_type()); 134 content::WebContents* web_contents) {
135 if (!content_setting_image_model_->is_visible())
136 return;
137
138 TabSpecificContentSettings* content_settings = web_contents ?
139 TabSpecificContentSettings::FromWebContents(web_contents) : NULL;
140 if (!content_settings)
141 return;
142 if (!content_settings->IsBlockageIndicated(
143 content_setting_image_model_->get_content_settings_type())) {
Peter Kasting 2013/09/04 20:59:11 Nit: Indent 4, not 9
npentrel 2013/09/04 21:50:18 Done.
144 if (content_setting_image_model_->ShouldShowBubbleOnBlockage()) {
145 if (web_contents && !bubble_widget_) {
Peter Kasting 2013/09/04 20:59:11 |web_contents| cannot be NULL here or we'd have re
npentrel 2013/09/04 21:50:18 true.
146 bubble_widget_ = parent_->delegate()->CreateViewsBubble(
147 new ContentSettingBubbleContents(
148 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
149 parent_->delegate()->GetContentSettingBubbleModelDelegate(),
150 web_contents, parent_->profile(),
151 content_setting_image_model_->get_content_settings_type()),
152 web_contents, this, views::BubbleBorder::TOP_RIGHT));
153 bubble_widget_->AddObserver(this);
154 bubble_widget_->Show();
155 }
156 content_settings->SetBlockageHasBeenIndicated(
Peter Kasting 2013/09/04 20:59:11 This statement is one layer too deep.
npentrel 2013/09/04 21:50:18 Done.
157 content_setting_image_model_->get_content_settings_type());
158 }
159 }
133 } 160 }
134 161
135 // static 162 // static
136 int ContentSettingImageView::GetBubbleOuterPadding(bool by_icon) { 163 int ContentSettingImageView::GetBubbleOuterPadding(bool by_icon) {
137 return LocationBarView::GetItemPadding() - LocationBarView::kBubblePadding + 164 return LocationBarView::GetItemPadding() - LocationBarView::kBubblePadding +
138 (by_icon ? 0 : LocationBarView::kIconInternalPadding); 165 (by_icon ? 0 : LocationBarView::kIconInternalPadding);
139 } 166 }
140 167
141 void ContentSettingImageView::AnimationEnded(const ui::Animation* animation) { 168 void ContentSettingImageView::AnimationEnded(const ui::Animation* animation) {
142 slide_animator_.Reset(); 169 slide_animator_.Reset();
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 parent_->delegate()->CreateViewsBubble(new ContentSettingBubbleContents( 277 parent_->delegate()->CreateViewsBubble(new ContentSettingBubbleContents(
251 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 278 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
252 parent_->delegate()->GetContentSettingBubbleModelDelegate(), 279 parent_->delegate()->GetContentSettingBubbleModelDelegate(),
253 web_contents, parent_->profile(), 280 web_contents, parent_->profile(),
254 content_setting_image_model_->get_content_settings_type()), 281 content_setting_image_model_->get_content_settings_type()),
255 web_contents, this, views::BubbleBorder::TOP_RIGHT)); 282 web_contents, this, views::BubbleBorder::TOP_RIGHT));
256 bubble_widget_->AddObserver(this); 283 bubble_widget_->AddObserver(this);
257 bubble_widget_->Show(); 284 bubble_widget_->Show();
258 } 285 }
259 } 286 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698