| 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/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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 // The fraction of the animation we'll spend animating the string into view, and | 34 // The fraction of the animation we'll spend animating the string into view, and |
| 35 // then again animating it closed - total animation (slide out, show, then | 35 // then again animating it closed - total animation (slide out, show, then |
| 36 // slide in) is 1.0. | 36 // slide in) is 1.0. |
| 37 const double kAnimatingFraction = kOpenTimeMs * 1.0 / kMoveTimeMs; | 37 const double kAnimatingFraction = kOpenTimeMs * 1.0 / kMoveTimeMs; |
| 38 } | 38 } |
| 39 | 39 |
| 40 ContentSettingImageView::ContentSettingImageView( | 40 ContentSettingImageView::ContentSettingImageView( |
| 41 ContentSettingsType content_type, | 41 ContentSettingsType content_type, |
| 42 const int background_images[], | 42 const int background_images[], |
| 43 LocationBarView* parent) | 43 LocationBarView* parent, |
| 44 : LocationBarDecorationView(parent, background_images), | 44 const gfx::Font& font, |
| 45 SkColor font_color) |
| 46 : LocationBarDecorationView(parent, background_images, font, font_color), |
| 45 content_setting_image_model_( | 47 content_setting_image_model_( |
| 46 ContentSettingImageModel::CreateContentSettingImageModel( | 48 ContentSettingImageModel::CreateContentSettingImageModel( |
| 47 content_type)), | 49 content_type)), |
| 48 bubble_widget_(NULL) { | 50 bubble_widget_(NULL) { |
| 49 SetHorizontalAlignment(ImageView::LEADING); | |
| 50 TouchableLocationBarView::Init(this); | |
| 51 } | 51 } |
| 52 | 52 |
| 53 ContentSettingImageView::~ContentSettingImageView() { | 53 ContentSettingImageView::~ContentSettingImageView() { |
| 54 if (bubble_widget_) { | 54 if (bubble_widget_) { |
| 55 bubble_widget_->RemoveObserver(this); | 55 bubble_widget_->RemoveObserver(this); |
| 56 bubble_widget_ = NULL; | 56 bubble_widget_ = NULL; |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 void ContentSettingImageView::Update(TabContents* tab_contents) { | 60 void ContentSettingImageView::Update(TabContents* tab_contents) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 88 content_setting_image_model_->explanatory_string_id(); | 88 content_setting_image_model_->explanatory_string_id(); |
| 89 // Check if the string for animation is available. | 89 // Check if the string for animation is available. |
| 90 if (!animated_string_id) | 90 if (!animated_string_id) |
| 91 return; | 91 return; |
| 92 | 92 |
| 93 StartLabelAnimation(l10n_util::GetStringUTF16(animated_string_id), | 93 StartLabelAnimation(l10n_util::GetStringUTF16(animated_string_id), |
| 94 kMoveTimeMs); | 94 kMoveTimeMs); |
| 95 } | 95 } |
| 96 | 96 |
| 97 int ContentSettingImageView::GetTextAnimationSize(double state, | 97 int ContentSettingImageView::GetTextAnimationSize(double state, |
| 98 int text_size) { | 98 int text_size) { |
| 99 if (state >= 1.0) { | 99 if (state >= 1.0) { |
| 100 // Animaton is over, clear the variables. | 100 // Animaton is over, clear the variables. |
| 101 return 0; | 101 return 0; |
| 102 } else if (state < kAnimatingFraction) { | 102 } else if (state < kAnimatingFraction) { |
| 103 return static_cast<int>(text_size * state / kAnimatingFraction); | 103 return static_cast<int>(text_size * state / kAnimatingFraction); |
| 104 } else if (state > (1.0 - kAnimatingFraction)) { | 104 } else if (state > (1.0 - kAnimatingFraction)) { |
| 105 return static_cast<int>(text_size * (1.0 - state) / kAnimatingFraction); | 105 return static_cast<int>(text_size * (1.0 - state) / kAnimatingFraction); |
| 106 } else { | 106 } else { |
| 107 return text_size; | 107 return text_size; |
| 108 } | 108 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 131 tab_contents, | 131 tab_contents, |
| 132 profile, | 132 profile, |
| 133 content_setting_image_model_->get_content_settings_type()), | 133 content_setting_image_model_->get_content_settings_type()), |
| 134 tab_contents->web_contents(), | 134 tab_contents->web_contents(), |
| 135 this, | 135 this, |
| 136 views::BubbleBorder::TOP_RIGHT); | 136 views::BubbleBorder::TOP_RIGHT); |
| 137 bubble_widget_ = parent->delegate()->CreateViewsBubble(bubble); | 137 bubble_widget_ = parent->delegate()->CreateViewsBubble(bubble); |
| 138 bubble_widget_->AddObserver(this); | 138 bubble_widget_->AddObserver(this); |
| 139 bubble->Show(); | 139 bubble->Show(); |
| 140 } | 140 } |
| OLD | NEW |