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

Side by Side Diff: content/renderer/manifest/manifest_manager.cc

Issue 2064943002: Pass in extra parameters to WebApkBuilder#buildWebApkAsync() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into webapk_manifest000 Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/renderer/manifest/manifest_manager.h" 5 #include "content/renderer/manifest/manifest_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/nullable_string16.h" 8 #include "base/strings/nullable_string16.h"
9 #include "content/common/manifest_manager_messages.h" 9 #include "content/common/manifest_manager_messages.h"
10 #include "content/public/renderer/render_frame.h" 10 #include "content/public/renderer/render_frame.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 bool has_manifest = may_have_manifest_ && !url.is_empty(); 52 bool has_manifest = may_have_manifest_ && !url.is_empty();
53 Send(new ManifestManagerHostMsg_HasManifestResponse( 53 Send(new ManifestManagerHostMsg_HasManifestResponse(
54 routing_id(), request_id, has_manifest)); 54 routing_id(), request_id, has_manifest));
55 } 55 }
56 56
57 void ManifestManager::OnRequestManifest(int request_id) { 57 void ManifestManager::OnRequestManifest(int request_id) {
58 GetManifest(base::Bind(&ManifestManager::OnRequestManifestComplete, 58 GetManifest(base::Bind(&ManifestManager::OnRequestManifestComplete,
59 base::Unretained(this), request_id)); 59 base::Unretained(this), request_id));
60 } 60 }
61 61
62 void ManifestManager::OnRequestManifestComplete( 62 void ManifestManager::OnRequestManifestComplete(int request_id,
63 int request_id, const Manifest& manifest, 63 const GURL& manifest_url,
64 const ManifestDebugInfo&) { 64 const Manifest& manifest,
65 const ManifestDebugInfo&) {
65 // When sent via IPC, the Manifest must follow certain security rules. 66 // When sent via IPC, the Manifest must follow certain security rules.
66 Manifest ipc_manifest = manifest; 67 Manifest ipc_manifest = manifest;
67 ipc_manifest.name = base::NullableString16( 68 ipc_manifest.name = base::NullableString16(
68 ipc_manifest.name.string().substr(0, Manifest::kMaxIPCStringLength), 69 ipc_manifest.name.string().substr(0, Manifest::kMaxIPCStringLength),
69 ipc_manifest.name.is_null()); 70 ipc_manifest.name.is_null());
70 ipc_manifest.short_name = base::NullableString16( 71 ipc_manifest.short_name = base::NullableString16(
71 ipc_manifest.short_name.string().substr(0, 72 ipc_manifest.short_name.string().substr(0,
72 Manifest::kMaxIPCStringLength), 73 Manifest::kMaxIPCStringLength),
73 ipc_manifest.short_name.is_null()); 74 ipc_manifest.short_name.is_null());
74 for (auto& icon : ipc_manifest.icons) { 75 for (auto& icon : ipc_manifest.icons) {
75 icon.type = base::NullableString16( 76 icon.type = base::NullableString16(
76 icon.type.string().substr(0, Manifest::kMaxIPCStringLength), 77 icon.type.string().substr(0, Manifest::kMaxIPCStringLength),
77 icon.type.is_null()); 78 icon.type.is_null());
78 } 79 }
79 ipc_manifest.gcm_sender_id = base::NullableString16( 80 ipc_manifest.gcm_sender_id = base::NullableString16(
80 ipc_manifest.gcm_sender_id.string().substr( 81 ipc_manifest.gcm_sender_id.string().substr(
81 0, Manifest::kMaxIPCStringLength), 82 0, Manifest::kMaxIPCStringLength),
82 ipc_manifest.gcm_sender_id.is_null()); 83 ipc_manifest.gcm_sender_id.is_null());
83 for (auto& related_application : ipc_manifest.related_applications) { 84 for (auto& related_application : ipc_manifest.related_applications) {
84 related_application.id = 85 related_application.id =
85 base::NullableString16(related_application.id.string().substr( 86 base::NullableString16(related_application.id.string().substr(
86 0, Manifest::kMaxIPCStringLength), 87 0, Manifest::kMaxIPCStringLength),
87 related_application.id.is_null()); 88 related_application.id.is_null());
88 } 89 }
89 90
90 Send(new ManifestManagerHostMsg_RequestManifestResponse( 91 Send(new ManifestManagerHostMsg_RequestManifestResponse(
91 routing_id(), request_id, ipc_manifest)); 92 routing_id(), request_id, manifest_url, ipc_manifest));
92 } 93 }
93 94
94 void ManifestManager::GetManifest(const GetManifestCallback& callback) { 95 void ManifestManager::GetManifest(const GetManifestCallback& callback) {
95 if (!may_have_manifest_) { 96 if (!may_have_manifest_) {
96 callback.Run(Manifest(), ManifestDebugInfo()); 97 callback.Run(GURL(), Manifest(), ManifestDebugInfo());
97 return; 98 return;
98 } 99 }
99 100
100 if (!manifest_dirty_) { 101 if (!manifest_dirty_) {
101 callback.Run(manifest_, manifest_debug_info_); 102 callback.Run(manifest_url_, manifest_, manifest_debug_info_);
102 return; 103 return;
103 } 104 }
104 105
105 pending_callbacks_.push_back(callback); 106 pending_callbacks_.push_back(callback);
106 107
107 // Just wait for the running call to be done if there are other callbacks. 108 // Just wait for the running call to be done if there are other callbacks.
108 if (pending_callbacks_.size() > 1) 109 if (pending_callbacks_.size() > 1)
109 return; 110 return;
110 111
111 FetchManifest(); 112 FetchManifest();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 render_frame()->GetWebFrame()->addMessageToConsole(message); 181 render_frame()->GetWebFrame()->addMessageToConsole(message);
181 } 182 }
182 183
183 // Having errors while parsing the manifest doesn't mean the manifest parsing 184 // Having errors while parsing the manifest doesn't mean the manifest parsing
184 // failed. Some properties might have been ignored but some others kept. 185 // failed. Some properties might have been ignored but some others kept.
185 if (parser.failed()) { 186 if (parser.failed()) {
186 ResolveCallbacks(ResolveStateFailure); 187 ResolveCallbacks(ResolveStateFailure);
187 return; 188 return;
188 } 189 }
189 190
191 manifest_url_ = response.url();
190 manifest_ = parser.manifest(); 192 manifest_ = parser.manifest();
191 ResolveCallbacks(ResolveStateSuccess); 193 ResolveCallbacks(ResolveStateSuccess);
192 } 194 }
193 195
194 void ManifestManager::ResolveCallbacks(ResolveState state) { 196 void ManifestManager::ResolveCallbacks(ResolveState state) {
195 if (state == ResolveStateFailure) 197 if (state == ResolveStateFailure) {
198 manifest_url_ = GURL();
196 manifest_ = Manifest(); 199 manifest_ = Manifest();
200 }
197 201
198 manifest_dirty_ = state != ResolveStateSuccess; 202 manifest_dirty_ = state != ResolveStateSuccess;
199 203
200 std::list<GetManifestCallback> callbacks; 204 std::list<GetManifestCallback> callbacks;
201 callbacks.swap(pending_callbacks_); 205 callbacks.swap(pending_callbacks_);
202 206
203 for (std::list<GetManifestCallback>::const_iterator it = callbacks.begin(); 207 for (std::list<GetManifestCallback>::const_iterator it = callbacks.begin();
204 it != callbacks.end(); ++it) { 208 it != callbacks.end(); ++it) {
205 it->Run(manifest_, manifest_debug_info_); 209 it->Run(manifest_url_, manifest_, manifest_debug_info_);
206 } 210 }
207 } 211 }
208 212
209 void ManifestManager::OnDestruct() { 213 void ManifestManager::OnDestruct() {
210 delete this; 214 delete this;
211 } 215 }
212 216
213 } // namespace content 217 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/manifest/manifest_manager.h ('k') | content/renderer/push_messaging/push_messaging_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698