| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Implements the Chrome Extensions Media Galleries API. | 5 // Implements the Chrome Extensions Media Galleries API. |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/media_galleries/media_galleries_api.h" | 7 #include "chrome/browser/extensions/api/media_galleries/media_galleries_api.h" |
| 8 | 8 |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 new base::DictionaryValue); | 745 new base::DictionaryValue); |
| 746 attached_image->Set(kBlobUUIDKey, new base::StringValue( | 746 attached_image->Set(kBlobUUIDKey, new base::StringValue( |
| 747 current_blob->GetUUID())); | 747 current_blob->GetUUID())); |
| 748 attached_image->Set(kTypeKey, new base::StringValue( | 748 attached_image->Set(kTypeKey, new base::StringValue( |
| 749 current_image->type)); | 749 current_image->type)); |
| 750 attached_image->Set(kSizeKey, new base::FundamentalValue( | 750 attached_image->Set(kSizeKey, new base::FundamentalValue( |
| 751 base::checked_cast<int>(current_image->data.size()))); | 751 base::checked_cast<int>(current_image->data.size()))); |
| 752 attached_images_list->Append(std::move(attached_image)); | 752 attached_images_list->Append(std::move(attached_image)); |
| 753 | 753 |
| 754 blob_uuids->push_back(current_blob->GetUUID()); | 754 blob_uuids->push_back(current_blob->GetUUID()); |
| 755 |
| 756 content::RenderProcessHost* render_process_host = |
| 757 render_frame_host()->GetProcess(); |
| 758 if (!render_process_host) { |
| 759 SendResponse(false); |
| 760 return; |
| 761 } |
| 762 |
| 755 extensions::BlobHolder* holder = | 763 extensions::BlobHolder* holder = |
| 756 extensions::BlobHolder::FromRenderProcessHost( | 764 extensions::BlobHolder::FromRenderProcessHost(render_process_host); |
| 757 render_frame_host()->GetProcess()); | |
| 758 holder->HoldBlobReference(std::move(current_blob)); | 765 holder->HoldBlobReference(std::move(current_blob)); |
| 759 | 766 |
| 760 // Construct the next Blob if necessary. | 767 // Construct the next Blob if necessary. |
| 761 if (blob_uuids->size() < attached_images->size()) { | 768 if (blob_uuids->size() < attached_images->size()) { |
| 762 metadata::AttachedImage* next_image = | 769 metadata::AttachedImage* next_image = |
| 763 &(*attached_images)[blob_uuids->size()]; | 770 &(*attached_images)[blob_uuids->size()]; |
| 764 content::BrowserContext::CreateMemoryBackedBlob( | 771 content::BrowserContext::CreateMemoryBackedBlob( |
| 765 GetProfile(), | 772 GetProfile(), |
| 766 next_image->data.c_str(), | 773 next_image->data.c_str(), |
| 767 next_image->data.size(), | 774 next_image->data.size(), |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 SendResponse(false); | 908 SendResponse(false); |
| 902 return; | 909 return; |
| 903 } | 910 } |
| 904 | 911 |
| 905 gallery_watch_manager()->RemoveWatch( | 912 gallery_watch_manager()->RemoveWatch( |
| 906 GetProfile(), extension_id(), gallery_pref_id); | 913 GetProfile(), extension_id(), gallery_pref_id); |
| 907 SendResponse(true); | 914 SendResponse(true); |
| 908 } | 915 } |
| 909 | 916 |
| 910 } // namespace extensions | 917 } // namespace extensions |
| OLD | NEW |