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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 DCHECK_LT(blob_uuids->size(), attached_images->size()); | 704 DCHECK_LT(blob_uuids->size(), attached_images->size()); |
705 | 705 |
706 // For the newly constructed Blob, store its image's metadata and Blob UUID. | 706 // For the newly constructed Blob, store its image's metadata and Blob UUID. |
707 base::ListValue* attached_images_list = NULL; | 707 base::ListValue* attached_images_list = NULL; |
708 result_dictionary->GetList(kAttachedImagesBlobInfoKey, &attached_images_list); | 708 result_dictionary->GetList(kAttachedImagesBlobInfoKey, &attached_images_list); |
709 DCHECK(attached_images_list); | 709 DCHECK(attached_images_list); |
710 DCHECK_LT(attached_images_list->GetSize(), attached_images->size()); | 710 DCHECK_LT(attached_images_list->GetSize(), attached_images->size()); |
711 | 711 |
712 metadata::AttachedImage* current_image = | 712 metadata::AttachedImage* current_image = |
713 &(*attached_images)[blob_uuids->size()]; | 713 &(*attached_images)[blob_uuids->size()]; |
714 base::DictionaryValue* attached_image = new base::DictionaryValue; | 714 std::unique_ptr<base::DictionaryValue> attached_image( |
| 715 new base::DictionaryValue); |
715 attached_image->Set(kBlobUUIDKey, new base::StringValue( | 716 attached_image->Set(kBlobUUIDKey, new base::StringValue( |
716 current_blob->GetUUID())); | 717 current_blob->GetUUID())); |
717 attached_image->Set(kTypeKey, new base::StringValue( | 718 attached_image->Set(kTypeKey, new base::StringValue( |
718 current_image->type)); | 719 current_image->type)); |
719 attached_image->Set(kSizeKey, new base::FundamentalValue( | 720 attached_image->Set(kSizeKey, new base::FundamentalValue( |
720 base::checked_cast<int>(current_image->data.size()))); | 721 base::checked_cast<int>(current_image->data.size()))); |
721 attached_images_list->Append(attached_image); | 722 attached_images_list->Append(std::move(attached_image)); |
722 | 723 |
723 blob_uuids->push_back(current_blob->GetUUID()); | 724 blob_uuids->push_back(current_blob->GetUUID()); |
724 extensions::BlobHolder* holder = | 725 extensions::BlobHolder* holder = |
725 extensions::BlobHolder::FromRenderProcessHost( | 726 extensions::BlobHolder::FromRenderProcessHost( |
726 render_frame_host()->GetProcess()); | 727 render_frame_host()->GetProcess()); |
727 holder->HoldBlobReference(std::move(current_blob)); | 728 holder->HoldBlobReference(std::move(current_blob)); |
728 | 729 |
729 // Construct the next Blob if necessary. | 730 // Construct the next Blob if necessary. |
730 if (blob_uuids->size() < attached_images->size()) { | 731 if (blob_uuids->size() < attached_images->size()) { |
731 metadata::AttachedImage* next_image = | 732 metadata::AttachedImage* next_image = |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 SendResponse(false); | 871 SendResponse(false); |
871 return; | 872 return; |
872 } | 873 } |
873 | 874 |
874 gallery_watch_manager()->RemoveWatch( | 875 gallery_watch_manager()->RemoveWatch( |
875 GetProfile(), extension_id(), gallery_pref_id); | 876 GetProfile(), extension_id(), gallery_pref_id); |
876 SendResponse(true); | 877 SendResponse(true); |
877 } | 878 } |
878 | 879 |
879 } // namespace extensions | 880 } // namespace extensions |
OLD | NEW |