Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: chrome/browser/ui/views/location_bar/content_setting_image_view.cc

Issue 16286003: Increase omnibox size by 2 px. Increase nominal font size in omnibox to 16 px. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" 11 #include "chrome/browser/ui/views/content_setting_bubble_contents.h"
12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
13 #include "grit/theme_resources.h" 13 #include "grit/theme_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/color_utils.h" 16 #include "ui/gfx/color_utils.h"
17 #include "ui/views/controls/image_view.h" 17 #include "ui/views/controls/image_view.h"
18 #include "ui/views/controls/label.h" 18 #include "ui/views/controls/label.h"
19 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
20 20
21 21
22 namespace { 22 namespace {
23 const int kBackgroundImages[] = { 23 const int kBackgroundImages[] = IMAGE_GRID(IDR_OMNIBOX_CONTENT_SETTING_BUBBLE);
24 IDR_OMNIBOX_CONTENT_SETTING_BUBBLE_LEFT,
25 IDR_OMNIBOX_CONTENT_SETTING_BUBBLE_CENTER,
26 IDR_OMNIBOX_CONTENT_SETTING_BUBBLE_RIGHT,
27 };
28 const int kStayOpenTimeMS = 3200; // Time spent with animation fully open. 24 const int kStayOpenTimeMS = 3200; // Time spent with animation fully open.
29 } 25 }
30 26
31 27
32 // static 28 // static
33 const int ContentSettingImageView::kOpenTimeMS = 150; 29 const int ContentSettingImageView::kOpenTimeMS = 150;
34 const int ContentSettingImageView::kAnimationDurationMS = 30 const int ContentSettingImageView::kAnimationDurationMS =
35 (kOpenTimeMS * 2) + kStayOpenTimeMS; 31 (kOpenTimeMS * 2) + kStayOpenTimeMS;
36 32
37 ContentSettingImageView::ContentSettingImageView( 33 ContentSettingImageView::ContentSettingImageView(
38 ContentSettingsType content_type, 34 ContentSettingsType content_type,
39 LocationBarView* parent, 35 LocationBarView* parent,
40 const gfx::Font& font, 36 const gfx::Font& font,
41 int font_y_offset, 37 int font_y_offset,
42 SkColor text_color, 38 SkColor text_color,
43 SkColor parent_background_color) 39 SkColor parent_background_color)
44 : parent_(parent), 40 : parent_(parent),
45 content_setting_image_model_( 41 content_setting_image_model_(
46 ContentSettingImageModel::CreateContentSettingImageModel( 42 ContentSettingImageModel::CreateContentSettingImageModel(
47 content_type)), 43 content_type)),
48 background_painter_(new views::HorizontalPainter(kBackgroundImages)), 44 background_painter_(
45 views::Painter::CreateImageGridPainter(kBackgroundImages)),
49 icon_(new views::ImageView), 46 icon_(new views::ImageView),
50 text_label_(new views::Label), 47 text_label_(new views::Label),
51 slide_animator_(this), 48 slide_animator_(this),
52 pause_animation_(false), 49 pause_animation_(false),
53 pause_animation_state_(0.0), 50 pause_animation_state_(0.0),
54 bubble_widget_(NULL) { 51 bubble_widget_(NULL) {
55 icon_->SetHorizontalAlignment(views::ImageView::LEADING); 52 icon_->SetHorizontalAlignment(views::ImageView::LEADING);
56 AddChildView(icon_); 53 AddChildView(icon_);
57 54
58 text_label_->SetVisible(false); 55 text_label_->SetVisible(false);
59 text_label_->set_border( 56 text_label_->set_border(
60 views::Border::CreateEmptyBorder(font_y_offset, 0, 0, 0)); 57 views::Border::CreateEmptyBorder(font_y_offset, 0, 0, 0));
61 text_label_->SetFont(font); 58 text_label_->SetFont(font);
62 text_label_->SetEnabledColor(text_color); 59 text_label_->SetEnabledColor(text_color);
63 // Calculate the actual background color for the label. The background images 60 // Calculate the actual background color for the label. The background images
64 // 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
65 // 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
66 // representative color of the entire background (reasonable, given the 63 // representative color of the entire background (reasonable, given the
67 // 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
68 // 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
69 // sit atop. 66 // sit atop.
70 const SkBitmap& bitmap( 67 const SkBitmap& bitmap(
71 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 68 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
72 kBackgroundImages[1])->GetRepresentation( 69 kBackgroundImages[4])->GetRepresentation(
73 ui::SCALE_FACTOR_100P).sk_bitmap()); 70 ui::SCALE_FACTOR_100P).sk_bitmap());
74 SkAutoLockPixels pixel_lock(bitmap); 71 SkAutoLockPixels pixel_lock(bitmap);
75 SkColor background_image_color = 72 SkColor background_image_color =
76 bitmap.getColor(bitmap.width() / 2, bitmap.height() / 2); 73 bitmap.getColor(bitmap.width() / 2, bitmap.height() / 2);
77 // Tricky bit: We alpha blend an opaque version of |background_image_color| 74 // Tricky bit: We alpha blend an opaque version of |background_image_color|
78 // against |parent_background_color| using the original image grid color's 75 // against |parent_background_color| using the original image grid color's
79 // alpha. This is because AlphaBlend(a, b, 255) always returns |a| unchanged 76 // alpha. This is because AlphaBlend(a, b, 255) always returns |a| unchanged
80 // even if |a| is a color with non-255 alpha. 77 // even if |a| is a color with non-255 alpha.
81 text_label_->SetBackgroundColor( 78 text_label_->SetBackgroundColor(
82 color_utils::AlphaBlend(SkColorSetA(background_image_color, 255), 79 color_utils::AlphaBlend(SkColorSetA(background_image_color, 255),
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 parent_->delegate()->CreateViewsBubble(new ContentSettingBubbleContents( 253 parent_->delegate()->CreateViewsBubble(new ContentSettingBubbleContents(
257 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 254 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
258 parent_->delegate()->GetContentSettingBubbleModelDelegate(), 255 parent_->delegate()->GetContentSettingBubbleModelDelegate(),
259 web_contents, parent_->profile(), 256 web_contents, parent_->profile(),
260 content_setting_image_model_->get_content_settings_type()), 257 content_setting_image_model_->get_content_settings_type()),
261 web_contents, this, views::BubbleBorder::TOP_RIGHT)); 258 web_contents, this, views::BubbleBorder::TOP_RIGHT));
262 bubble_widget_->AddObserver(this); 259 bubble_widget_->AddObserver(this);
263 bubble_widget_->Show(); 260 bubble_widget_->Show();
264 } 261 }
265 } 262 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.cc ('k') | chrome/browser/ui/views/location_bar/ev_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698