Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(762)

Side by Side Diff: chrome/browser/extensions/api/media_galleries/media_galleries_api.cc

Issue 2888073002: Remove raw DictionaryValue::Set in //chrome (Closed)
Patch Set: Fix Tests Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 SendResponse(false); 657 SendResponse(false);
658 return; 658 return;
659 } 659 }
660 660
661 if (metadata_type == MediaGalleries::GET_METADATA_TYPE_MIMETYPEONLY) { 661 if (metadata_type == MediaGalleries::GET_METADATA_TYPE_MIMETYPEONLY) {
662 MediaGalleries::MediaMetadata metadata; 662 MediaGalleries::MediaMetadata metadata;
663 metadata.mime_type = mime_type; 663 metadata.mime_type = mime_type;
664 664
665 std::unique_ptr<base::DictionaryValue> result_dictionary( 665 std::unique_ptr<base::DictionaryValue> result_dictionary(
666 new base::DictionaryValue); 666 new base::DictionaryValue);
667 result_dictionary->Set(kMetadataKey, metadata.ToValue().release()); 667 result_dictionary->Set(kMetadataKey, metadata.ToValue());
668 SetResult(std::move(result_dictionary)); 668 SetResult(std::move(result_dictionary));
669 SendResponse(true); 669 SendResponse(true);
670 return; 670 return;
671 } 671 }
672 672
673 // We get attached images by default. GET_METADATA_TYPE_NONE is the default 673 // We get attached images by default. GET_METADATA_TYPE_NONE is the default
674 // value if the caller doesn't specify the metadata type. 674 // value if the caller doesn't specify the metadata type.
675 bool get_attached_images = 675 bool get_attached_images =
676 metadata_type == MediaGalleries::GET_METADATA_TYPE_ALL || 676 metadata_type == MediaGalleries::GET_METADATA_TYPE_ALL ||
677 metadata_type == MediaGalleries::GET_METADATA_TYPE_NONE; 677 metadata_type == MediaGalleries::GET_METADATA_TYPE_NONE;
(...skipping 15 matching lines...) Expand all
693 if (!parse_success) { 693 if (!parse_success) {
694 SendResponse(false); 694 SendResponse(false);
695 return; 695 return;
696 } 696 }
697 697
698 DCHECK(metadata_dictionary.get()); 698 DCHECK(metadata_dictionary.get());
699 DCHECK(attached_images.get()); 699 DCHECK(attached_images.get());
700 700
701 std::unique_ptr<base::DictionaryValue> result_dictionary( 701 std::unique_ptr<base::DictionaryValue> result_dictionary(
702 new base::DictionaryValue); 702 new base::DictionaryValue);
703 result_dictionary->Set(kMetadataKey, metadata_dictionary.release()); 703 result_dictionary->Set(kMetadataKey, std::move(metadata_dictionary));
704 704
705 if (attached_images->empty()) { 705 if (attached_images->empty()) {
706 SetResult(std::move(result_dictionary)); 706 SetResult(std::move(result_dictionary));
707 SendResponse(true); 707 SendResponse(true);
708 return; 708 return;
709 } 709 }
710 710
711 result_dictionary->Set(kAttachedImagesBlobInfoKey, new base::ListValue); 711 result_dictionary->Set(kAttachedImagesBlobInfoKey,
712 base::MakeUnique<base::ListValue>());
712 metadata::AttachedImage* first_image = &attached_images->front(); 713 metadata::AttachedImage* first_image = &attached_images->front();
713 content::BrowserContext::CreateMemoryBackedBlob( 714 content::BrowserContext::CreateMemoryBackedBlob(
714 GetProfile(), first_image->data.c_str(), first_image->data.size(), 715 GetProfile(), first_image->data.c_str(), first_image->data.size(),
715 base::Bind(&MediaGalleriesGetMetadataFunction::ConstructNextBlob, this, 716 base::Bind(&MediaGalleriesGetMetadataFunction::ConstructNextBlob, this,
716 base::Passed(&result_dictionary), 717 base::Passed(&result_dictionary),
717 base::Passed(&attached_images), 718 base::Passed(&attached_images),
718 base::Passed(base::WrapUnique(new std::vector<std::string>)))); 719 base::Passed(base::WrapUnique(new std::vector<std::string>))));
719 } 720 }
720 721
721 void MediaGalleriesGetMetadataFunction::ConstructNextBlob( 722 void MediaGalleriesGetMetadataFunction::ConstructNextBlob(
(...skipping 14 matching lines...) Expand all
736 // For the newly constructed Blob, store its image's metadata and Blob UUID. 737 // For the newly constructed Blob, store its image's metadata and Blob UUID.
737 base::ListValue* attached_images_list = NULL; 738 base::ListValue* attached_images_list = NULL;
738 result_dictionary->GetList(kAttachedImagesBlobInfoKey, &attached_images_list); 739 result_dictionary->GetList(kAttachedImagesBlobInfoKey, &attached_images_list);
739 DCHECK(attached_images_list); 740 DCHECK(attached_images_list);
740 DCHECK_LT(attached_images_list->GetSize(), attached_images->size()); 741 DCHECK_LT(attached_images_list->GetSize(), attached_images->size());
741 742
742 metadata::AttachedImage* current_image = 743 metadata::AttachedImage* current_image =
743 &(*attached_images)[blob_uuids->size()]; 744 &(*attached_images)[blob_uuids->size()];
744 std::unique_ptr<base::DictionaryValue> attached_image( 745 std::unique_ptr<base::DictionaryValue> attached_image(
745 new base::DictionaryValue); 746 new base::DictionaryValue);
746 attached_image->Set(kBlobUUIDKey, new base::Value(current_blob->GetUUID())); 747 attached_image->SetString(kBlobUUIDKey, current_blob->GetUUID());
747 attached_image->Set(kTypeKey, new base::Value(current_image->type)); 748 attached_image->SetString(kTypeKey, current_image->type);
748 attached_image->Set( 749 attached_image->SetInteger(
749 kSizeKey, 750 kSizeKey, base::checked_cast<int>(current_image->data.size()));
750 new base::Value(base::checked_cast<int>(current_image->data.size())));
751 attached_images_list->Append(std::move(attached_image)); 751 attached_images_list->Append(std::move(attached_image));
752 752
753 blob_uuids->push_back(current_blob->GetUUID()); 753 blob_uuids->push_back(current_blob->GetUUID());
754 754
755 content::RenderProcessHost* render_process_host = 755 content::RenderProcessHost* render_process_host =
756 render_frame_host()->GetProcess(); 756 render_frame_host()->GetProcess();
757 if (!render_process_host) { 757 if (!render_process_host) {
758 SendResponse(false); 758 SendResponse(false);
759 return; 759 return;
760 } 760 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 SendResponse(false); 907 SendResponse(false);
908 return; 908 return;
909 } 909 }
910 910
911 gallery_watch_manager()->RemoveWatch( 911 gallery_watch_manager()->RemoveWatch(
912 GetProfile(), extension_id(), gallery_pref_id); 912 GetProfile(), extension_id(), gallery_pref_id);
913 SendResponse(true); 913 SendResponse(true);
914 } 914 }
915 915
916 } // namespace extensions 916 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/proxy/proxy_api.cc » ('j') | chrome/browser/prerender/prerender_history.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698