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

Side by Side Diff: chrome/browser/infobars/infobar.h

Issue 23338005: Mac InfoBar: Use cross platform infobar classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/app/nibs/InfoBarContainer.xib ('k') | chrome/browser/infobars/infobar.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_H_ 5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_H_
6 #define CHROME_BROWSER_INFOBARS_INFOBAR_H_ 6 #define CHROME_BROWSER_INFOBARS_INFOBAR_H_
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/infobars/infobar_delegate.h" 13 #include "chrome/browser/infobars/infobar_delegate.h"
14 #include "third_party/skia/include/core/SkColor.h" 14 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/base/animation/animation_delegate.h" 15 #include "ui/base/animation/animation_delegate.h"
16 #include "ui/base/animation/slide_animation.h" 16 #include "ui/base/animation/slide_animation.h"
17 #include "ui/gfx/size.h" 17 #include "ui/gfx/size.h"
18 18
19 // TODO(sail): These functions should be static methods in the InfoBar class 19 // TODO(sail): These functions should be static methods in the InfoBar class
20 // below once all platforms use that class. 20 // below once all platforms use that class.
21 SkColor GetInfoBarTopColor(InfoBarDelegate::Type infobar_type); 21 SkColor GetInfoBarTopColor(InfoBarDelegate::Type infobar_type);
22 SkColor GetInfoBarBottomColor(InfoBarDelegate::Type infobar_type); 22 SkColor GetInfoBarBottomColor(InfoBarDelegate::Type infobar_type);
23 23
24 // TODO(pkasting): Same with these notification-related typedefs. 24 // TODO(pkasting): Same with these notification-related typedefs.
25 typedef InfoBarDelegate InfoBarAddedDetails; 25 typedef InfoBarDelegate InfoBarAddedDetails;
26 typedef std::pair<InfoBarDelegate*, bool> InfoBarRemovedDetails; 26 typedef std::pair<InfoBarDelegate*, bool> InfoBarRemovedDetails;
27 typedef std::pair<InfoBarDelegate*, InfoBarDelegate*> InfoBarReplacedDetails; 27 typedef std::pair<InfoBarDelegate*, InfoBarDelegate*> InfoBarReplacedDetails;
28 28
29 // TODO(pkasting): Port Mac to use this.
30 #if defined(TOOLKIT_VIEWS) || defined(TOOLKIT_GTK) || defined(OS_ANDROID)
31
32 class InfoBarContainer; 29 class InfoBarContainer;
33 class InfoBarService; 30 class InfoBarService;
34 31
35 class InfoBar : public ui::AnimationDelegate { 32 class InfoBar : public ui::AnimationDelegate {
36 public: 33 public:
37 InfoBar(InfoBarService* owner, InfoBarDelegate* delegate); 34 InfoBar(InfoBarService* owner, InfoBarDelegate* delegate);
38 virtual ~InfoBar(); 35 virtual ~InfoBar();
39 36
40 // Platforms must define these. 37 // Platforms must define these.
41 static const int kDefaultBarTargetHeight; 38 static const int kDefaultBarTargetHeight;
(...skipping 18 matching lines...) Expand all
60 void Hide(bool animate); 57 void Hide(bool animate);
61 58
62 // Changes the target height of the arrow portion of the infobar. This has no 59 // Changes the target height of the arrow portion of the infobar. This has no
63 // effect once the infobar is animating closed. 60 // effect once the infobar is animating closed.
64 void SetArrowTargetHeight(int height); 61 void SetArrowTargetHeight(int height);
65 62
66 // Notifies the infobar that it is no longer owned and should close its 63 // Notifies the infobar that it is no longer owned and should close its
67 // delegate once it is invisible. 64 // delegate once it is invisible.
68 void CloseSoon(); 65 void CloseSoon();
69 66
67 // Changes the target height of the main ("bar") portion of the infobar.
68 void SetBarTargetHeight(int height);
69
70 const ui::SlideAnimation& animation() const { return animation_; } 70 const ui::SlideAnimation& animation() const { return animation_; }
71 int arrow_height() const { return arrow_height_; } 71 int arrow_height() const { return arrow_height_; }
72 int arrow_target_height() const { return arrow_target_height_; } 72 int arrow_target_height() const { return arrow_target_height_; }
73 int arrow_half_width() const { return arrow_half_width_; } 73 int arrow_half_width() const { return arrow_half_width_; }
74 int total_height() const { return arrow_height_ + bar_height_; } 74 int total_height() const { return arrow_height_ + bar_height_; }
75 75
76 protected: 76 protected:
77 // ui::AnimationDelegate: 77 // ui::AnimationDelegate:
78 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; 78 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
79 79
80 // Forwards a close request to our owner. 80 // Forwards a close request to our owner.
81 // NOTE: Subclasses should not call this if we're already unowned. 81 // NOTE: Subclasses should not call this if we're already unowned.
82 void RemoveSelf(); 82 void RemoveSelf();
83 83
84 // Changes the target height of the main ("bar") portion of the infobar.
85 void SetBarTargetHeight(int height);
86
87 // Given a control with size |prefsize|, returns the centered y position 84 // Given a control with size |prefsize|, returns the centered y position
88 // within us, taking into account animation so the control "slides in" (or 85 // within us, taking into account animation so the control "slides in" (or
89 // out) as we animate open and closed. 86 // out) as we animate open and closed.
90 int OffsetY(const gfx::Size& prefsize) const; 87 int OffsetY(const gfx::Size& prefsize) const;
91 88
92 InfoBarService* owner() const { return owner_; } 89 InfoBarService* owner() const { return owner_; }
93 const InfoBarContainer* container() const { return container_; } 90 const InfoBarContainer* container() const { return container_; }
94 InfoBarContainer* container() { return container_; } 91 InfoBarContainer* container() { return container_; }
95 ui::SlideAnimation* animation() { return &animation_; } 92 ui::SlideAnimation* animation() { return &animation_; }
96 int bar_height() const { return bar_height_; } 93 int bar_height() const { return bar_height_; }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // arrow as two halves on either side of a center point.) 125 // arrow as two halves on either side of a center point.)
129 int arrow_height_; // Includes both fill and top stroke. 126 int arrow_height_; // Includes both fill and top stroke.
130 int arrow_target_height_; 127 int arrow_target_height_;
131 int arrow_half_width_; // Includes only fill. 128 int arrow_half_width_; // Includes only fill.
132 int bar_height_; // Includes both fill and bottom separator. 129 int bar_height_; // Includes both fill and bottom separator.
133 int bar_target_height_; 130 int bar_target_height_;
134 131
135 DISALLOW_COPY_AND_ASSIGN(InfoBar); 132 DISALLOW_COPY_AND_ASSIGN(InfoBar);
136 }; 133 };
137 134
138 #elif defined(OS_MACOSX)
139 #include "chrome/browser/ui/cocoa/infobars/infobar.h"
140 #endif
141
142 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_H_ 135 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_H_
OLDNEW
« no previous file with comments | « chrome/app/nibs/InfoBarContainer.xib ('k') | chrome/browser/infobars/infobar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698