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/utf_string_conversions.h" | 7 #include "base/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/browser.h" |
9 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 10 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 11 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
12 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" | 13 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" |
13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
14 #include "chrome/browser/ui/views/window.h" | 15 #include "chrome/browser/ui/views/window.h" |
15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
16 #include "third_party/skia/include/core/SkShader.h" | 17 #include "third_party/skia/include/core/SkShader.h" |
17 #include "ui/base/animation/slide_animation.h" | 18 #include "ui/base/animation/slide_animation.h" |
18 #include "ui/base/animation/tween.h" | 19 #include "ui/base/animation/tween.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 TabContentsWrapper* tab_contents = parent_->GetTabContentsWrapper(); | 171 TabContentsWrapper* tab_contents = parent_->GetTabContentsWrapper(); |
171 if (!tab_contents) | 172 if (!tab_contents) |
172 return; | 173 return; |
173 | 174 |
174 // Stop animation. | 175 // Stop animation. |
175 if (slide_animator_.get() && slide_animator_->is_animating()) { | 176 if (slide_animator_.get() && slide_animator_->is_animating()) { |
176 slide_animator_->Reset(); | 177 slide_animator_->Reset(); |
177 pause_animation_ = true; | 178 pause_animation_ = true; |
178 } | 179 } |
179 | 180 |
180 Profile* profile = parent_->profile(); | 181 Profile* profile = parent_->browser()->profile(); |
181 ContentSettingBubbleContents* bubble = new ContentSettingBubbleContents( | 182 ContentSettingBubbleContents* bubble = new ContentSettingBubbleContents( |
182 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 183 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
183 parent_->delegate()->GetContentSettingBubbleModelDelegate(), | 184 parent_->browser(), |
184 tab_contents, | 185 tab_contents, |
185 profile, | 186 profile, |
186 content_setting_image_model_->get_content_settings_type()), | 187 content_setting_image_model_->get_content_settings_type()), |
187 profile, | 188 profile, |
188 tab_contents->web_contents(), | 189 tab_contents->web_contents(), |
189 this, | 190 this, |
190 views::BubbleBorder::TOP_RIGHT); | 191 views::BubbleBorder::TOP_RIGHT); |
191 bubble_widget_ = parent_->delegate()->CreateViewsBubble(bubble); | 192 bubble_widget_ = browser::CreateViewsBubble(bubble); |
192 bubble_widget_->AddObserver(this); | 193 bubble_widget_->AddObserver(this); |
193 bubble->Show(); | 194 bubble->Show(); |
194 } | 195 } |
195 | 196 |
196 void ContentSettingImageView::OnPaint(gfx::Canvas* canvas) { | 197 void ContentSettingImageView::OnPaint(gfx::Canvas* canvas) { |
197 // During the animation we draw a border, an icon and the text. The text area | 198 // During the animation we draw a border, an icon and the text. The text area |
198 // is changing in size during the animation, giving the appearance of the text | 199 // is changing in size during the animation, giving the appearance of the text |
199 // sliding out and then back in. When the text completely slid out the yellow | 200 // sliding out and then back in. When the text completely slid out the yellow |
200 // border is no longer painted around the icon. |visible_text_size_| is 0 when | 201 // border is no longer painted around the icon. |visible_text_size_| is 0 when |
201 // animation is stopped. | 202 // animation is stopped. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 bubble_widget_->RemoveObserver(this); | 258 bubble_widget_->RemoveObserver(this); |
258 bubble_widget_ = NULL; | 259 bubble_widget_ = NULL; |
259 } | 260 } |
260 if (pause_animation_) { | 261 if (pause_animation_) { |
261 slide_animator_->Reset( | 262 slide_animator_->Reset( |
262 1.0 - (visible_text_size_ * kAnimatingFraction) / text_size_); | 263 1.0 - (visible_text_size_ * kAnimatingFraction) / text_size_); |
263 pause_animation_ = false; | 264 pause_animation_ = false; |
264 slide_animator_->Show(); | 265 slide_animator_->Show(); |
265 } | 266 } |
266 } | 267 } |
OLD | NEW |