| 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 28 matching lines...) Expand all Loading... |
| 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 : LocationBarDecorationView(parent, background_images), |
| 45 content_setting_image_model_( | 45 content_setting_image_model_( |
| 46 ContentSettingImageModel::CreateContentSettingImageModel( | 46 ContentSettingImageModel::CreateContentSettingImageModel( |
| 47 content_type)), | 47 content_type)), |
| 48 bubble_widget_(NULL) { | 48 bubble_widget_(NULL) { |
| 49 SetHorizontalAlignment(ImageView::LEADING); | |
| 50 TouchableLocationBarView::Init(this); | |
| 51 } | 49 } |
| 52 | 50 |
| 53 ContentSettingImageView::~ContentSettingImageView() { | 51 ContentSettingImageView::~ContentSettingImageView() { |
| 54 if (bubble_widget_) { | 52 if (bubble_widget_) { |
| 55 bubble_widget_->RemoveObserver(this); | 53 bubble_widget_->RemoveObserver(this); |
| 56 bubble_widget_ = NULL; | 54 bubble_widget_ = NULL; |
| 57 } | 55 } |
| 58 } | 56 } |
| 59 | 57 |
| 60 void ContentSettingImageView::Update(TabContents* tab_contents) { | 58 void ContentSettingImageView::Update(TabContents* tab_contents) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 88 content_setting_image_model_->explanatory_string_id(); | 86 content_setting_image_model_->explanatory_string_id(); |
| 89 // Check if the string for animation is available. | 87 // Check if the string for animation is available. |
| 90 if (!animated_string_id) | 88 if (!animated_string_id) |
| 91 return; | 89 return; |
| 92 | 90 |
| 93 StartLabelAnimation(l10n_util::GetStringUTF16(animated_string_id), | 91 StartLabelAnimation(l10n_util::GetStringUTF16(animated_string_id), |
| 94 kMoveTimeMs); | 92 kMoveTimeMs); |
| 95 } | 93 } |
| 96 | 94 |
| 97 int ContentSettingImageView::GetTextAnimationSize(double state, | 95 int ContentSettingImageView::GetTextAnimationSize(double state, |
| 98 int text_size) { | 96 int text_size) { |
| 99 if (state >= 1.0) { | 97 if (state >= 1.0) { |
| 100 // Animaton is over, clear the variables. | 98 // Animaton is over, clear the variables. |
| 101 return 0; | 99 return 0; |
| 102 } else if (state < kAnimatingFraction) { | 100 } else if (state < kAnimatingFraction) { |
| 103 return static_cast<int>(text_size * state / kAnimatingFraction); | 101 return static_cast<int>(text_size * state / kAnimatingFraction); |
| 104 } else if (state > (1.0 - kAnimatingFraction)) { | 102 } else if (state > (1.0 - kAnimatingFraction)) { |
| 105 return static_cast<int>(text_size * (1.0 - state) / kAnimatingFraction); | 103 return static_cast<int>(text_size * (1.0 - state) / kAnimatingFraction); |
| 106 } else { | 104 } else { |
| 107 return text_size; | 105 return text_size; |
| 108 } | 106 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 131 tab_contents, | 129 tab_contents, |
| 132 profile, | 130 profile, |
| 133 content_setting_image_model_->get_content_settings_type()), | 131 content_setting_image_model_->get_content_settings_type()), |
| 134 tab_contents->web_contents(), | 132 tab_contents->web_contents(), |
| 135 this, | 133 this, |
| 136 views::BubbleBorder::TOP_RIGHT); | 134 views::BubbleBorder::TOP_RIGHT); |
| 137 bubble_widget_ = parent->delegate()->CreateViewsBubble(bubble); | 135 bubble_widget_ = parent->delegate()->CreateViewsBubble(bubble); |
| 138 bubble_widget_->AddObserver(this); | 136 bubble_widget_->AddObserver(this); |
| 139 bubble->Show(); | 137 bubble->Show(); |
| 140 } | 138 } |
| OLD | NEW |