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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 text_label_->SetEnabledColor(text_color); | 59 text_label_->SetEnabledColor(text_color); |
60 // Calculate the actual background color for the label. The background images | 60 // Calculate the actual background color for the label. The background images |
61 // are painted atop |parent_background_color|. We grab the color of the | 61 // 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 | 62 // middle pixel of the middle image of the background, which we treat as the |
63 // representative color of the entire background (reasonable, given the | 63 // representative color of the entire background (reasonable, given the |
64 // current appearance of these images). Then we alpha-blend it over the | 64 // 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 | 65 // parent background color to determine the actual color the label text will |
66 // sit atop. | 66 // sit atop. |
67 const SkBitmap& bitmap( | 67 const SkBitmap& bitmap( |
68 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 68 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
69 kBackgroundImages[4])->GetRepresentation( | 69 kBackgroundImages[4])->GetRepresentation(1.0f).sk_bitmap()); |
70 ui::SCALE_FACTOR_100P).sk_bitmap()); | |
71 SkAutoLockPixels pixel_lock(bitmap); | 70 SkAutoLockPixels pixel_lock(bitmap); |
72 SkColor background_image_color = | 71 SkColor background_image_color = |
73 bitmap.getColor(bitmap.width() / 2, bitmap.height() / 2); | 72 bitmap.getColor(bitmap.width() / 2, bitmap.height() / 2); |
74 // Tricky bit: We alpha blend an opaque version of |background_image_color| | 73 // Tricky bit: We alpha blend an opaque version of |background_image_color| |
75 // against |parent_background_color| using the original image grid color's | 74 // against |parent_background_color| using the original image grid color's |
76 // alpha. This is because AlphaBlend(a, b, 255) always returns |a| unchanged | 75 // alpha. This is because AlphaBlend(a, b, 255) always returns |a| unchanged |
77 // even if |a| is a color with non-255 alpha. | 76 // even if |a| is a color with non-255 alpha. |
78 text_label_->SetBackgroundColor( | 77 text_label_->SetBackgroundColor( |
79 color_utils::AlphaBlend(SkColorSetA(background_image_color, 255), | 78 color_utils::AlphaBlend(SkColorSetA(background_image_color, 255), |
80 parent_background_color, | 79 parent_background_color, |
(...skipping 195 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 |