Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Unified Diff: content/browser/manifest/manifest_manager_host.cc

Issue 537053002: Implement ManifestManager to handle manifest in content/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@manifest_fetcher
Patch Set: with tests Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698