| 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/notifications/message_center_notification_manager.h" | 5 #include "chrome/browser/notifications/message_center_notification_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 // Set the image directly if we have it. | 401 // Set the image directly if we have it. |
| 402 if (image && !image->IsEmpty()) { | 402 if (image && !image->IsEmpty()) { |
| 403 callback.Run(*image); | 403 callback.Run(*image); |
| 404 return; | 404 return; |
| 405 } | 405 } |
| 406 | 406 |
| 407 // Leave the image null if there's no URL. | 407 // Leave the image null if there's no URL. |
| 408 if (url.is_empty()) | 408 if (url.is_empty()) |
| 409 return; | 409 return; |
| 410 | 410 |
| 411 content::WebContents* contents = notification.GetWebContents(); | 411 content::WebContents* contents = notification.delegate()->GetWebContents(); |
| 412 if (!contents) { | 412 if (!contents) { |
| 413 LOG(WARNING) << "Notification needs an image but has no WebContents"; | 413 LOG(WARNING) << "Notification needs an image but has no WebContents"; |
| 414 return; | 414 return; |
| 415 } | 415 } |
| 416 | 416 |
| 417 AddPendingDownload(); | 417 AddPendingDownload(); |
| 418 | 418 |
| 419 contents->DownloadImage( | 419 contents->DownloadImage( |
| 420 url, | 420 url, |
| 421 false, // Not a favicon | 421 false, // Not a favicon |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 472 |
| 473 MessageCenterNotificationManager::ProfileNotification::~ProfileNotification() { | 473 MessageCenterNotificationManager::ProfileNotification::~ProfileNotification() { |
| 474 } | 474 } |
| 475 | 475 |
| 476 void MessageCenterNotificationManager::ProfileNotification::StartDownloads() { | 476 void MessageCenterNotificationManager::ProfileNotification::StartDownloads() { |
| 477 downloads_->StartDownloads(notification_); | 477 downloads_->StartDownloads(notification_); |
| 478 } | 478 } |
| 479 | 479 |
| 480 void | 480 void |
| 481 MessageCenterNotificationManager::ProfileNotification::OnDownloadsCompleted() { | 481 MessageCenterNotificationManager::ProfileNotification::OnDownloadsCompleted() { |
| 482 notification_.DoneRendering(); | 482 notification_.delegate()->ReleaseRenderViewHost(); |
| 483 } | 483 } |
| 484 | 484 |
| 485 void | 485 void |
| 486 MessageCenterNotificationManager::ProfileNotification::AddToAlternateProvider( | 486 MessageCenterNotificationManager::ProfileNotification::AddToAlternateProvider( |
| 487 const std::string extension_id) { | 487 const std::string extension_id) { |
| 488 // Convert data from Notification type to NotificationOptions type. | 488 // Convert data from Notification type to NotificationOptions type. |
| 489 extensions::api::notifications::NotificationOptions options; | 489 extensions::api::notifications::NotificationOptions options; |
| 490 NotificationConversionHelper::NotificationToNotificationOptions(notification_, | 490 NotificationConversionHelper::NotificationToNotificationOptions(notification_, |
| 491 &options); | 491 &options); |
| 492 | 492 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 it != registry->enabled_extensions().end(); | 540 it != registry->enabled_extensions().end(); |
| 541 ++it) { | 541 ++it) { |
| 542 if ((*it->get()).permissions_data()->HasAPIPermission( | 542 if ((*it->get()).permissions_data()->HasAPIPermission( |
| 543 extensions::APIPermission::ID::kNotificationProvider)) { | 543 extensions::APIPermission::ID::kNotificationProvider)) { |
| 544 extension_id = (*it->get()).id(); | 544 extension_id = (*it->get()).id(); |
| 545 return extension_id; | 545 return extension_id; |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 return extension_id; | 548 return extension_id; |
| 549 } | 549 } |
| OLD | NEW |