| Index: third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.cpp
|
| diff --git a/third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.cpp b/third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.cpp
|
| index 365512a55618e56ba75216808cd9acd886f4d5ec..cfdfe39c3ad4d5e6fdc049677a2161214bdfe394 100644
|
| --- a/third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.cpp
|
| +++ b/third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.cpp
|
| @@ -4,10 +4,9 @@
|
|
|
| #include "modules/notifications/NotificationResourcesLoader.h"
|
|
|
| +#include "platform/bitmap_type_converters.h"
|
| #include "platform/weborigin/KURL.h"
|
| #include "public/platform/modules/notifications/WebNotificationConstants.h"
|
| -#include "public/platform/modules/notifications/WebNotificationData.h"
|
| -#include "public/platform/modules/notifications/WebNotificationResources.h"
|
| #include "skia/ext/image_operations.h"
|
| #include "third_party/skia/include/core/SkBitmap.h"
|
|
|
| @@ -29,7 +28,7 @@ SkBitmap scaleDownIfNeeded(const SkBitmap& image, int maxSizePx)
|
| } // namespace
|
|
|
| NotificationResourcesLoader::NotificationResourcesLoader(PassOwnPtr<CompletionCallback> completionCallback)
|
| - : m_started(false), m_completionCallback(std::move(completionCallback)), m_pendingRequestCount(0)
|
| + : m_completionCallback(std::move(completionCallback)), m_pendingRequestCount(0)
|
| {
|
| ThreadState::current()->registerPreFinalizer(this);
|
| DCHECK(m_completionCallback);
|
| @@ -39,28 +38,34 @@ NotificationResourcesLoader::~NotificationResourcesLoader()
|
| {
|
| }
|
|
|
| -void NotificationResourcesLoader::start(ExecutionContext* executionContext, const WebNotificationData& notificationData)
|
| +void NotificationResourcesLoader::start(ExecutionContext* executionContext, mojom::blink::NotificationPtr notification)
|
| {
|
| - DCHECK(!m_started);
|
| - m_started = true;
|
| + DCHECK(m_notification.is_null());
|
| + DCHECK(!notification.is_null());
|
|
|
| - size_t numActions = notificationData.actions.size();
|
| + m_notification = std::move(notification);
|
| +
|
| + size_t numActions = m_notification->actions.size();
|
| m_pendingRequestCount = 2 /* icon and badge */ + numActions;
|
|
|
| - loadImage(executionContext, notificationData.icon, bind<const SkBitmap&>(&NotificationResourcesLoader::didLoadIcon, WeakPersistentThisPointer<NotificationResourcesLoader>(this)));
|
| - loadImage(executionContext, notificationData.badge, bind<const SkBitmap&>(&NotificationResourcesLoader::didLoadBadge, WeakPersistentThisPointer<NotificationResourcesLoader>(this)));
|
| + loadImage(executionContext, KURL(ParsedURLString, m_notification->icon), bind<const SkBitmap&>(&NotificationResourcesLoader::didLoadIcon, WeakPersistentThisPointer<NotificationResourcesLoader>(this)));
|
| + loadImage(executionContext, KURL(ParsedURLString, m_notification->badge), bind<const SkBitmap&>(&NotificationResourcesLoader::didLoadBadge, WeakPersistentThisPointer<NotificationResourcesLoader>(this)));
|
|
|
| m_actionIcons.resize(numActions);
|
| for (size_t i = 0; i < numActions; i++)
|
| - loadImage(executionContext, notificationData.actions[i].icon, bind<const SkBitmap&>(&NotificationResourcesLoader::didLoadActionIcon, WeakPersistentThisPointer<NotificationResourcesLoader>(this), i));
|
| + loadImage(executionContext, KURL(ParsedURLString, m_notification->actions[i]->icon), bind<const SkBitmap&>(&NotificationResourcesLoader::didLoadActionIcon, WeakPersistentThisPointer<NotificationResourcesLoader>(this), i));
|
| }
|
|
|
| -std::unique_ptr<WebNotificationResources> NotificationResourcesLoader::getResources() const
|
| +mojom::blink::NotificationResourcesPtr NotificationResourcesLoader::getResources() const
|
| {
|
| - std::unique_ptr<WebNotificationResources> resources(new WebNotificationResources());
|
| - resources->icon = m_icon;
|
| - resources->badge = m_badge;
|
| - resources->actionIcons = m_actionIcons;
|
| + mojom::blink::NotificationResourcesPtr resources = mojom::blink::NotificationResources::New();
|
| + resources->icon = mojom::blink::Bitmap::From(m_icon);
|
| + resources->badge = mojom::blink::Bitmap::From(m_badge);
|
| +
|
| + resources->action_icons.resize(m_actionIcons.size());
|
| + for (size_t i = 0; i < m_actionIcons.size(); i++)
|
| + resources->action_icons[i] = mojom::blink::Bitmap::From(m_actionIcons[i]);
|
| +
|
| return resources;
|
| }
|
|
|
| @@ -113,7 +118,8 @@ void NotificationResourcesLoader::didFinishRequest()
|
| m_pendingRequestCount--;
|
| if (!m_pendingRequestCount) {
|
| stop();
|
| - (*m_completionCallback)(this);
|
| +
|
| + (*m_completionCallback)(this, std::move(m_notification));
|
| // The |this| pointer may have been deleted now.
|
| }
|
| }
|
|
|