OLD | NEW |
---|---|
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 Loading... | |
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::UpdatePostLayout( |
Peter Kasting
2013/09/03 23:50:43
Function definition order needs to match declarati
npentrel
2013/09/04 09:55:36
Done.
| |
98 content::WebContents* web_contents) { | |
99 if (!content_setting_image_model_->is_visible()) { | |
Peter Kasting
2013/09/03 23:50:43
Nit: No {}
npentrel
2013/09/04 09:55:36
Done.
| |
100 return; | |
101 } | |
102 | |
103 TabSpecificContentSettings* content_settings = web_contents ? | |
Peter Kasting
2013/09/03 23:50:43
Nit: This should be done inside the below conditio
npentrel
2013/09/04 09:55:36
Done.
| |
104 TabSpecificContentSettings::FromWebContents(web_contents) : NULL; | |
105 | |
106 if (content_setting_image_model_->get_content_settings_type() == | |
107 CONTENT_SETTINGS_TYPE_SAVE_PASSWORD) { | |
Peter Kasting
2013/09/03 23:50:43
It would be nice if this was more generic than "is
npentrel
2013/09/04 09:55:36
Done.
| |
108 if (!content_settings->IsBlockageIndicated( | |
109 content_setting_image_model_->get_content_settings_type())) { | |
110 if (web_contents && !bubble_widget_) { | |
111 bubble_widget_ = parent_->delegate()->CreateViewsBubble( | |
112 new ContentSettingBubbleContents( | |
113 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | |
114 parent_->delegate()->GetContentSettingBubbleModelDelegate(), | |
115 web_contents, parent_->profile(), | |
116 content_setting_image_model_->get_content_settings_type()), | |
117 web_contents, this, views::BubbleBorder::TOP_RIGHT)); | |
118 bubble_widget_->AddObserver(this); | |
119 bubble_widget_->Show(); | |
120 } | |
121 content_settings->SetBlockageHasBeenIndicated( | |
122 content_setting_image_model_->get_content_settings_type()); | |
123 } | |
124 } | |
125 } | |
126 | |
127 void ContentSettingImageView::UpdatePreLayout( | |
128 content::WebContents* web_contents) { | |
98 // Note: We explicitly want to call this even if |web_contents| is NULL, so we | 129 // 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. | 130 // get hidden properly while the user is editing the omnibox. |
100 content_setting_image_model_->UpdateFromWebContents(web_contents); | 131 content_setting_image_model_->UpdateFromWebContents(web_contents); |
101 | 132 |
102 if (!content_setting_image_model_->is_visible()) { | 133 if (!content_setting_image_model_->is_visible()) { |
103 SetVisible(false); | 134 SetVisible(false); |
104 return; | 135 return; |
105 } | 136 } |
106 | 137 |
107 icon_->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 138 icon_->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
(...skipping 13 matching lines...) Expand all Loading... | |
121 // We just ignore this blockage if we're already showing some other string to | 152 // 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 | 153 // 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. | 154 // 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(); | 155 int string_id = content_setting_image_model_->explanatory_string_id(); |
125 if (string_id && !background_showing()) { | 156 if (string_id && !background_showing()) { |
126 text_label_->SetText(l10n_util::GetStringUTF16(string_id)); | 157 text_label_->SetText(l10n_util::GetStringUTF16(string_id)); |
127 text_label_->SetVisible(true); | 158 text_label_->SetVisible(true); |
128 slide_animator_.Show(); | 159 slide_animator_.Show(); |
129 } | 160 } |
130 | 161 |
131 content_settings->SetBlockageHasBeenIndicated( | 162 // The blockage for |CONTENT_SETTINGS_TYPE_SAVE_PASSWORD| is set once the |
132 content_setting_image_model_->get_content_settings_type()); | 163 // bubble pops up. |
Peter Kasting
2013/09/03 23:50:43
Nit: Say why, not what. This comment currently ju
npentrel
2013/09/04 09:55:36
Done.
| |
164 if (content_setting_image_model_->get_content_settings_type() != | |
165 CONTENT_SETTINGS_TYPE_SAVE_PASSWORD) { | |
166 content_settings->SetBlockageHasBeenIndicated( | |
167 content_setting_image_model_->get_content_settings_type()); | |
Peter Kasting
2013/09/03 23:50:43
I wonder if for consistency's sake, we should move
npentrel
2013/09/04 09:55:36
Done.
| |
168 } | |
133 } | 169 } |
134 | 170 |
135 // static | 171 // static |
136 int ContentSettingImageView::GetBubbleOuterPadding(bool by_icon) { | 172 int ContentSettingImageView::GetBubbleOuterPadding(bool by_icon) { |
137 return LocationBarView::GetItemPadding() - LocationBarView::kBubblePadding + | 173 return LocationBarView::GetItemPadding() - LocationBarView::kBubblePadding + |
138 (by_icon ? 0 : LocationBarView::kIconInternalPadding); | 174 (by_icon ? 0 : LocationBarView::kIconInternalPadding); |
139 } | 175 } |
140 | 176 |
141 void ContentSettingImageView::AnimationEnded(const ui::Animation* animation) { | 177 void ContentSettingImageView::AnimationEnded(const ui::Animation* animation) { |
142 slide_animator_.Reset(); | 178 slide_animator_.Reset(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 parent_->delegate()->CreateViewsBubble(new ContentSettingBubbleContents( | 286 parent_->delegate()->CreateViewsBubble(new ContentSettingBubbleContents( |
251 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 287 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
252 parent_->delegate()->GetContentSettingBubbleModelDelegate(), | 288 parent_->delegate()->GetContentSettingBubbleModelDelegate(), |
253 web_contents, parent_->profile(), | 289 web_contents, parent_->profile(), |
254 content_setting_image_model_->get_content_settings_type()), | 290 content_setting_image_model_->get_content_settings_type()), |
255 web_contents, this, views::BubbleBorder::TOP_RIGHT)); | 291 web_contents, this, views::BubbleBorder::TOP_RIGHT)); |
256 bubble_widget_->AddObserver(this); | 292 bubble_widget_->AddObserver(this); |
257 bubble_widget_->Show(); | 293 bubble_widget_->Show(); |
258 } | 294 } |
259 } | 295 } |
OLD | NEW |