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/chromeos/notifications/balloon_view.h" | 5 #include "chrome/browser/chromeos/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/chromeos/notifications/balloon_view_host.h" | 11 #include "chrome/browser/chromeos/notifications/balloon_view_host.h" |
12 #include "chrome/browser/chromeos/notifications/notification_panel.h" | 12 #include "chrome/browser/chromeos/notifications/notification_panel.h" |
13 #include "chrome/browser/notifications/balloon.h" | 13 #include "chrome/browser/notifications/balloon.h" |
14 #include "chrome/browser/notifications/desktop_notification_service.h" | 14 #include "chrome/browser/notifications/desktop_notification_service.h" |
15 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 15 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
16 #include "chrome/browser/notifications/notification.h" | 16 #include "chrome/browser/notifications/notification.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/ui/views/notifications/balloon_view_host.h" | 18 #include "chrome/browser/ui/views/notifications/balloon_view_host.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" | 20 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 21 #include "chrome/common/chrome_notification_types.h" |
21 #include "content/common/notification_details.h" | 22 #include "content/common/notification_details.h" |
22 #include "content/common/notification_source.h" | 23 #include "content/common/notification_source.h" |
23 #include "content/common/notification_type.h" | |
24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
25 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
27 #include "ui/base/models/simple_menu_model.h" | 27 #include "ui/base/models/simple_menu_model.h" |
28 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
29 #include "views/background.h" | 29 #include "views/background.h" |
30 #include "views/controls/button/button.h" | 30 #include "views/controls/button/button.h" |
31 #include "views/controls/button/image_button.h" | 31 #include "views/controls/button/image_button.h" |
32 #include "views/controls/button/menu_button.h" | 32 #include "views/controls/button/menu_button.h" |
33 #include "views/controls/label.h" | 33 #include "views/controls/label.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 //////////////////////////////////////////////////////////////////////////////// | 220 //////////////////////////////////////////////////////////////////////////////// |
221 // BallonViewImpl, BalloonView implementation. | 221 // BallonViewImpl, BalloonView implementation. |
222 | 222 |
223 void BalloonViewImpl::Show(Balloon* balloon) { | 223 void BalloonViewImpl::Show(Balloon* balloon) { |
224 balloon_ = balloon; | 224 balloon_ = balloon; |
225 html_contents_ = new BalloonViewHost(balloon); | 225 html_contents_ = new BalloonViewHost(balloon); |
226 if (web_ui_) | 226 if (web_ui_) |
227 html_contents_->EnableWebUI(); | 227 html_contents_->EnableWebUI(); |
228 AddChildView(html_contents_->view()); | 228 AddChildView(html_contents_->view()); |
229 notification_registrar_.Add(this, | 229 notification_registrar_.Add(this, |
230 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon)); | 230 chrome::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon)); |
231 } | 231 } |
232 | 232 |
233 void BalloonViewImpl::Update() { | 233 void BalloonViewImpl::Update() { |
234 stale_ = false; | 234 stale_ = false; |
235 if (html_contents_->render_view_host()) | 235 if (html_contents_->render_view_host()) |
236 html_contents_->render_view_host()->NavigateToURL( | 236 html_contents_->render_view_host()->NavigateToURL( |
237 balloon_->notification().content_url()); | 237 balloon_->notification().content_url()); |
238 } | 238 } |
239 | 239 |
240 void BalloonViewImpl::Close(bool by_user) { | 240 void BalloonViewImpl::Close(bool by_user) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 control_view_host_.release()->CloseNow(); | 291 control_view_host_.release()->CloseNow(); |
292 } | 292 } |
293 | 293 |
294 gfx::Size BalloonViewImpl::GetPreferredSize() { | 294 gfx::Size BalloonViewImpl::GetPreferredSize() { |
295 return gfx::Size(1000, 1000); | 295 return gfx::Size(1000, 1000); |
296 } | 296 } |
297 | 297 |
298 //////////////////////////////////////////////////////////////////////////////// | 298 //////////////////////////////////////////////////////////////////////////////// |
299 // NotificationObserver overrides. | 299 // NotificationObserver overrides. |
300 | 300 |
301 void BalloonViewImpl::Observe(NotificationType type, | 301 void BalloonViewImpl::Observe(int type, |
302 const NotificationSource& source, | 302 const NotificationSource& source, |
303 const NotificationDetails& details) { | 303 const NotificationDetails& details) { |
304 if (type != NotificationType::NOTIFY_BALLOON_DISCONNECTED) { | 304 if (type != chrome::NOTIFY_BALLOON_DISCONNECTED) { |
305 NOTREACHED(); | 305 NOTREACHED(); |
306 return; | 306 return; |
307 } | 307 } |
308 | 308 |
309 // If the renderer process attached to this balloon is disconnected | 309 // If the renderer process attached to this balloon is disconnected |
310 // (e.g., because of a crash), we want to close the balloon. | 310 // (e.g., because of a crash), we want to close the balloon. |
311 notification_registrar_.Remove(this, | 311 notification_registrar_.Remove(this, |
312 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_)); | 312 chrome::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_)); |
313 Close(false); | 313 Close(false); |
314 } | 314 } |
315 | 315 |
316 //////////////////////////////////////////////////////////////////////////////// | 316 //////////////////////////////////////////////////////////////////////////////// |
317 // BalloonViewImpl public. | 317 // BalloonViewImpl public. |
318 | 318 |
319 bool BalloonViewImpl::IsFor(const Notification& notification) const { | 319 bool BalloonViewImpl::IsFor(const Notification& notification) const { |
320 return balloon_->notification().notification_id() == | 320 return balloon_->notification().notification_id() == |
321 notification.notification_id(); | 321 notification.notification_id(); |
322 } | 322 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 service->DenyPermission(balloon_->notification().origin_url()); | 356 service->DenyPermission(balloon_->notification().origin_url()); |
357 } | 357 } |
358 | 358 |
359 gfx::NativeView BalloonViewImpl::GetParentNativeView() { | 359 gfx::NativeView BalloonViewImpl::GetParentNativeView() { |
360 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); | 360 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); |
361 DCHECK(view); | 361 DCHECK(view); |
362 return view->GetNativeView(); | 362 return view->GetNativeView(); |
363 } | 363 } |
364 | 364 |
365 } // namespace chromeos | 365 } // namespace chromeos |
OLD | NEW |