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

Side by Side Diff: components/infobars/core/infobar.cc

Issue 1330513002: Infobar material design refresh: bg color (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/infobars/core/infobar.h" 5 #include "components/infobars/core/infobar.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "components/infobars/core/infobar_container.h" 11 #include "components/infobars/core/infobar_container.h"
12 #include "components/infobars/core/infobar_manager.h" 12 #include "components/infobars/core/infobar_manager.h"
13 #include "ui/base/resource/material_design/material_design_controller.h"
13 #include "ui/gfx/animation/slide_animation.h" 14 #include "ui/gfx/animation/slide_animation.h"
14 15
15 namespace infobars { 16 namespace infobars {
16 17
18 namespace {
19
20 static const SkColor kWarningBackgroundColorMd =
21 SkColorSetRGB(0xFF, 0xEC, 0xB3); // Yellow
22 static const SkColor kPageActionBackgroundColorMd = SK_ColorWHITE;
Peter Kasting 2015/09/02 21:46:10 Nit: Put these in GetTopColor() so they're next to
Evan Stade 2015/09/02 23:34:35 done
23
24 } // namespace
25
17 InfoBar::InfoBar(scoped_ptr<InfoBarDelegate> delegate) 26 InfoBar::InfoBar(scoped_ptr<InfoBarDelegate> delegate)
18 : owner_(NULL), 27 : owner_(NULL),
19 delegate_(delegate.Pass()), 28 delegate_(delegate.Pass()),
20 container_(NULL), 29 container_(NULL),
21 animation_(this), 30 animation_(this),
22 arrow_height_(0), 31 arrow_height_(0),
23 arrow_target_height_(0), 32 arrow_target_height_(0),
24 arrow_half_width_(0), 33 arrow_half_width_(0),
25 bar_height_(0), 34 bar_height_(0),
26 bar_target_height_(-1) { 35 bar_target_height_(-1) {
27 DCHECK(delegate_ != NULL); 36 DCHECK(delegate_ != NULL);
28 animation_.SetTweenType(gfx::Tween::LINEAR); 37 animation_.SetTweenType(gfx::Tween::LINEAR);
29 delegate_->set_infobar(this); 38 delegate_->set_infobar(this);
30 } 39 }
31 40
32 InfoBar::~InfoBar() { 41 InfoBar::~InfoBar() {
33 DCHECK(!owner_); 42 DCHECK(!owner_);
34 } 43 }
35 44
36 // static 45 // static
37 SkColor InfoBar::GetTopColor(InfoBarDelegate::Type infobar_type) { 46 SkColor InfoBar::GetTopColor(InfoBarDelegate::Type infobar_type) {
47 if (ui::MaterialDesignController::IsModeMaterial()) {
48 return infobar_type == InfoBarDelegate::WARNING_TYPE ?
49 kWarningBackgroundColorMd : kPageActionBackgroundColorMd;
Peter Kasting 2015/09/02 21:46:10 Should we be getting these colors from the theme p
Evan Stade 2015/09/02 23:34:35 I don't see any other places where this is used in
50 }
51
38 static const SkColor kWarningBackgroundColorTop = 52 static const SkColor kWarningBackgroundColorTop =
39 SkColorSetRGB(255, 242, 183); // Yellow 53 SkColorSetRGB(255, 242, 183); // Yellow
40 static const SkColor kPageActionBackgroundColorTop = 54 static const SkColor kPageActionBackgroundColorTop =
41 SkColorSetRGB(237, 237, 237); // Gray 55 SkColorSetRGB(237, 237, 237); // Gray
42 return (infobar_type == InfoBarDelegate::WARNING_TYPE) ? 56 return (infobar_type == InfoBarDelegate::WARNING_TYPE) ?
43 kWarningBackgroundColorTop : kPageActionBackgroundColorTop; 57 kWarningBackgroundColorTop : kPageActionBackgroundColorTop;
44 } 58 }
45 59
46 // static 60 // static
47 SkColor InfoBar::GetBottomColor(InfoBarDelegate::Type infobar_type) { 61 SkColor InfoBar::GetBottomColor(InfoBarDelegate::Type infobar_type) {
62 // No gradient in MD.
63 if (ui::MaterialDesignController::IsModeMaterial())
64 return GetTopColor(infobar_type);
65
48 static const SkColor kWarningBackgroundColorBottom = 66 static const SkColor kWarningBackgroundColorBottom =
49 SkColorSetRGB(250, 230, 145); // Yellow 67 SkColorSetRGB(250, 230, 145); // Yellow
50 static const SkColor kPageActionBackgroundColorBottom = 68 static const SkColor kPageActionBackgroundColorBottom =
51 SkColorSetRGB(217, 217, 217); // Gray 69 SkColorSetRGB(217, 217, 217); // Gray
52 return (infobar_type == InfoBarDelegate::WARNING_TYPE) ? 70 return (infobar_type == InfoBarDelegate::WARNING_TYPE) ?
53 kWarningBackgroundColorBottom : kPageActionBackgroundColorBottom; 71 kWarningBackgroundColorBottom : kPageActionBackgroundColorBottom;
54 } 72 }
55 73
56 void InfoBar::SetOwner(InfoBarManager* owner) { 74 void InfoBar::SetOwner(InfoBarManager* owner) {
57 DCHECK(!owner_); 75 DCHECK(!owner_);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 171
154 void InfoBar::MaybeDelete() { 172 void InfoBar::MaybeDelete() {
155 if (!owner_ && (animation_.GetCurrentValue() == 0.0)) { 173 if (!owner_ && (animation_.GetCurrentValue() == 0.0)) {
156 if (container_) 174 if (container_)
157 container_->RemoveInfoBar(this); 175 container_->RemoveInfoBar(this);
158 delete this; 176 delete this;
159 } 177 }
160 } 178 }
161 179
162 } // namespace infobars 180 } // namespace infobars
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698