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

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

Issue 1423263004: [MD] Use programmatic rendering for omnibox chips (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review Created 5 years, 1 month 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
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/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/themes/theme_properties.h" 9 #include "chrome/browser/themes/theme_properties.h"
10 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" 10 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
11 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" 11 #include "chrome/browser/ui/content_settings/content_setting_image_model.h"
12 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" 12 #include "chrome/browser/ui/views/content_setting_bubble_contents.h"
13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
14 #include "grit/theme_resources.h" 14 #include "grit/theme_resources.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/resource/material_design/material_design_controller.h" 16 #include "ui/base/resource/material_design/material_design_controller.h"
17 #include "ui/base/theme_provider.h" 17 #include "ui/base/theme_provider.h"
18 #include "ui/gfx/color_palette.h"
18 #include "ui/gfx/color_utils.h" 19 #include "ui/gfx/color_utils.h"
19 #include "ui/views/controls/image_view.h" 20 #include "ui/views/controls/image_view.h"
20 #include "ui/views/controls/label.h" 21 #include "ui/views/controls/label.h"
21 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
22 23
23 24
24 namespace { 25 namespace {
25 // Time spent with animation fully open. 26 // Time spent with animation fully open.
26 const int kStayOpenTimeMS = 3200; 27 const int kStayOpenTimeMS = 3200;
27 } 28 }
(...skipping 16 matching lines...) Expand all
44 parent_background_color, 45 parent_background_color,
45 false), 46 false),
46 parent_(parent), 47 parent_(parent),
47 content_setting_image_model_( 48 content_setting_image_model_(
48 ContentSettingImageModel::CreateContentSettingImageModel( 49 ContentSettingImageModel::CreateContentSettingImageModel(
49 content_type)), 50 content_type)),
50 slide_animator_(this), 51 slide_animator_(this),
51 pause_animation_(false), 52 pause_animation_(false),
52 pause_animation_state_(0.0), 53 pause_animation_state_(0.0),
53 bubble_widget_(NULL) { 54 bubble_widget_(NULL) {
54 if (ui::MaterialDesignController::IsModeMaterial()) { 55 if (!ui::MaterialDesignController::IsModeMaterial()) {
55 // The insets for IDR_OMNIBOX_CONTENT_SETTING_BUBBLE for which to perfom
56 // nine-slicing.
57 static const int kImageInset = 4;
58 gfx::Insets insets(kImageInset, kImageInset, kImageInset, kImageInset);
59 SetBackgroundImageWithInsets(IDR_OMNIBOX_CONTENT_SETTING_BUBBLE, insets);
60 } else {
61 static const int kBackgroundImages[] = 56 static const int kBackgroundImages[] =
62 IMAGE_GRID(IDR_OMNIBOX_CONTENT_SETTING_BUBBLE); 57 IMAGE_GRID(IDR_OMNIBOX_CONTENT_SETTING_BUBBLE);
63 SetBackgroundImageGrid(kBackgroundImages); 58 SetBackgroundImageGrid(kBackgroundImages);
64 } 59 }
65 60
66 image()->SetHorizontalAlignment(views::ImageView::LEADING); 61 image()->SetHorizontalAlignment(views::ImageView::LEADING);
67 image()->set_interactive(true); 62 image()->set_interactive(true);
68 label()->SetElideBehavior(gfx::NO_ELIDE); 63 label()->SetElideBehavior(gfx::NO_ELIDE);
69 64
70 slide_animator_.SetSlideDuration(kAnimationDurationMS); 65 slide_animator_.SetSlideDuration(kAnimationDurationMS);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 const double kOpenFraction = 120 const double kOpenFraction =
126 static_cast<double>(kOpenTimeMS) / kAnimationDurationMS; 121 static_cast<double>(kOpenTimeMS) / kAnimationDurationMS;
127 double size_fraction = 1.0; 122 double size_fraction = 1.0;
128 if (state < kOpenFraction) 123 if (state < kOpenFraction)
129 size_fraction = state / kOpenFraction; 124 size_fraction = state / kOpenFraction;
130 if (state > (1.0 - kOpenFraction)) 125 if (state > (1.0 - kOpenFraction))
131 size_fraction = (1.0 - state) / kOpenFraction; 126 size_fraction = (1.0 - state) / kOpenFraction;
132 return size_fraction; 127 return size_fraction;
133 } 128 }
134 129
130 SkColor ContentSettingImageView::GetTextColor() const {
131 return GetNativeTheme()->GetSystemColor(
132 ui::NativeTheme::kColorId_TextfieldDefaultColor);
133 }
134
135 SkColor ContentSettingImageView::GetBorderColor() const {
136 return gfx::kGoogleYellow700;
137 }
138
135 void ContentSettingImageView::AnimationEnded(const gfx::Animation* animation) { 139 void ContentSettingImageView::AnimationEnded(const gfx::Animation* animation) {
136 slide_animator_.Reset(); 140 slide_animator_.Reset();
137 if (!pause_animation_) { 141 if (!pause_animation_) {
138 label()->SetVisible(false); 142 label()->SetVisible(false);
139 parent_->Layout(); 143 parent_->Layout();
140 parent_->SchedulePaint(); 144 parent_->SchedulePaint();
141 } 145 }
142 } 146 }
143 147
144 void ContentSettingImageView::AnimationProgressed( 148 void ContentSettingImageView::AnimationProgressed(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 parent_->delegate()->CreateViewsBubble(new ContentSettingBubbleContents( 208 parent_->delegate()->CreateViewsBubble(new ContentSettingBubbleContents(
205 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 209 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
206 parent_->delegate()->GetContentSettingBubbleModelDelegate(), 210 parent_->delegate()->GetContentSettingBubbleModelDelegate(),
207 web_contents, parent_->profile(), 211 web_contents, parent_->profile(),
208 content_setting_image_model_->get_content_settings_type()), 212 content_setting_image_model_->get_content_settings_type()),
209 web_contents, this, views::BubbleBorder::TOP_RIGHT)); 213 web_contents, this, views::BubbleBorder::TOP_RIGHT));
210 bubble_widget_->AddObserver(this); 214 bubble_widget_->AddObserver(this);
211 bubble_widget_->Show(); 215 bubble_widget_->Show();
212 } 216 }
213 } 217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698