| OLD | NEW |
| 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 #include "chrome/browser/ui/views/notifications/balloon_view.h" | 5 #include "chrome/browser/ui/views/notifications/balloon_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/notifications/balloon.h" | 13 #include "chrome/browser/notifications/balloon.h" |
| 14 #include "chrome/browser/notifications/balloon_collection.h" | 14 #include "chrome/browser/notifications/balloon_collection.h" |
| 15 #include "chrome/browser/notifications/desktop_notification_service.h" | 15 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 16 #include "chrome/browser/notifications/notification.h" | 16 #include "chrome/browser/notifications/notification.h" |
| 17 #include "chrome/browser/notifications/notification_options_menu_model.h" | 17 #include "chrome/browser/notifications/notification_options_menu_model.h" |
| 18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "content/browser/renderer_host/render_view_host.h" | 19 #include "content/browser/renderer_host/render_view_host.h" |
| 20 #include "content/browser/renderer_host/render_widget_host_view.h" | |
| 21 #include "content/public/browser/notification_details.h" | 20 #include "content/public/browser/notification_details.h" |
| 22 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
| 23 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
| 23 #include "content/public/browser/render_widget_host_view.h" |
| 24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 25 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 26 #include "grit/theme_resources.h" | 26 #include "grit/theme_resources.h" |
| 27 #include "grit/theme_resources_standard.h" | 27 #include "grit/theme_resources_standard.h" |
| 28 #include "ui/base/animation/slide_animation.h" | 28 #include "ui/base/animation/slide_animation.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
| 31 #include "ui/gfx/canvas_skia.h" | 31 #include "ui/gfx/canvas_skia.h" |
| 32 #include "ui/gfx/insets.h" | 32 #include "ui/gfx/insets.h" |
| 33 #include "ui/gfx/native_widget_types.h" | 33 #include "ui/gfx/native_widget_types.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 DCHECK(html_container_); | 216 DCHECK(html_container_); |
| 217 DCHECK(balloon_); | 217 DCHECK(balloon_); |
| 218 | 218 |
| 219 if (!kAnimateEnabled) { | 219 if (!kAnimateEnabled) { |
| 220 frame_container_->SetBounds( | 220 frame_container_->SetBounds( |
| 221 gfx::Rect(balloon_->GetPosition().x(), balloon_->GetPosition().y(), | 221 gfx::Rect(balloon_->GetPosition().x(), balloon_->GetPosition().y(), |
| 222 GetTotalWidth(), GetTotalHeight())); | 222 GetTotalWidth(), GetTotalHeight())); |
| 223 gfx::Rect contents_rect = GetContentsRectangle(); | 223 gfx::Rect contents_rect = GetContentsRectangle(); |
| 224 html_container_->SetBounds(contents_rect); | 224 html_container_->SetBounds(contents_rect); |
| 225 html_contents_->SetPreferredSize(contents_rect.size()); | 225 html_contents_->SetPreferredSize(contents_rect.size()); |
| 226 RenderWidgetHostView* view = | 226 content::RenderWidgetHostView* view = |
| 227 html_contents_->web_contents()->GetRenderWidgetHostView(); | 227 html_contents_->web_contents()->GetRenderWidgetHostView(); |
| 228 if (view) | 228 if (view) |
| 229 view->SetSize(contents_rect.size()); | 229 view->SetSize(contents_rect.size()); |
| 230 return; | 230 return; |
| 231 } | 231 } |
| 232 | 232 |
| 233 anim_frame_end_ = gfx::Rect( | 233 anim_frame_end_ = gfx::Rect( |
| 234 balloon_->GetPosition().x(), balloon_->GetPosition().y(), | 234 balloon_->GetPosition().x(), balloon_->GetPosition().y(), |
| 235 GetTotalWidth(), GetTotalHeight()); | 235 GetTotalWidth(), GetTotalHeight()); |
| 236 anim_frame_start_ = frame_container_->GetClientAreaScreenBounds(); | 236 anim_frame_start_ = frame_container_->GetClientAreaScreenBounds(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 265 e * anim_frame_end_.height())); | 265 e * anim_frame_end_.height())); |
| 266 frame_container_->SetBounds(frame_position); | 266 frame_container_->SetBounds(frame_position); |
| 267 | 267 |
| 268 gfx::Path path; | 268 gfx::Path path; |
| 269 gfx::Rect contents_rect = GetContentsRectangle(); | 269 gfx::Rect contents_rect = GetContentsRectangle(); |
| 270 html_container_->SetBounds(contents_rect); | 270 html_container_->SetBounds(contents_rect); |
| 271 GetContentsMask(contents_rect, &path); | 271 GetContentsMask(contents_rect, &path); |
| 272 html_container_->SetShape(path.CreateNativeRegion()); | 272 html_container_->SetShape(path.CreateNativeRegion()); |
| 273 | 273 |
| 274 html_contents_->SetPreferredSize(contents_rect.size()); | 274 html_contents_->SetPreferredSize(contents_rect.size()); |
| 275 RenderWidgetHostView* view = | 275 content::RenderWidgetHostView* view = |
| 276 html_contents_->web_contents()->GetRenderWidgetHostView(); | 276 html_contents_->web_contents()->GetRenderWidgetHostView(); |
| 277 if (view) | 277 if (view) |
| 278 view->SetSize(contents_rect.size()); | 278 view->SetSize(contents_rect.size()); |
| 279 } | 279 } |
| 280 | 280 |
| 281 gfx::Rect BalloonViewImpl::GetCloseButtonBounds() const { | 281 gfx::Rect BalloonViewImpl::GetCloseButtonBounds() const { |
| 282 return gfx::Rect( | 282 return gfx::Rect( |
| 283 width() - kDismissButtonWidth - | 283 width() - kDismissButtonWidth - |
| 284 kDismissButtonRightMargin - kRightShadowWidth, | 284 kDismissButtonRightMargin - kRightShadowWidth, |
| 285 kDismissButtonTopMargin, | 285 kDismissButtonTopMargin, |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 return; | 532 return; |
| 533 } | 533 } |
| 534 | 534 |
| 535 // If the renderer process attached to this balloon is disconnected | 535 // If the renderer process attached to this balloon is disconnected |
| 536 // (e.g., because of a crash), we want to close the balloon. | 536 // (e.g., because of a crash), we want to close the balloon. |
| 537 notification_registrar_.Remove( | 537 notification_registrar_.Remove( |
| 538 this, chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, | 538 this, chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, |
| 539 content::Source<Balloon>(balloon_)); | 539 content::Source<Balloon>(balloon_)); |
| 540 Close(false); | 540 Close(false); |
| 541 } | 541 } |
| OLD | NEW |