| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "content/common/manifest_manager_messages.h" | 10 #include "content/common/manifest_manager_messages.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 { | 58 { |
| 59 GetCallbackMap* callbacks = GetCallbackMapForFrame(render_frame_host); | 59 GetCallbackMap* callbacks = GetCallbackMapForFrame(render_frame_host); |
| 60 if (!callbacks) | 60 if (!callbacks) |
| 61 return; | 61 return; |
| 62 | 62 |
| 63 // Call the callbacks with a failure state before deleting them. Do this in | 63 // Call the callbacks with a failure state before deleting them. Do this in |
| 64 // a block so the iterator is destroyed before |callbacks|. | 64 // a block so the iterator is destroyed before |callbacks|. |
| 65 { | 65 { |
| 66 GetCallbackMap::const_iterator it(callbacks); | 66 GetCallbackMap::const_iterator it(callbacks); |
| 67 for (; !it.IsAtEnd(); it.Advance()) | 67 for (; !it.IsAtEnd(); it.Advance()) |
| 68 it.GetCurrentValue()->Run(Manifest()); | 68 it.GetCurrentValue()->Run(GURL(), Manifest()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 delete callbacks; | 71 delete callbacks; |
| 72 pending_get_callbacks_.erase(render_frame_host); | 72 pending_get_callbacks_.erase(render_frame_host); |
| 73 } | 73 } |
| 74 | 74 |
| 75 { | 75 { |
| 76 HasCallbackMap* callbacks = HasCallbackMapForFrame(render_frame_host); | 76 HasCallbackMap* callbacks = HasCallbackMapForFrame(render_frame_host); |
| 77 if (!callbacks) | 77 if (!callbacks) |
| 78 return; | 78 return; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 OnHasManifestResponse) | 130 OnHasManifestResponse) |
| 131 IPC_MESSAGE_UNHANDLED(handled = false) | 131 IPC_MESSAGE_UNHANDLED(handled = false) |
| 132 IPC_END_MESSAGE_MAP() | 132 IPC_END_MESSAGE_MAP() |
| 133 | 133 |
| 134 return handled; | 134 return handled; |
| 135 } | 135 } |
| 136 | 136 |
| 137 void ManifestManagerHost::OnRequestManifestResponse( | 137 void ManifestManagerHost::OnRequestManifestResponse( |
| 138 RenderFrameHost* render_frame_host, | 138 RenderFrameHost* render_frame_host, |
| 139 int request_id, | 139 int request_id, |
| 140 const GURL& manifest_url, |
| 140 const Manifest& insecure_manifest) { | 141 const Manifest& insecure_manifest) { |
| 141 GetCallbackMap* callbacks = GetCallbackMapForFrame(render_frame_host); | 142 GetCallbackMap* callbacks = GetCallbackMapForFrame(render_frame_host); |
| 142 if (!callbacks) { | 143 if (!callbacks) { |
| 143 DVLOG(1) << "Unexpected RequestManifestResponse to from renderer. " | 144 DVLOG(1) << "Unexpected RequestManifestResponse to from renderer. " |
| 144 "Killing renderer."; | 145 "Killing renderer."; |
| 145 KillRenderer(render_frame_host); | 146 KillRenderer(render_frame_host); |
| 146 return; | 147 return; |
| 147 } | 148 } |
| 148 | 149 |
| 149 GetManifestCallback* callback = callbacks->Lookup(request_id); | 150 GetManifestCallback* callback = callbacks->Lookup(request_id); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // theme_color and background_color are 32 bit unsigned integers with 64 bit | 188 // theme_color and background_color are 32 bit unsigned integers with 64 bit |
| 188 // integers simply being used to encode the occurence of an error. Therefore, | 189 // integers simply being used to encode the occurence of an error. Therefore, |
| 189 // any value outside the range of a 32 bit integer is invalid. | 190 // any value outside the range of a 32 bit integer is invalid. |
| 190 if (manifest.theme_color < std::numeric_limits<int32_t>::min() || | 191 if (manifest.theme_color < std::numeric_limits<int32_t>::min() || |
| 191 manifest.theme_color > std::numeric_limits<int32_t>::max()) | 192 manifest.theme_color > std::numeric_limits<int32_t>::max()) |
| 192 manifest.theme_color = Manifest::kInvalidOrMissingColor; | 193 manifest.theme_color = Manifest::kInvalidOrMissingColor; |
| 193 if (manifest.background_color < std::numeric_limits<int32_t>::min() || | 194 if (manifest.background_color < std::numeric_limits<int32_t>::min() || |
| 194 manifest.background_color > std::numeric_limits<int32_t>::max()) | 195 manifest.background_color > std::numeric_limits<int32_t>::max()) |
| 195 manifest.background_color = Manifest::kInvalidOrMissingColor; | 196 manifest.background_color = Manifest::kInvalidOrMissingColor; |
| 196 | 197 |
| 197 callback->Run(manifest); | 198 callback->Run(manifest_url, manifest); |
| 198 callbacks->Remove(request_id); | 199 callbacks->Remove(request_id); |
| 199 if (callbacks->IsEmpty()) { | 200 if (callbacks->IsEmpty()) { |
| 200 delete callbacks; | 201 delete callbacks; |
| 201 pending_get_callbacks_.erase(render_frame_host); | 202 pending_get_callbacks_.erase(render_frame_host); |
| 202 } | 203 } |
| 203 } | 204 } |
| 204 | 205 |
| 205 void ManifestManagerHost::OnHasManifestResponse( | 206 void ManifestManagerHost::OnHasManifestResponse( |
| 206 RenderFrameHost* render_frame_host, | 207 RenderFrameHost* render_frame_host, |
| 207 int request_id, | 208 int request_id, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 224 | 225 |
| 225 callback->Run(has_manifest); | 226 callback->Run(has_manifest); |
| 226 callbacks->Remove(request_id); | 227 callbacks->Remove(request_id); |
| 227 if (callbacks->IsEmpty()) { | 228 if (callbacks->IsEmpty()) { |
| 228 delete callbacks; | 229 delete callbacks; |
| 229 pending_has_callbacks_.erase(render_frame_host); | 230 pending_has_callbacks_.erase(render_frame_host); |
| 230 } | 231 } |
| 231 } | 232 } |
| 232 | 233 |
| 233 } // namespace content | 234 } // namespace content |
| OLD | NEW |