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

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

Issue 2473863004: Remove MaterialDesignController::IsModeMaterial (Closed)
Patch Set: fix win Created 4 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 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 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "components/infobars/core/infobar_container.h" 12 #include "components/infobars/core/infobar_container.h"
13 #include "components/infobars/core/infobar_manager.h" 13 #include "components/infobars/core/infobar_manager.h"
14 #include "ui/base/material_design/material_design_controller.h"
15 #include "ui/gfx/animation/slide_animation.h" 14 #include "ui/gfx/animation/slide_animation.h"
16 15
17 namespace infobars { 16 namespace infobars {
18 17
19 InfoBar::InfoBar(std::unique_ptr<InfoBarDelegate> delegate) 18 InfoBar::InfoBar(std::unique_ptr<InfoBarDelegate> delegate)
20 : owner_(NULL), 19 : owner_(NULL),
21 delegate_(std::move(delegate)), 20 delegate_(std::move(delegate)),
22 container_(NULL), 21 container_(NULL),
23 animation_(this), 22 animation_(this),
24 arrow_height_(0), 23 arrow_height_(0),
25 arrow_target_height_(0), 24 arrow_target_height_(0),
26 arrow_half_width_(0), 25 arrow_half_width_(0),
27 bar_height_(0), 26 bar_height_(0),
28 bar_target_height_(-1) { 27 bar_target_height_(-1) {
29 DCHECK(delegate_ != NULL); 28 DCHECK(delegate_ != NULL);
30 animation_.SetTweenType(gfx::Tween::LINEAR); 29 animation_.SetTweenType(gfx::Tween::LINEAR);
31 delegate_->set_infobar(this); 30 delegate_->set_infobar(this);
32 } 31 }
33 32
34 InfoBar::~InfoBar() { 33 InfoBar::~InfoBar() {
35 DCHECK(!owner_); 34 DCHECK(!owner_);
36 } 35 }
37 36
38 // static 37 // static
39 SkColor InfoBar::GetTopColor(InfoBarDelegate::Type infobar_type) { 38 SkColor InfoBar::GetBackgroundColor(InfoBarDelegate::Type infobar_type) {
40 if (ui::MaterialDesignController::IsModeMaterial()) { 39 static const SkColor kWarningBackgroundColor =
41 static const SkColor kWarningBackgroundColorMd = 40 SkColorSetRGB(0xFF, 0xEC, 0xB3); // Yellow
42 SkColorSetRGB(0xFF, 0xEC, 0xB3); // Yellow 41 static const SkColor kPageActionBackgroundColor = SK_ColorWHITE;
Peter Kasting 2016/11/10 05:42:20 Nit: This one can be constexpr (The other can't b
Evan Stade 2016/11/10 15:39:46 Done.
43 static const SkColor kPageActionBackgroundColorMd = SK_ColorWHITE;
44 42
45 return infobar_type == InfoBarDelegate::WARNING_TYPE ? 43 return infobar_type == InfoBarDelegate::WARNING_TYPE
46 kWarningBackgroundColorMd : kPageActionBackgroundColorMd; 44 ? kWarningBackgroundColor
47 } 45 : kPageActionBackgroundColor;
48
49 static const SkColor kWarningBackgroundColorTop =
50 SkColorSetRGB(255, 242, 183); // Yellow
51 static const SkColor kPageActionBackgroundColorTop =
52 SkColorSetRGB(237, 237, 237); // Gray
53 return (infobar_type == InfoBarDelegate::WARNING_TYPE) ?
54 kWarningBackgroundColorTop : kPageActionBackgroundColorTop;
55 }
56
57 // static
58 SkColor InfoBar::GetBottomColor(InfoBarDelegate::Type infobar_type) {
59 // No gradient in MD.
60 if (ui::MaterialDesignController::IsModeMaterial())
61 return GetTopColor(infobar_type);
62
63 static const SkColor kWarningBackgroundColorBottom =
64 SkColorSetRGB(250, 230, 145); // Yellow
65 static const SkColor kPageActionBackgroundColorBottom =
66 SkColorSetRGB(217, 217, 217); // Gray
67 return (infobar_type == InfoBarDelegate::WARNING_TYPE) ?
68 kWarningBackgroundColorBottom : kPageActionBackgroundColorBottom;
69 } 46 }
70 47
71 void InfoBar::SetOwner(InfoBarManager* owner) { 48 void InfoBar::SetOwner(InfoBarManager* owner) {
72 DCHECK(!owner_); 49 DCHECK(!owner_);
73 owner_ = owner; 50 owner_ = owner;
74 delegate_->set_nav_entry_id(owner->GetActiveEntryID()); 51 delegate_->set_nav_entry_id(owner->GetActiveEntryID());
75 PlatformSpecificSetOwner(); 52 PlatformSpecificSetOwner();
76 } 53 }
77 54
78 void InfoBar::Show(bool animate) { 55 void InfoBar::Show(bool animate) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 145
169 void InfoBar::MaybeDelete() { 146 void InfoBar::MaybeDelete() {
170 if (!owner_ && (animation_.GetCurrentValue() == 0.0)) { 147 if (!owner_ && (animation_.GetCurrentValue() == 0.0)) {
171 if (container_) 148 if (container_)
172 container_->RemoveInfoBar(this); 149 container_->RemoveInfoBar(this);
173 delete this; 150 delete this;
174 } 151 }
175 } 152 }
176 153
177 } // namespace infobars 154 } // namespace infobars
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698