OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/notifications/balloon_view.h" | 5 #include "chrome/browser/views/notifications/balloon_view.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "app/slide_animation.h" | |
12 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
13 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/notifications/balloon.h" | 13 #include "chrome/browser/notifications/balloon.h" |
15 #include "chrome/browser/notifications/balloon_collection.h" | 14 #include "chrome/browser/notifications/balloon_collection.h" |
16 #include "chrome/browser/notifications/desktop_notification_service.h" | 15 #include "chrome/browser/notifications/desktop_notification_service.h" |
17 #include "chrome/browser/notifications/notification.h" | 16 #include "chrome/browser/notifications/notification.h" |
18 #include "chrome/browser/notifications/notification_options_menu_model.h" | 17 #include "chrome/browser/notifications/notification_options_menu_model.h" |
19 #include "chrome/browser/renderer_host/render_view_host.h" | 18 #include "chrome/browser/renderer_host/render_view_host.h" |
20 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 19 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
21 #include "chrome/browser/themes/browser_theme_provider.h" | 20 #include "chrome/browser/themes/browser_theme_provider.h" |
22 #include "chrome/browser/views/bubble_border.h" | 21 #include "chrome/browser/views/bubble_border.h" |
23 #include "chrome/browser/views/notifications/balloon_view_host.h" | 22 #include "chrome/browser/views/notifications/balloon_view_host.h" |
24 #include "chrome/common/notification_details.h" | 23 #include "chrome/common/notification_details.h" |
25 #include "chrome/common/notification_source.h" | 24 #include "chrome/common/notification_source.h" |
26 #include "chrome/common/notification_type.h" | 25 #include "chrome/common/notification_type.h" |
27 #include "gfx/canvas_skia.h" | 26 #include "gfx/canvas_skia.h" |
28 #include "gfx/insets.h" | 27 #include "gfx/insets.h" |
29 #include "gfx/native_widget_types.h" | 28 #include "gfx/native_widget_types.h" |
30 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
31 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
| 31 #include "ui/base/animation/slide_animation.h" |
32 #include "views/controls/button/button.h" | 32 #include "views/controls/button/button.h" |
33 #include "views/controls/button/image_button.h" | 33 #include "views/controls/button/image_button.h" |
34 #include "views/controls/button/text_button.h" | 34 #include "views/controls/button/text_button.h" |
35 #include "views/controls/menu/menu_2.h" | 35 #include "views/controls/menu/menu_2.h" |
36 #include "views/controls/native/native_view_host.h" | 36 #include "views/controls/native/native_view_host.h" |
37 #include "views/painter.h" | 37 #include "views/painter.h" |
38 #include "views/widget/root_view.h" | 38 #include "views/widget/root_view.h" |
39 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
40 #include "views/widget/widget_win.h" | 40 #include "views/widget/widget_win.h" |
41 #endif | 41 #endif |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); | 206 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); |
207 if (view) | 207 if (view) |
208 view->SetSize(contents_rect.size()); | 208 view->SetSize(contents_rect.size()); |
209 return; | 209 return; |
210 } | 210 } |
211 | 211 |
212 anim_frame_end_ = gfx::Rect( | 212 anim_frame_end_ = gfx::Rect( |
213 balloon_->GetPosition().x(), balloon_->GetPosition().y(), | 213 balloon_->GetPosition().x(), balloon_->GetPosition().y(), |
214 GetTotalWidth(), GetTotalHeight()); | 214 GetTotalWidth(), GetTotalHeight()); |
215 frame_container_->GetBounds(&anim_frame_start_, false); | 215 frame_container_->GetBounds(&anim_frame_start_, false); |
216 animation_.reset(new SlideAnimation(this)); | 216 animation_.reset(new ui::SlideAnimation(this)); |
217 animation_->Show(); | 217 animation_->Show(); |
218 } | 218 } |
219 | 219 |
220 void BalloonViewImpl::Update() { | 220 void BalloonViewImpl::Update() { |
221 DCHECK(html_contents_.get()) << "BalloonView::Update called before Show"; | 221 DCHECK(html_contents_.get()) << "BalloonView::Update called before Show"; |
222 if (html_contents_->render_view_host()) | 222 if (html_contents_->render_view_host()) |
223 html_contents_->render_view_host()->NavigateToURL( | 223 html_contents_->render_view_host()->NavigateToURL( |
224 balloon_->notification().content_url()); | 224 balloon_->notification().content_url()); |
225 } | 225 } |
226 | 226 |
227 void BalloonViewImpl::AnimationProgressed(const Animation* animation) { | 227 void BalloonViewImpl::AnimationProgressed(const ui::Animation* animation) { |
228 DCHECK(animation == animation_.get()); | 228 DCHECK(animation == animation_.get()); |
229 | 229 |
230 // Linear interpolation from start to end position. | 230 // Linear interpolation from start to end position. |
231 double e = animation->GetCurrentValue(); | 231 double e = animation->GetCurrentValue(); |
232 double s = (1.0 - e); | 232 double s = (1.0 - e); |
233 | 233 |
234 gfx::Rect frame_position( | 234 gfx::Rect frame_position( |
235 static_cast<int>(s * anim_frame_start_.x() + | 235 static_cast<int>(s * anim_frame_start_.x() + |
236 e * anim_frame_end_.x()), | 236 e * anim_frame_end_.x()), |
237 static_cast<int>(s * anim_frame_start_.y() + | 237 static_cast<int>(s * anim_frame_start_.y() + |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 NOTREACHED(); | 502 NOTREACHED(); |
503 return; | 503 return; |
504 } | 504 } |
505 | 505 |
506 // If the renderer process attached to this balloon is disconnected | 506 // If the renderer process attached to this balloon is disconnected |
507 // (e.g., because of a crash), we want to close the balloon. | 507 // (e.g., because of a crash), we want to close the balloon. |
508 notification_registrar_.Remove(this, | 508 notification_registrar_.Remove(this, |
509 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_)); | 509 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_)); |
510 Close(false); | 510 Close(false); |
511 } | 511 } |
OLD | NEW |