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

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

Issue 1724963002: Color the ink drop ripple and hover effects based on theming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review and format Created 4 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/bubble_icon_view.h" 5 #include "chrome/browser/ui/views/location_bar/bubble_icon_view.h"
6 6
7 #include "chrome/browser/command_updater.h" 7 #include "chrome/browser/command_updater.h"
8 #include "ui/accessibility/ax_view_state.h" 8 #include "ui/accessibility/ax_view_state.h"
9 #include "ui/base/material_design/material_design_controller.h" 9 #include "ui/base/material_design/material_design_controller.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 return true; 107 return true;
108 } 108 }
109 109
110 void BubbleIconView::ViewHierarchyChanged( 110 void BubbleIconView::ViewHierarchyChanged(
111 const ViewHierarchyChangedDetails& details) { 111 const ViewHierarchyChangedDetails& details) {
112 View::ViewHierarchyChanged(details); 112 View::ViewHierarchyChanged(details);
113 if (details.is_add && GetNativeTheme()) 113 if (details.is_add && GetNativeTheme())
114 UpdateIcon(); 114 UpdateIcon();
115 } 115 }
116 116
117 void BubbleIconView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
118 UpdateIcon();
119 }
120
117 void BubbleIconView::AddInkDropLayer(ui::Layer* ink_drop_layer) { 121 void BubbleIconView::AddInkDropLayer(ui::Layer* ink_drop_layer) {
118 image_->SetPaintToLayer(true); 122 image_->SetPaintToLayer(true);
119 image_->SetFillsBoundsOpaquely(false); 123 image_->SetFillsBoundsOpaquely(false);
120 views::InkDropHostView::AddInkDropLayer(ink_drop_layer); 124 views::InkDropHostView::AddInkDropLayer(ink_drop_layer);
121 } 125 }
122 126
123 void BubbleIconView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { 127 void BubbleIconView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
124 views::InkDropHostView::RemoveInkDropLayer(ink_drop_layer); 128 views::InkDropHostView::RemoveInkDropLayer(ink_drop_layer);
125 image_->SetFillsBoundsOpaquely(true); 129 image_->SetFillsBoundsOpaquely(true);
126 image_->SetPaintToLayer(false); 130 image_->SetPaintToLayer(false);
127 } 131 }
128 132
129 scoped_ptr<views::InkDropHover> BubbleIconView::CreateInkDropHover() const { 133 scoped_ptr<views::InkDropHover> BubbleIconView::CreateInkDropHover() const {
130 // BubbleIconView views don't show hover effect. 134 // BubbleIconView views don't show hover effect.
131 return nullptr; 135 return nullptr;
132 } 136 }
133 137
134 void BubbleIconView::OnNativeThemeChanged(const ui::NativeTheme* theme) { 138 SkColor BubbleIconView::GetInkDropBaseColor() const {
135 UpdateIcon(); 139 return color_utils::DeriveDefaultIconColor(GetNativeTheme()->GetSystemColor(
140 ui::NativeTheme::kColorId_TextfieldDefaultColor));
136 } 141 }
137 142
138 void BubbleIconView::OnGestureEvent(ui::GestureEvent* event) { 143 void BubbleIconView::OnGestureEvent(ui::GestureEvent* event) {
139 if (event->type() == ui::ET_GESTURE_TAP) { 144 if (event->type() == ui::ET_GESTURE_TAP) {
140 ink_drop_delegate_->OnAction(views::InkDropState::ACTIVATED); 145 ink_drop_delegate_->OnAction(views::InkDropState::ACTIVATED);
141 ExecuteCommand(EXECUTE_SOURCE_GESTURE); 146 ExecuteCommand(EXECUTE_SOURCE_GESTURE);
142 event->SetHandled(); 147 event->SetHandled();
143 } 148 }
144 } 149 }
145 150
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 void BubbleIconView::UpdateIcon() { 182 void BubbleIconView::UpdateIcon() {
178 if (SetRasterIcon()) 183 if (SetRasterIcon())
179 return; 184 return;
180 185
181 const int icon_size = 186 const int icon_size =
182 ui::MaterialDesignController::IsModeMaterial() ? 16 : 18; 187 ui::MaterialDesignController::IsModeMaterial() ? 16 : 18;
183 const ui::NativeTheme* theme = GetNativeTheme(); 188 const ui::NativeTheme* theme = GetNativeTheme();
184 SkColor icon_color = 189 SkColor icon_color =
185 active_ 190 active_
186 ? theme->GetSystemColor(ui::NativeTheme::kColorId_CallToActionColor) 191 ? theme->GetSystemColor(ui::NativeTheme::kColorId_CallToActionColor)
187 : color_utils::DeriveDefaultIconColor(theme->GetSystemColor( 192 : GetInkDropBaseColor();
188 ui::NativeTheme::kColorId_TextfieldDefaultColor));
189 image_->SetImage( 193 image_->SetImage(
190 gfx::CreateVectorIcon(GetVectorIcon(), icon_size, icon_color)); 194 gfx::CreateVectorIcon(GetVectorIcon(), icon_size, icon_color));
191 } 195 }
192 196
193 void BubbleIconView::SetActiveInternal(bool active) { 197 void BubbleIconView::SetActiveInternal(bool active) {
194 if (active_ == active) 198 if (active_ == active)
195 return; 199 return;
196 active_ = active; 200 active_ = active;
197 UpdateIcon(); 201 UpdateIcon();
198 } 202 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698