Chromium Code Reviews| Index: content/renderer/manifest/manifest_manager.cc |
| diff --git a/content/renderer/manifest/manifest_manager.cc b/content/renderer/manifest/manifest_manager.cc |
| index fda8c835e64796aea0195be181c8254cca309c3d..ea6cfe9d4e40432dfc6e046e13e2718789e5c6df 100644 |
| --- a/content/renderer/manifest/manifest_manager.cc |
| +++ b/content/renderer/manifest/manifest_manager.cc |
| @@ -6,7 +6,7 @@ |
| #include "base/bind.h" |
| #include "base/strings/nullable_string16.h" |
| -#include "content/common/manifest_manager_messages.h" |
| +#include "content/common/manifest_type_converters.h" |
| #include "content/public/renderer/render_frame.h" |
| #include "content/renderer/fetchers/manifest_fetcher.h" |
| #include "content/renderer/manifest/manifest_parser.h" |
| @@ -34,60 +34,21 @@ ManifestManager::~ManifestManager() { |
| ResolveCallbacks(ResolveStateFailure); |
| } |
| -bool ManifestManager::OnMessageReceived(const IPC::Message& message) { |
| - bool handled = true; |
| - |
| - IPC_BEGIN_MESSAGE_MAP(ManifestManager, message) |
| - IPC_MESSAGE_HANDLER(ManifestManagerMsg_HasManifest, OnHasManifest) |
| - IPC_MESSAGE_HANDLER(ManifestManagerMsg_RequestManifest, OnRequestManifest) |
| - IPC_MESSAGE_UNHANDLED(handled = false) |
| - IPC_END_MESSAGE_MAP() |
| - |
| - return handled; |
| -} |
| - |
| -void ManifestManager::OnHasManifest(int request_id) { |
| +void ManifestManager::HasManifest(const HasManifestCallback& callback) { |
| GURL url(render_frame()->GetWebFrame()->document().manifestURL()); |
| - bool has_manifest = may_have_manifest_ && !url.is_empty(); |
| - Send(new ManifestManagerHostMsg_HasManifestResponse( |
| - routing_id(), request_id, has_manifest)); |
| + callback.Run(may_have_manifest_ && !url.is_empty()); |
| } |
| -void ManifestManager::OnRequestManifest(int request_id) { |
| +void ManifestManager::RequestManifest(const RequestManifestCallback& callback) { |
| GetManifest(base::Bind(&ManifestManager::OnRequestManifestComplete, |
| - base::Unretained(this), request_id)); |
| + base::Unretained(this), callback)); |
| } |
| void ManifestManager::OnRequestManifestComplete( |
| - int request_id, const Manifest& manifest) { |
| - // When sent via IPC, the Manifest must follow certain security rules. |
| - Manifest ipc_manifest = manifest; |
| - ipc_manifest.name = base::NullableString16( |
| - ipc_manifest.name.string().substr(0, Manifest::kMaxIPCStringLength), |
| - ipc_manifest.name.is_null()); |
| - ipc_manifest.short_name = base::NullableString16( |
| - ipc_manifest.short_name.string().substr(0, |
| - Manifest::kMaxIPCStringLength), |
| - ipc_manifest.short_name.is_null()); |
| - for (auto& icon : ipc_manifest.icons) { |
| - icon.type = base::NullableString16( |
| - icon.type.string().substr(0, Manifest::kMaxIPCStringLength), |
| - icon.type.is_null()); |
| - } |
| - ipc_manifest.gcm_sender_id = base::NullableString16( |
| - ipc_manifest.gcm_sender_id.string().substr( |
| - 0, Manifest::kMaxIPCStringLength), |
| - ipc_manifest.gcm_sender_id.is_null()); |
| - for (auto& related_application : ipc_manifest.related_applications) { |
| - related_application.id = |
| - base::NullableString16(related_application.id.string().substr( |
| - 0, Manifest::kMaxIPCStringLength), |
| - related_application.id.is_null()); |
| - } |
| - |
| - Send(new ManifestManagerHostMsg_RequestManifestResponse( |
| - routing_id(), request_id, ipc_manifest)); |
| + const RequestManifestCallback& callback, |
| + const Manifest& manifest) { |
| + callback.Run(blink::mojom::Manifest::From(manifest)); |
| } |
| void ManifestManager::GetManifest(const GetManifestCallback& callback) { |
| @@ -190,14 +151,17 @@ void ManifestManager::ResolveCallbacks(ResolveState state) { |
| manifest_dirty_ = state != ResolveStateSuccess; |
| Manifest manifest = manifest_; |
| - std::list<GetManifestCallback> callbacks = pending_callbacks_; |
| - |
| + std::vector<GetManifestCallback> callbacks = std::move(pending_callbacks_); |
| pending_callbacks_.clear(); |
| - for (std::list<GetManifestCallback>::const_iterator it = callbacks.begin(); |
| - it != callbacks.end(); ++it) { |
| - it->Run(manifest); |
| + for (const auto& callback : callbacks) { |
| + callback.Run(manifest); |
| } |
|
mlamouri (slow - plz ping)
2016/04/27 13:38:08
style: remove { }
Sam McNally
2016/04/28 08:25:28
Done.
|
| } |
| -} // namespace content |
| +void ManifestManager::BindToRequest( |
| + blink::mojom::ManifestManagerRequest request) { |
| + bindings_.AddBinding(this, std::move(request)); |
| +} |
| + |
| +} // namespace content |