| OLD | NEW |
| 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/ui/views/notifications/balloon_view.h" | 5 #include "chrome/browser/ui/views/notifications/balloon_view.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/notifications/balloon.h" | 11 #include "chrome/browser/notifications/balloon.h" |
| 12 #include "chrome/browser/notifications/balloon_collection.h" | 12 #include "chrome/browser/notifications/balloon_collection.h" |
| 13 #include "chrome/browser/notifications/desktop_notification_service.h" | 13 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 14 #include "chrome/browser/notifications/notification.h" | 14 #include "chrome/browser/notifications/notification.h" |
| 15 #include "chrome/browser/notifications/notification_options_menu_model.h" | 15 #include "chrome/browser/notifications/notification_options_menu_model.h" |
| 16 #include "chrome/browser/ui/views/bubble/bubble_border.h" | 16 #include "chrome/browser/ui/views/bubble/bubble_border.h" |
| 17 #include "chrome/browser/ui/views/notifications/balloon_view_host.h" | 17 #include "chrome/browser/ui/views/notifications/balloon_view_host.h" |
| 18 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "content/browser/renderer_host/render_view_host.h" | 19 #include "content/browser/renderer_host/render_view_host.h" |
| 19 #include "content/browser/renderer_host/render_widget_host_view.h" | 20 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 21 #include "content/common/content_notification_types.h" |
| 20 #include "content/common/notification_details.h" | 22 #include "content/common/notification_details.h" |
| 21 #include "content/common/notification_source.h" | 23 #include "content/common/notification_source.h" |
| 22 #include "content/common/notification_type.h" | |
| 23 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 24 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
| 25 #include "grit/theme_resources_standard.h" | 26 #include "grit/theme_resources_standard.h" |
| 26 #include "ui/base/animation/slide_animation.h" | 27 #include "ui/base/animation/slide_animation.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| 29 #include "ui/gfx/canvas_skia.h" | 30 #include "ui/gfx/canvas_skia.h" |
| 30 #include "ui/gfx/insets.h" | 31 #include "ui/gfx/insets.h" |
| 31 #include "ui/gfx/native_widget_types.h" | 32 #include "ui/gfx/native_widget_types.h" |
| 32 #include "views/controls/button/button.h" | 33 #include "views/controls/button/button.h" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 351 |
| 351 source_label_->SetFont(rb.GetFont(ResourceBundle::SmallFont)); | 352 source_label_->SetFont(rb.GetFont(ResourceBundle::SmallFont)); |
| 352 source_label_->SetColor(kControlBarTextColor); | 353 source_label_->SetColor(kControlBarTextColor); |
| 353 source_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 354 source_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 354 source_label_->SetBoundsRect(GetLabelBounds()); | 355 source_label_->SetBoundsRect(GetLabelBounds()); |
| 355 | 356 |
| 356 SizeContentsWindow(); | 357 SizeContentsWindow(); |
| 357 html_container_->Show(); | 358 html_container_->Show(); |
| 358 frame_container_->Show(); | 359 frame_container_->Show(); |
| 359 | 360 |
| 360 notification_registrar_.Add(this, | 361 notification_registrar_.Add( |
| 361 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon)); | 362 this, chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, |
| 363 Source<Balloon>(balloon)); |
| 362 } | 364 } |
| 363 | 365 |
| 364 void BalloonViewImpl::RunOptionsMenu(const gfx::Point& pt) { | 366 void BalloonViewImpl::RunOptionsMenu(const gfx::Point& pt) { |
| 365 CreateOptionsMenu(); | 367 CreateOptionsMenu(); |
| 366 options_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); | 368 options_menu_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); |
| 367 } | 369 } |
| 368 | 370 |
| 369 void BalloonViewImpl::CreateOptionsMenu() { | 371 void BalloonViewImpl::CreateOptionsMenu() { |
| 370 if (options_menu_model_.get()) | 372 if (options_menu_model_.get()) |
| 371 return; | 373 return; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 kLeftMargin, 1 + GetShelfHeight(), line_width, 1); | 483 kLeftMargin, 1 + GetShelfHeight(), line_width, 1); |
| 482 | 484 |
| 483 View::OnPaint(canvas); | 485 View::OnPaint(canvas); |
| 484 OnPaintBorder(canvas); | 486 OnPaintBorder(canvas); |
| 485 } | 487 } |
| 486 | 488 |
| 487 void BalloonViewImpl::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 489 void BalloonViewImpl::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 488 SizeContentsWindow(); | 490 SizeContentsWindow(); |
| 489 } | 491 } |
| 490 | 492 |
| 491 void BalloonViewImpl::Observe(NotificationType type, | 493 void BalloonViewImpl::Observe(int type, |
| 492 const NotificationSource& source, | 494 const NotificationSource& source, |
| 493 const NotificationDetails& details) { | 495 const NotificationDetails& details) { |
| 494 if (type != NotificationType::NOTIFY_BALLOON_DISCONNECTED) { | 496 if (type != chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED) { |
| 495 NOTREACHED(); | 497 NOTREACHED(); |
| 496 return; | 498 return; |
| 497 } | 499 } |
| 498 | 500 |
| 499 // If the renderer process attached to this balloon is disconnected | 501 // If the renderer process attached to this balloon is disconnected |
| 500 // (e.g., because of a crash), we want to close the balloon. | 502 // (e.g., because of a crash), we want to close the balloon. |
| 501 notification_registrar_.Remove(this, | 503 notification_registrar_.Remove( |
| 502 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_)); | 504 this, chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, |
| 505 Source<Balloon>(balloon_)); |
| 503 Close(false); | 506 Close(false); |
| 504 } | 507 } |
| OLD | NEW |