| 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" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 //////////////////////////////////////////////////////////////////////////////// | 209 //////////////////////////////////////////////////////////////////////////////// |
| 210 // BallonViewImpl, BalloonView implementation. | 210 // BallonViewImpl, BalloonView implementation. |
| 211 | 211 |
| 212 void BalloonViewImpl::Show(Balloon* balloon) { | 212 void BalloonViewImpl::Show(Balloon* balloon) { |
| 213 balloon_ = balloon; | 213 balloon_ = balloon; |
| 214 html_contents_ = new BalloonViewHost(balloon); | 214 html_contents_ = new BalloonViewHost(balloon); |
| 215 if (web_ui_) | 215 if (web_ui_) |
| 216 html_contents_->EnableWebUI(); | 216 html_contents_->EnableWebUI(); |
| 217 AddChildView(html_contents_->view()); | 217 AddChildView(html_contents_->view()); |
| 218 notification_registrar_.Add(this, | 218 notification_registrar_.Add(this, |
| 219 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon)); | 219 chrome::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon)); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void BalloonViewImpl::Update() { | 222 void BalloonViewImpl::Update() { |
| 223 stale_ = false; | 223 stale_ = false; |
| 224 if (html_contents_->render_view_host()) | 224 if (html_contents_->render_view_host()) |
| 225 html_contents_->render_view_host()->NavigateToURL( | 225 html_contents_->render_view_host()->NavigateToURL( |
| 226 balloon_->notification().content_url()); | 226 balloon_->notification().content_url()); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void BalloonViewImpl::Close(bool by_user) { | 229 void BalloonViewImpl::Close(bool by_user) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 gfx::Size BalloonViewImpl::GetPreferredSize() { | 283 gfx::Size BalloonViewImpl::GetPreferredSize() { |
| 284 return gfx::Size(1000, 1000); | 284 return gfx::Size(1000, 1000); |
| 285 } | 285 } |
| 286 | 286 |
| 287 //////////////////////////////////////////////////////////////////////////////// | 287 //////////////////////////////////////////////////////////////////////////////// |
| 288 // NotificationObserver overrides. | 288 // NotificationObserver overrides. |
| 289 | 289 |
| 290 void BalloonViewImpl::Observe(NotificationType type, | 290 void BalloonViewImpl::Observe(NotificationType type, |
| 291 const NotificationSource& source, | 291 const NotificationSource& source, |
| 292 const NotificationDetails& details) { | 292 const NotificationDetails& details) { |
| 293 if (type != NotificationType::NOTIFY_BALLOON_DISCONNECTED) { | 293 if (type != chrome::NOTIFY_BALLOON_DISCONNECTED) { |
| 294 NOTREACHED(); | 294 NOTREACHED(); |
| 295 return; | 295 return; |
| 296 } | 296 } |
| 297 | 297 |
| 298 // If the renderer process attached to this balloon is disconnected | 298 // If the renderer process attached to this balloon is disconnected |
| 299 // (e.g., because of a crash), we want to close the balloon. | 299 // (e.g., because of a crash), we want to close the balloon. |
| 300 notification_registrar_.Remove(this, | 300 notification_registrar_.Remove(this, |
| 301 NotificationType::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_)); | 301 chrome::NOTIFY_BALLOON_DISCONNECTED, Source<Balloon>(balloon_)); |
| 302 Close(false); | 302 Close(false); |
| 303 } | 303 } |
| 304 | 304 |
| 305 //////////////////////////////////////////////////////////////////////////////// | 305 //////////////////////////////////////////////////////////////////////////////// |
| 306 // BalloonViewImpl public. | 306 // BalloonViewImpl public. |
| 307 | 307 |
| 308 bool BalloonViewImpl::IsFor(const Notification& notification) const { | 308 bool BalloonViewImpl::IsFor(const Notification& notification) const { |
| 309 return balloon_->notification().notification_id() == | 309 return balloon_->notification().notification_id() == |
| 310 notification.notification_id(); | 310 notification.notification_id(); |
| 311 } | 311 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 service->DenyPermission(balloon_->notification().origin_url()); | 345 service->DenyPermission(balloon_->notification().origin_url()); |
| 346 } | 346 } |
| 347 | 347 |
| 348 gfx::NativeView BalloonViewImpl::GetParentNativeView() { | 348 gfx::NativeView BalloonViewImpl::GetParentNativeView() { |
| 349 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); | 349 RenderWidgetHostView* view = html_contents_->render_view_host()->view(); |
| 350 DCHECK(view); | 350 DCHECK(view); |
| 351 return view->GetNativeView(); | 351 return view->GetNativeView(); |
| 352 } | 352 } |
| 353 | 353 |
| 354 } // namespace chromeos | 354 } // namespace chromeos |
| OLD | NEW |