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

Side by Side Diff: chrome/browser/ui/views/download/download_started_animation_win.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/download/download_started_animation.h" 5 #include "chrome/browser/download/download_started_animation.h"
6 6
7 #include "content/browser/tab_contents/tab_contents.h" 7 #include "content/browser/tab_contents/tab_contents.h"
8 #include "content/common/notification_details.h" 8 #include "content/common/notification_details.h"
9 #include "content/common/notification_registrar.h" 9 #include "content/common/notification_registrar.h"
10 #include "content/common/notification_source.h" 10 #include "content/common/notification_source.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // Move the animation to wherever it should currently be. 43 // Move the animation to wherever it should currently be.
44 void Reposition(); 44 void Reposition();
45 45
46 // Shut down the animation cleanly. 46 // Shut down the animation cleanly.
47 void Close(); 47 void Close();
48 48
49 // Animation 49 // Animation
50 virtual void AnimateToState(double state); 50 virtual void AnimateToState(double state);
51 51
52 // NotificationObserver 52 // NotificationObserver
53 virtual void Observe(NotificationType type, 53 virtual void Observe(int type,
54 const NotificationSource& source, 54 const NotificationSource& source,
55 const NotificationDetails& details); 55 const NotificationDetails& details);
56 56
57 // We use a HWND for the popup so that it may float above any HWNDs in our UI. 57 // We use a HWND for the popup so that it may float above any HWNDs in our UI.
58 views::Widget* popup_; 58 views::Widget* popup_;
59 59
60 // The content area holding us. 60 // The content area holding us.
61 TabContents* tab_contents_; 61 TabContents* tab_contents_;
62 62
63 // The content area at the start of the animation. We store this so that the 63 // The content area at the start of the animation. We store this so that the
(...skipping 21 matching lines...) Expand all
85 } 85 }
86 86
87 // If we're too small to show the download image, then don't bother - 87 // If we're too small to show the download image, then don't bother -
88 // the shelf will be enough. 88 // the shelf will be enough.
89 tab_contents_->GetContainerBounds(&tab_contents_bounds_); 89 tab_contents_->GetContainerBounds(&tab_contents_bounds_);
90 if (tab_contents_bounds_.height() < kDownloadImage->height()) 90 if (tab_contents_bounds_.height() < kDownloadImage->height())
91 return; 91 return;
92 92
93 registrar_.Add( 93 registrar_.Add(
94 this, 94 this,
95 NotificationType::TAB_CONTENTS_HIDDEN, 95 content::NOTIFICATION_TAB_CONTENTS_HIDDEN,
96 Source<TabContents>(tab_contents_)); 96 Source<TabContents>(tab_contents_));
97 registrar_.Add( 97 registrar_.Add(
98 this, 98 this,
99 NotificationType::TAB_CONTENTS_DESTROYED, 99 content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
100 Source<TabContents>(tab_contents_)); 100 Source<TabContents>(tab_contents_));
101 101
102 SetImage(kDownloadImage); 102 SetImage(kDownloadImage);
103 103
104 popup_ = new views::Widget; 104 popup_ = new views::Widget;
105 105
106 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); 106 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
107 params.transparent = true; 107 params.transparent = true;
108 params.accept_events = false; 108 params.accept_events = false;
109 params.parent = tab_contents_->GetNativeView(); 109 params.parent = tab_contents_->GetNativeView();
(...skipping 22 matching lines...) Expand all
132 size.width(), 132 size.width(),
133 size.height())); 133 size.height()));
134 } 134 }
135 135
136 void DownloadStartedAnimationWin::Close() { 136 void DownloadStartedAnimationWin::Close() {
137 if (!tab_contents_) 137 if (!tab_contents_)
138 return; 138 return;
139 139
140 registrar_.Remove( 140 registrar_.Remove(
141 this, 141 this,
142 NotificationType::TAB_CONTENTS_HIDDEN, 142 content::NOTIFICATION_TAB_CONTENTS_HIDDEN,
143 Source<TabContents>(tab_contents_)); 143 Source<TabContents>(tab_contents_));
144 registrar_.Remove( 144 registrar_.Remove(
145 this, 145 this,
146 NotificationType::TAB_CONTENTS_DESTROYED, 146 content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
147 Source<TabContents>(tab_contents_)); 147 Source<TabContents>(tab_contents_));
148 tab_contents_ = NULL; 148 tab_contents_ = NULL;
149 popup_->Close(); 149 popup_->Close();
150 } 150 }
151 151
152 void DownloadStartedAnimationWin::AnimateToState(double state) { 152 void DownloadStartedAnimationWin::AnimateToState(double state) {
153 if (state >= 1.0) { 153 if (state >= 1.0) {
154 Close(); 154 Close();
155 } else { 155 } else {
156 Reposition(); 156 Reposition();
157 157
158 // Start at zero, peak halfway and end at zero. 158 // Start at zero, peak halfway and end at zero.
159 double opacity = std::min(1.0 - pow(GetCurrentValue() - 0.5, 2) * 4.0, 159 double opacity = std::min(1.0 - pow(GetCurrentValue() - 0.5, 2) * 4.0,
160 static_cast<double>(1.0)); 160 static_cast<double>(1.0));
161 161
162 popup_->SetOpacity( 162 popup_->SetOpacity(
163 static_cast<SkColor>(opacity * 255.0)); 163 static_cast<SkColor>(opacity * 255.0));
164 SchedulePaint(); // Reposition() calls MoveWindow() which never picks up 164 SchedulePaint(); // Reposition() calls MoveWindow() which never picks up
165 // alpha changes, so we need to force a paint. 165 // alpha changes, so we need to force a paint.
166 } 166 }
167 } 167 }
168 168
169 void DownloadStartedAnimationWin::Observe(NotificationType type, 169 void DownloadStartedAnimationWin::Observe(int type,
170 const NotificationSource& source, 170 const NotificationSource& source,
171 const NotificationDetails& details) { 171 const NotificationDetails& details) {
172 Close(); 172 Close();
173 } 173 }
174 174
175 } // namespace 175 } // namespace
176 176
177 // static 177 // static
178 void DownloadStartedAnimation::Show(TabContents* tab_contents) { 178 void DownloadStartedAnimation::Show(TabContents* tab_contents) {
179 // The animation will delete itself when it's finished or when the tab 179 // The animation will delete itself when it's finished or when the tab
180 // contents is hidden or destroyed. 180 // contents is hidden or destroyed.
181 new DownloadStartedAnimationWin(tab_contents); 181 new DownloadStartedAnimationWin(tab_contents);
182 } 182 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/dom_view_browsertest.cc ('k') | chrome/browser/ui/views/extensions/extension_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698