OLD | NEW |
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 int request_id, const Manifest& manifest) { | 54 int request_id, const Manifest& manifest) { |
55 // When sent via IPC, the Manifest must follow certain security rules. | 55 // When sent via IPC, the Manifest must follow certain security rules. |
56 Manifest ipc_manifest = manifest; | 56 Manifest ipc_manifest = manifest; |
57 ipc_manifest.name = base::NullableString16( | 57 ipc_manifest.name = base::NullableString16( |
58 ipc_manifest.name.string().substr(0, Manifest::kMaxIPCStringLength), | 58 ipc_manifest.name.string().substr(0, Manifest::kMaxIPCStringLength), |
59 ipc_manifest.name.is_null()); | 59 ipc_manifest.name.is_null()); |
60 ipc_manifest.short_name = base::NullableString16( | 60 ipc_manifest.short_name = base::NullableString16( |
61 ipc_manifest.short_name.string().substr(0, | 61 ipc_manifest.short_name.string().substr(0, |
62 Manifest::kMaxIPCStringLength), | 62 Manifest::kMaxIPCStringLength), |
63 ipc_manifest.short_name.is_null()); | 63 ipc_manifest.short_name.is_null()); |
64 for (size_t i = 0; i < ipc_manifest.icons.size(); ++i) { | 64 for (auto& icon : ipc_manifest.icons) { |
65 ipc_manifest.icons[i].type = base::NullableString16( | 65 icon.type = base::NullableString16( |
66 ipc_manifest.icons[i].type.string().substr( | 66 icon.type.string().substr(0, Manifest::kMaxIPCStringLength), |
67 0, Manifest::kMaxIPCStringLength), | 67 icon.type.is_null()); |
68 ipc_manifest.icons[i].type.is_null()); | |
69 } | 68 } |
70 ipc_manifest.gcm_sender_id = base::NullableString16( | 69 ipc_manifest.gcm_sender_id = base::NullableString16( |
71 ipc_manifest.gcm_sender_id.string().substr( | 70 ipc_manifest.gcm_sender_id.string().substr( |
72 0, Manifest::kMaxIPCStringLength), | 71 0, Manifest::kMaxIPCStringLength), |
73 ipc_manifest.gcm_sender_id.is_null()); | 72 ipc_manifest.gcm_sender_id.is_null()); |
| 73 for (auto& related_application : ipc_manifest.related_applications) { |
| 74 related_application.id = |
| 75 base::NullableString16(related_application.id.string().substr( |
| 76 0, Manifest::kMaxIPCStringLength), |
| 77 related_application.id.is_null()); |
| 78 } |
74 | 79 |
75 Send(new ManifestManagerHostMsg_RequestManifestResponse( | 80 Send(new ManifestManagerHostMsg_RequestManifestResponse( |
76 routing_id(), request_id, ipc_manifest)); | 81 routing_id(), request_id, ipc_manifest)); |
77 } | 82 } |
78 | 83 |
79 void ManifestManager::GetManifest(const GetManifestCallback& callback) { | 84 void ManifestManager::GetManifest(const GetManifestCallback& callback) { |
80 if (!may_have_manifest_) { | 85 if (!may_have_manifest_) { |
81 callback.Run(Manifest()); | 86 callback.Run(Manifest()); |
82 return; | 87 return; |
83 } | 88 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 178 |
174 pending_callbacks_.clear(); | 179 pending_callbacks_.clear(); |
175 | 180 |
176 for (std::list<GetManifestCallback>::const_iterator it = callbacks.begin(); | 181 for (std::list<GetManifestCallback>::const_iterator it = callbacks.begin(); |
177 it != callbacks.end(); ++it) { | 182 it != callbacks.end(); ++it) { |
178 it->Run(manifest); | 183 it->Run(manifest); |
179 } | 184 } |
180 } | 185 } |
181 | 186 |
182 } // namespace content | 187 } // namespace content |
OLD | NEW |