| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 | 27 |
| 28 // static | 28 // static |
| 29 const int ContentSettingImageView::kOpenTimeMS = 150; | 29 const int ContentSettingImageView::kOpenTimeMS = 150; |
| 30 const int ContentSettingImageView::kAnimationDurationMS = | 30 const int ContentSettingImageView::kAnimationDurationMS = |
| 31 (kOpenTimeMS * 2) + kStayOpenTimeMS; | 31 (kOpenTimeMS * 2) + kStayOpenTimeMS; |
| 32 | 32 |
| 33 ContentSettingImageView::ContentSettingImageView( | 33 ContentSettingImageView::ContentSettingImageView( |
| 34 ContentSettingsType content_type, | 34 ContentSettingsType content_type, |
| 35 LocationBarView* parent, | 35 LocationBarView* parent, |
| 36 const gfx::Font& font, | 36 const gfx::FontList& font_list, |
| 37 int font_y_offset, | 37 int font_y_offset, |
| 38 SkColor text_color, | 38 SkColor text_color, |
| 39 SkColor parent_background_color) | 39 SkColor parent_background_color) |
| 40 : parent_(parent), | 40 : parent_(parent), |
| 41 content_setting_image_model_( | 41 content_setting_image_model_( |
| 42 ContentSettingImageModel::CreateContentSettingImageModel( | 42 ContentSettingImageModel::CreateContentSettingImageModel( |
| 43 content_type)), | 43 content_type)), |
| 44 background_painter_( | 44 background_painter_( |
| 45 views::Painter::CreateImageGridPainter(kBackgroundImages)), | 45 views::Painter::CreateImageGridPainter(kBackgroundImages)), |
| 46 icon_(new views::ImageView), | 46 icon_(new views::ImageView), |
| 47 text_label_(new views::Label), | 47 text_label_(new views::Label(string16(), font_list)), |
| 48 slide_animator_(this), | 48 slide_animator_(this), |
| 49 pause_animation_(false), | 49 pause_animation_(false), |
| 50 pause_animation_state_(0.0), | 50 pause_animation_state_(0.0), |
| 51 bubble_widget_(NULL) { | 51 bubble_widget_(NULL) { |
| 52 icon_->SetHorizontalAlignment(views::ImageView::LEADING); | 52 icon_->SetHorizontalAlignment(views::ImageView::LEADING); |
| 53 AddChildView(icon_); | 53 AddChildView(icon_); |
| 54 | 54 |
| 55 text_label_->SetVisible(false); | 55 text_label_->SetVisible(false); |
| 56 text_label_->set_border( | 56 text_label_->set_border( |
| 57 views::Border::CreateEmptyBorder(font_y_offset, 0, 0, 0)); | 57 views::Border::CreateEmptyBorder(font_y_offset, 0, 0, 0)); |
| 58 text_label_->SetFont(font); | |
| 59 text_label_->SetEnabledColor(text_color); | 58 text_label_->SetEnabledColor(text_color); |
| 60 // Calculate the actual background color for the label. The background images | 59 // Calculate the actual background color for the label. The background images |
| 61 // are painted atop |parent_background_color|. We grab the color of the | 60 // are painted atop |parent_background_color|. We grab the color of the |
| 62 // middle pixel of the middle image of the background, which we treat as the | 61 // middle pixel of the middle image of the background, which we treat as the |
| 63 // representative color of the entire background (reasonable, given the | 62 // representative color of the entire background (reasonable, given the |
| 64 // current appearance of these images). Then we alpha-blend it over the | 63 // current appearance of these images). Then we alpha-blend it over the |
| 65 // parent background color to determine the actual color the label text will | 64 // parent background color to determine the actual color the label text will |
| 66 // sit atop. | 65 // sit atop. |
| 67 const SkBitmap& bitmap( | 66 const SkBitmap& bitmap( |
| 68 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 67 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 parent_->delegate()->CreateViewsBubble(new ContentSettingBubbleContents( | 275 parent_->delegate()->CreateViewsBubble(new ContentSettingBubbleContents( |
| 277 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 276 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 278 parent_->delegate()->GetContentSettingBubbleModelDelegate(), | 277 parent_->delegate()->GetContentSettingBubbleModelDelegate(), |
| 279 web_contents, parent_->profile(), | 278 web_contents, parent_->profile(), |
| 280 content_setting_image_model_->get_content_settings_type()), | 279 content_setting_image_model_->get_content_settings_type()), |
| 281 web_contents, this, views::BubbleBorder::TOP_RIGHT)); | 280 web_contents, this, views::BubbleBorder::TOP_RIGHT)); |
| 282 bubble_widget_->AddObserver(this); | 281 bubble_widget_->AddObserver(this); |
| 283 bubble_widget_->Show(); | 282 bubble_widget_->Show(); |
| 284 } | 283 } |
| 285 | 284 |
| OLD | NEW |