| 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" | |
| 10 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 9 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| 11 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 13 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" | 12 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" |
| 14 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 15 #include "chrome/browser/ui/views/window.h" | 14 #include "chrome/browser/ui/views/window.h" |
| 16 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 17 #include "third_party/skia/include/core/SkShader.h" | 16 #include "third_party/skia/include/core/SkShader.h" |
| 18 #include "ui/base/animation/slide_animation.h" | 17 #include "ui/base/animation/slide_animation.h" |
| 19 #include "ui/base/animation/tween.h" | 18 #include "ui/base/animation/tween.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 TabContentsWrapper* tab_contents = parent_->GetTabContentsWrapper(); | 171 TabContentsWrapper* tab_contents = parent_->GetTabContentsWrapper(); |
| 173 if (!tab_contents) | 172 if (!tab_contents) |
| 174 return; | 173 return; |
| 175 | 174 |
| 176 // Stop animation. | 175 // Stop animation. |
| 177 if (slide_animator_.get() && slide_animator_->is_animating()) { | 176 if (slide_animator_.get() && slide_animator_->is_animating()) { |
| 178 slide_animator_->Reset(); | 177 slide_animator_->Reset(); |
| 179 pause_animation_ = true; | 178 pause_animation_ = true; |
| 180 } | 179 } |
| 181 | 180 |
| 182 Profile* profile = parent_->browser()->profile(); | 181 Profile* profile = parent_->profile(); |
| 183 ContentSettingBubbleContents* bubble = new ContentSettingBubbleContents( | 182 ContentSettingBubbleContents* bubble = new ContentSettingBubbleContents( |
| 184 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 183 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 185 parent_->browser(), | 184 parent_->delegate()->GetContentSettingBubbleModelDelegate(), |
| 186 tab_contents, | 185 tab_contents, |
| 187 profile, | 186 profile, |
| 188 content_setting_image_model_->get_content_settings_type()), | 187 content_setting_image_model_->get_content_settings_type()), |
| 189 profile, | 188 profile, |
| 190 tab_contents->web_contents(), | 189 tab_contents->web_contents(), |
| 191 this, | 190 this, |
| 192 views::BubbleBorder::TOP_RIGHT); | 191 views::BubbleBorder::TOP_RIGHT); |
| 193 bubble_widget_ = browser::CreateViewsBubble(bubble); | 192 bubble_widget_ = parent_->delegate()->CreateViewsBubble(bubble); |
| 194 bubble_widget_->AddObserver(this); | 193 bubble_widget_->AddObserver(this); |
| 195 bubble->Show(); | 194 bubble->Show(); |
| 196 } | 195 } |
| 197 | 196 |
| 198 void ContentSettingImageView::OnPaint(gfx::Canvas* canvas) { | 197 void ContentSettingImageView::OnPaint(gfx::Canvas* canvas) { |
| 199 // 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 |
| 200 // 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 |
| 201 // 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 |
| 202 // 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 |
| 203 // animation is stopped. | 202 // animation is stopped. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 bubble_widget_->RemoveObserver(this); | 258 bubble_widget_->RemoveObserver(this); |
| 260 bubble_widget_ = NULL; | 259 bubble_widget_ = NULL; |
| 261 } | 260 } |
| 262 if (pause_animation_) { | 261 if (pause_animation_) { |
| 263 slide_animator_->Reset( | 262 slide_animator_->Reset( |
| 264 1.0 - (visible_text_size_ * kAnimatingFraction) / text_size_); | 263 1.0 - (visible_text_size_ * kAnimatingFraction) / text_size_); |
| 265 pause_animation_ = false; | 264 pause_animation_ = false; |
| 266 slide_animator_->Show(); | 265 slide_animator_->Show(); |
| 267 } | 266 } |
| 268 } | 267 } |
| OLD | NEW |