Index: content/browser/manifest/manifest_manager_host.cc |
diff --git a/content/browser/manifest/manifest_manager_host.cc b/content/browser/manifest/manifest_manager_host.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2e5fbda37b94c5c6c530a9bd52930eacf5ae8200 |
--- /dev/null |
+++ b/content/browser/manifest/manifest_manager_host.cc |
@@ -0,0 +1,54 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/browser/manifest/manifest_manager_host.h" |
+ |
+#include "content/common/manifest_manager_messages.h" |
+#include "content/public/browser/render_frame_host.h" |
+#include "content/public/common/manifest.h" |
+ |
+namespace content { |
+ |
+ManifestManagerHost::ManifestManagerHost(WebContents* web_contents) |
+ : WebContentsObserver(web_contents) { |
+} |
+ |
+ManifestManagerHost::~ManifestManagerHost() { |
+} |
+ |
+void ManifestManagerHost::GetManifest(RenderFrameHost* render_frame_host, |
+ const GetManifestCallback& callback) { |
+ int request_id = pending_callbacks_.Add(new GetManifestCallback(callback)); |
+ |
+ render_frame_host->Send(new ManifestManagerMsg_RequestManifest( |
+ render_frame_host->GetRoutingID(), request_id)); |
+} |
+ |
+bool ManifestManagerHost::OnMessageReceived( |
+ const IPC::Message& message, RenderFrameHost* render_frame_host) { |
+ bool handled = true; |
+ |
+ IPC_BEGIN_MESSAGE_MAP(ManifestManagerHost, message) |
+ IPC_MESSAGE_HANDLER(ManifestManagerHostMsg_RequestManifestResponse, |
+ OnRequestManifestResponse) |
+ IPC_MESSAGE_UNHANDLED(handled = false) |
+ IPC_END_MESSAGE_MAP() |
+ |
+ return handled; |
+} |
+ |
+void ManifestManagerHost::OnRequestManifestResponse(int request_id, |
+ const Manifest& manifest) { |
+ GetManifestCallback* callback = pending_callbacks_.Lookup(request_id); |
+ if (!callback) { |
+ LOG(ERROR) << "Received a request_id (" << request_id << ") from renderer " |
+ "with no associated callabck."; |
+ return; |
+ } |
+ |
+ callback->Run(manifest); |
+ pending_callbacks_.Remove(request_id); |
+} |
+ |
+} // namespace content |