| 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/browser/manifest/manifest_manager_host.h" | 5 #include "content/browser/manifest/manifest_manager_host.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "content/common/manifest_manager_messages.h" | 8 #include "content/common/manifest_manager_messages.h" |
| 9 #include "content/public/browser/render_frame_host.h" | 9 #include "content/public/browser/render_frame_host.h" |
| 10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // coming from a known and secure source. It must be processed accordingly. | 110 // coming from a known and secure source. It must be processed accordingly. |
| 111 Manifest manifest = insecure_manifest; | 111 Manifest manifest = insecure_manifest; |
| 112 manifest.name = base::NullableString16( | 112 manifest.name = base::NullableString16( |
| 113 manifest.name.string().substr(0, Manifest::kMaxIPCStringLength), | 113 manifest.name.string().substr(0, Manifest::kMaxIPCStringLength), |
| 114 manifest.name.is_null()); | 114 manifest.name.is_null()); |
| 115 manifest.short_name = base::NullableString16( | 115 manifest.short_name = base::NullableString16( |
| 116 manifest.short_name.string().substr(0, Manifest::kMaxIPCStringLength), | 116 manifest.short_name.string().substr(0, Manifest::kMaxIPCStringLength), |
| 117 manifest.short_name.is_null()); | 117 manifest.short_name.is_null()); |
| 118 if (!manifest.start_url.is_valid()) | 118 if (!manifest.start_url.is_valid()) |
| 119 manifest.start_url = GURL(); | 119 manifest.start_url = GURL(); |
| 120 for (size_t i = 0; i < manifest.icons.size(); ++i) { | 120 for (auto& icon : manifest.icons) { |
| 121 if (!manifest.icons[i].src.is_valid()) | 121 if (!icon.src.is_valid()) |
| 122 manifest.icons[i].src = GURL(); | 122 icon.src = GURL(); |
| 123 manifest.icons[i].type = base::NullableString16( | 123 icon.type = base::NullableString16( |
| 124 manifest.icons[i].type.string().substr(0, | 124 icon.type.string().substr(0, Manifest::kMaxIPCStringLength), |
| 125 Manifest::kMaxIPCStringLength), | 125 icon.type.is_null()); |
| 126 manifest.icons[i].type.is_null()); | |
| 127 } | 126 } |
| 128 manifest.gcm_sender_id = base::NullableString16( | 127 manifest.gcm_sender_id = base::NullableString16( |
| 129 manifest.gcm_sender_id.string().substr( | 128 manifest.gcm_sender_id.string().substr( |
| 130 0, Manifest::kMaxIPCStringLength), | 129 0, Manifest::kMaxIPCStringLength), |
| 131 manifest.gcm_sender_id.is_null()); | 130 manifest.gcm_sender_id.is_null()); |
| 131 for (auto& related_application : manifest.related_applications) { |
| 132 if (!related_application.url.is_valid()) |
| 133 related_application.url = GURL(); |
| 134 related_application.id = |
| 135 base::NullableString16(related_application.id.string().substr( |
| 136 0, Manifest::kMaxIPCStringLength), |
| 137 related_application.id.is_null()); |
| 138 } |
| 132 | 139 |
| 133 callback->Run(manifest); | 140 callback->Run(manifest); |
| 134 callbacks->Remove(request_id); | 141 callbacks->Remove(request_id); |
| 135 if (callbacks->IsEmpty()) { | 142 if (callbacks->IsEmpty()) { |
| 136 delete callbacks; | 143 delete callbacks; |
| 137 pending_callbacks_.erase(render_frame_host); | 144 pending_callbacks_.erase(render_frame_host); |
| 138 } | 145 } |
| 139 } | 146 } |
| 140 | 147 |
| 141 } // namespace content | 148 } // namespace content |
| OLD | NEW |