| 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 #include <set> | 11 #include <set> |
| 11 #include <string> | 12 #include <string> |
| 12 #include <utility> | 13 #include <utility> |
| 13 #include <vector> | 14 #include <vector> |
| 14 | 15 |
| 15 #include "base/callback.h" | 16 #include "base/callback.h" |
| 16 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
| 17 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/ptr_util.h" |
| 18 #include "base/numerics/safe_conversions.h" | 20 #include "base/numerics/safe_conversions.h" |
| 19 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
| 20 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/values.h" | 24 #include "base/values.h" |
| 23 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 26 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
| 25 #include "chrome/browser/extensions/blob_reader.h" | 27 #include "chrome/browser/extensions/blob_reader.h" |
| 26 #include "chrome/browser/extensions/chrome_extension_function_details.h" | 28 #include "chrome/browser/extensions/chrome_extension_function_details.h" |
| 27 #include "chrome/browser/extensions/extension_tab_util.h" | 29 #include "chrome/browser/extensions/extension_tab_util.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 MediaGalleriesPermission::CheckParam copy_to_param( | 152 MediaGalleriesPermission::CheckParam copy_to_param( |
| 151 MediaGalleriesPermission::kCopyToPermission); | 153 MediaGalleriesPermission::kCopyToPermission); |
| 152 bool has_copy_to_permission = permissions_data->CheckAPIPermissionWithParam( | 154 bool has_copy_to_permission = permissions_data->CheckAPIPermissionWithParam( |
| 153 APIPermission::kMediaGalleries, ©_to_param); | 155 APIPermission::kMediaGalleries, ©_to_param); |
| 154 MediaGalleriesPermission::CheckParam delete_param( | 156 MediaGalleriesPermission::CheckParam delete_param( |
| 155 MediaGalleriesPermission::kDeletePermission); | 157 MediaGalleriesPermission::kDeletePermission); |
| 156 bool has_delete_permission = permissions_data->CheckAPIPermissionWithParam( | 158 bool has_delete_permission = permissions_data->CheckAPIPermissionWithParam( |
| 157 APIPermission::kMediaGalleries, &delete_param); | 159 APIPermission::kMediaGalleries, &delete_param); |
| 158 | 160 |
| 159 const int child_id = rfh->GetProcess()->GetID(); | 161 const int child_id = rfh->GetProcess()->GetID(); |
| 160 scoped_ptr<base::ListValue> list(new base::ListValue()); | 162 std::unique_ptr<base::ListValue> list(new base::ListValue()); |
| 161 for (size_t i = 0; i < filesystems.size(); ++i) { | 163 for (size_t i = 0; i < filesystems.size(); ++i) { |
| 162 scoped_ptr<base::DictionaryValue> file_system_dict_value( | 164 std::unique_ptr<base::DictionaryValue> file_system_dict_value( |
| 163 new base::DictionaryValue()); | 165 new base::DictionaryValue()); |
| 164 | 166 |
| 165 // Send the file system id so the renderer can create a valid FileSystem | 167 // Send the file system id so the renderer can create a valid FileSystem |
| 166 // object. | 168 // object. |
| 167 file_system_dict_value->SetStringWithoutPathExpansion( | 169 file_system_dict_value->SetStringWithoutPathExpansion( |
| 168 "fsid", filesystems[i].fsid); | 170 "fsid", filesystems[i].fsid); |
| 169 | 171 |
| 170 file_system_dict_value->SetStringWithoutPathExpansion( | 172 file_system_dict_value->SetStringWithoutPathExpansion( |
| 171 kNameKey, filesystems[i].name); | 173 kNameKey, filesystems[i].name); |
| 172 file_system_dict_value->SetStringWithoutPathExpansion( | 174 file_system_dict_value->SetStringWithoutPathExpansion( |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 bool MediaGalleriesEventRouter::ExtensionHasGalleryChangeListener( | 309 bool MediaGalleriesEventRouter::ExtensionHasGalleryChangeListener( |
| 308 const std::string& extension_id) const { | 310 const std::string& extension_id) const { |
| 309 return EventRouter::Get(profile_)->ExtensionHasEventListener( | 311 return EventRouter::Get(profile_)->ExtensionHasEventListener( |
| 310 extension_id, MediaGalleries::OnGalleryChanged::kEventName); | 312 extension_id, MediaGalleries::OnGalleryChanged::kEventName); |
| 311 } | 313 } |
| 312 | 314 |
| 313 void MediaGalleriesEventRouter::DispatchEventToExtension( | 315 void MediaGalleriesEventRouter::DispatchEventToExtension( |
| 314 const std::string& extension_id, | 316 const std::string& extension_id, |
| 315 events::HistogramValue histogram_value, | 317 events::HistogramValue histogram_value, |
| 316 const std::string& event_name, | 318 const std::string& event_name, |
| 317 scoped_ptr<base::ListValue> event_args) { | 319 std::unique_ptr<base::ListValue> event_args) { |
| 318 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 320 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 319 | 321 |
| 320 EventRouter* router = EventRouter::Get(profile_); | 322 EventRouter* router = EventRouter::Get(profile_); |
| 321 if (!router->ExtensionHasEventListener(extension_id, event_name)) | 323 if (!router->ExtensionHasEventListener(extension_id, event_name)) |
| 322 return; | 324 return; |
| 323 | 325 |
| 324 scoped_ptr<extensions::Event> event(new extensions::Event( | 326 std::unique_ptr<extensions::Event> event(new extensions::Event( |
| 325 histogram_value, event_name, std::move(event_args))); | 327 histogram_value, event_name, std::move(event_args))); |
| 326 router->DispatchEventToExtension(extension_id, std::move(event)); | 328 router->DispatchEventToExtension(extension_id, std::move(event)); |
| 327 } | 329 } |
| 328 | 330 |
| 329 void MediaGalleriesEventRouter::OnGalleryChanged( | 331 void MediaGalleriesEventRouter::OnGalleryChanged( |
| 330 const std::string& extension_id, MediaGalleryPrefId gallery_id) { | 332 const std::string& extension_id, MediaGalleryPrefId gallery_id) { |
| 331 MediaGalleries::GalleryChangeDetails details; | 333 MediaGalleries::GalleryChangeDetails details; |
| 332 details.type = MediaGalleries::GALLERY_CHANGE_TYPE_CONTENTS_CHANGED; | 334 details.type = MediaGalleries::GALLERY_CHANGE_TYPE_CONTENTS_CHANGED; |
| 333 details.gallery_id = base::Uint64ToString(gallery_id); | 335 details.gallery_id = base::Uint64ToString(gallery_id); |
| 334 DispatchEventToExtension(extension_id, | 336 DispatchEventToExtension(extension_id, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 357 } | 359 } |
| 358 | 360 |
| 359 /////////////////////////////////////////////////////////////////////////////// | 361 /////////////////////////////////////////////////////////////////////////////// |
| 360 // MediaGalleriesGetMediaFileSystemsFunction // | 362 // MediaGalleriesGetMediaFileSystemsFunction // |
| 361 /////////////////////////////////////////////////////////////////////////////// | 363 /////////////////////////////////////////////////////////////////////////////// |
| 362 MediaGalleriesGetMediaFileSystemsFunction:: | 364 MediaGalleriesGetMediaFileSystemsFunction:: |
| 363 ~MediaGalleriesGetMediaFileSystemsFunction() {} | 365 ~MediaGalleriesGetMediaFileSystemsFunction() {} |
| 364 | 366 |
| 365 bool MediaGalleriesGetMediaFileSystemsFunction::RunAsync() { | 367 bool MediaGalleriesGetMediaFileSystemsFunction::RunAsync() { |
| 366 media_galleries::UsageCount(media_galleries::GET_MEDIA_FILE_SYSTEMS); | 368 media_galleries::UsageCount(media_galleries::GET_MEDIA_FILE_SYSTEMS); |
| 367 scoped_ptr<GetMediaFileSystems::Params> params( | 369 std::unique_ptr<GetMediaFileSystems::Params> params( |
| 368 GetMediaFileSystems::Params::Create(*args_)); | 370 GetMediaFileSystems::Params::Create(*args_)); |
| 369 EXTENSION_FUNCTION_VALIDATE(params.get()); | 371 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 370 MediaGalleries::GetMediaFileSystemsInteractivity interactive = | 372 MediaGalleries::GetMediaFileSystemsInteractivity interactive = |
| 371 MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NO; | 373 MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NO; |
| 372 if (params->details.get() && params->details->interactive != MediaGalleries:: | 374 if (params->details.get() && params->details->interactive != MediaGalleries:: |
| 373 GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NONE) { | 375 GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NONE) { |
| 374 interactive = params->details->interactive; | 376 interactive = params->details->interactive; |
| 375 } | 377 } |
| 376 | 378 |
| 377 return Setup(GetProfile(), &error_, base::Bind( | 379 return Setup(GetProfile(), &error_, base::Bind( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 ReturnGalleries(filesystems); | 422 ReturnGalleries(filesystems); |
| 421 } | 423 } |
| 422 | 424 |
| 423 void MediaGalleriesGetMediaFileSystemsFunction::GetAndReturnGalleries() { | 425 void MediaGalleriesGetMediaFileSystemsFunction::GetAndReturnGalleries() { |
| 424 GetMediaFileSystemsForExtension(base::Bind( | 426 GetMediaFileSystemsForExtension(base::Bind( |
| 425 &MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries, this)); | 427 &MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries, this)); |
| 426 } | 428 } |
| 427 | 429 |
| 428 void MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries( | 430 void MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries( |
| 429 const std::vector<MediaFileSystemInfo>& filesystems) { | 431 const std::vector<MediaFileSystemInfo>& filesystems) { |
| 430 scoped_ptr<base::ListValue> list( | 432 std::unique_ptr<base::ListValue> list( |
| 431 ConstructFileSystemList(render_frame_host(), extension(), filesystems)); | 433 ConstructFileSystemList(render_frame_host(), extension(), filesystems)); |
| 432 if (!list.get()) { | 434 if (!list.get()) { |
| 433 SendResponse(false); | 435 SendResponse(false); |
| 434 return; | 436 return; |
| 435 } | 437 } |
| 436 | 438 |
| 437 // The custom JS binding will use this list to create DOMFileSystem objects. | 439 // The custom JS binding will use this list to create DOMFileSystem objects. |
| 438 SetResult(list.release()); | 440 SetResult(list.release()); |
| 439 SendResponse(true); | 441 SendResponse(true); |
| 440 } | 442 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 | 530 |
| 529 GetMediaFileSystemsForExtension(base::Bind( | 531 GetMediaFileSystemsForExtension(base::Bind( |
| 530 &MediaGalleriesAddUserSelectedFolderFunction::ReturnGalleriesAndId, | 532 &MediaGalleriesAddUserSelectedFolderFunction::ReturnGalleriesAndId, |
| 531 this, | 533 this, |
| 532 pref_id)); | 534 pref_id)); |
| 533 } | 535 } |
| 534 | 536 |
| 535 void MediaGalleriesAddUserSelectedFolderFunction::ReturnGalleriesAndId( | 537 void MediaGalleriesAddUserSelectedFolderFunction::ReturnGalleriesAndId( |
| 536 MediaGalleryPrefId pref_id, | 538 MediaGalleryPrefId pref_id, |
| 537 const std::vector<MediaFileSystemInfo>& filesystems) { | 539 const std::vector<MediaFileSystemInfo>& filesystems) { |
| 538 scoped_ptr<base::ListValue> list( | 540 std::unique_ptr<base::ListValue> list( |
| 539 ConstructFileSystemList(render_frame_host(), extension(), filesystems)); | 541 ConstructFileSystemList(render_frame_host(), extension(), filesystems)); |
| 540 if (!list.get()) { | 542 if (!list.get()) { |
| 541 SendResponse(false); | 543 SendResponse(false); |
| 542 return; | 544 return; |
| 543 } | 545 } |
| 544 | 546 |
| 545 int index = -1; | 547 int index = -1; |
| 546 if (pref_id != kInvalidMediaGalleryPrefId) { | 548 if (pref_id != kInvalidMediaGalleryPrefId) { |
| 547 for (size_t i = 0; i < filesystems.size(); ++i) { | 549 for (size_t i = 0; i < filesystems.size(); ++i) { |
| 548 if (filesystems[i].pref_id == pref_id) { | 550 if (filesystems[i].pref_id == pref_id) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 577 MediaGalleriesGetMetadataFunction::~MediaGalleriesGetMetadataFunction() {} | 579 MediaGalleriesGetMetadataFunction::~MediaGalleriesGetMetadataFunction() {} |
| 578 | 580 |
| 579 bool MediaGalleriesGetMetadataFunction::RunAsync() { | 581 bool MediaGalleriesGetMetadataFunction::RunAsync() { |
| 580 media_galleries::UsageCount(media_galleries::GET_METADATA); | 582 media_galleries::UsageCount(media_galleries::GET_METADATA); |
| 581 std::string blob_uuid; | 583 std::string blob_uuid; |
| 582 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &blob_uuid)); | 584 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &blob_uuid)); |
| 583 | 585 |
| 584 const base::Value* options_value = NULL; | 586 const base::Value* options_value = NULL; |
| 585 if (!args_->Get(1, &options_value)) | 587 if (!args_->Get(1, &options_value)) |
| 586 return false; | 588 return false; |
| 587 scoped_ptr<MediaGalleries::MediaMetadataOptions> options = | 589 std::unique_ptr<MediaGalleries::MediaMetadataOptions> options = |
| 588 MediaGalleries::MediaMetadataOptions::FromValue(*options_value); | 590 MediaGalleries::MediaMetadataOptions::FromValue(*options_value); |
| 589 if (!options) | 591 if (!options) |
| 590 return false; | 592 return false; |
| 591 | 593 |
| 592 return Setup(GetProfile(), &error_, base::Bind( | 594 return Setup(GetProfile(), &error_, base::Bind( |
| 593 &MediaGalleriesGetMetadataFunction::OnPreferencesInit, this, | 595 &MediaGalleriesGetMetadataFunction::OnPreferencesInit, this, |
| 594 options->metadata_type, blob_uuid)); | 596 options->metadata_type, blob_uuid)); |
| 595 } | 597 } |
| 596 | 598 |
| 597 void MediaGalleriesGetMetadataFunction::OnPreferencesInit( | 599 void MediaGalleriesGetMetadataFunction::OnPreferencesInit( |
| 598 MediaGalleries::GetMetadataType metadata_type, | 600 MediaGalleries::GetMetadataType metadata_type, |
| 599 const std::string& blob_uuid) { | 601 const std::string& blob_uuid) { |
| 600 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 602 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 601 | 603 |
| 602 // BlobReader is self-deleting. | 604 // BlobReader is self-deleting. |
| 603 BlobReader* reader = new BlobReader( | 605 BlobReader* reader = new BlobReader( |
| 604 GetProfile(), | 606 GetProfile(), |
| 605 blob_uuid, | 607 blob_uuid, |
| 606 base::Bind(&MediaGalleriesGetMetadataFunction::GetMetadata, this, | 608 base::Bind(&MediaGalleriesGetMetadataFunction::GetMetadata, this, |
| 607 metadata_type, blob_uuid)); | 609 metadata_type, blob_uuid)); |
| 608 reader->SetByteRange(0, net::kMaxBytesToSniff); | 610 reader->SetByteRange(0, net::kMaxBytesToSniff); |
| 609 reader->Start(); | 611 reader->Start(); |
| 610 } | 612 } |
| 611 | 613 |
| 612 void MediaGalleriesGetMetadataFunction::GetMetadata( | 614 void MediaGalleriesGetMetadataFunction::GetMetadata( |
| 613 MediaGalleries::GetMetadataType metadata_type, | 615 MediaGalleries::GetMetadataType metadata_type, |
| 614 const std::string& blob_uuid, | 616 const std::string& blob_uuid, |
| 615 scoped_ptr<std::string> blob_header, | 617 std::unique_ptr<std::string> blob_header, |
| 616 int64_t total_blob_length) { | 618 int64_t total_blob_length) { |
| 617 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 619 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 618 | 620 |
| 619 std::string mime_type; | 621 std::string mime_type; |
| 620 bool mime_type_sniffed = net::SniffMimeTypeFromLocalData( | 622 bool mime_type_sniffed = net::SniffMimeTypeFromLocalData( |
| 621 blob_header->c_str(), blob_header->size(), &mime_type); | 623 blob_header->c_str(), blob_header->size(), &mime_type); |
| 622 | 624 |
| 623 if (!mime_type_sniffed) { | 625 if (!mime_type_sniffed) { |
| 624 SendResponse(false); | 626 SendResponse(false); |
| 625 return; | 627 return; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 644 | 646 |
| 645 scoped_refptr<metadata::SafeMediaMetadataParser> parser( | 647 scoped_refptr<metadata::SafeMediaMetadataParser> parser( |
| 646 new metadata::SafeMediaMetadataParser(GetProfile(), blob_uuid, | 648 new metadata::SafeMediaMetadataParser(GetProfile(), blob_uuid, |
| 647 total_blob_length, mime_type, | 649 total_blob_length, mime_type, |
| 648 get_attached_images)); | 650 get_attached_images)); |
| 649 parser->Start(base::Bind( | 651 parser->Start(base::Bind( |
| 650 &MediaGalleriesGetMetadataFunction::OnSafeMediaMetadataParserDone, this)); | 652 &MediaGalleriesGetMetadataFunction::OnSafeMediaMetadataParserDone, this)); |
| 651 } | 653 } |
| 652 | 654 |
| 653 void MediaGalleriesGetMetadataFunction::OnSafeMediaMetadataParserDone( | 655 void MediaGalleriesGetMetadataFunction::OnSafeMediaMetadataParserDone( |
| 654 bool parse_success, scoped_ptr<base::DictionaryValue> metadata_dictionary, | 656 bool parse_success, |
| 655 scoped_ptr<std::vector<metadata::AttachedImage> > attached_images) { | 657 std::unique_ptr<base::DictionaryValue> metadata_dictionary, |
| 658 std::unique_ptr<std::vector<metadata::AttachedImage>> attached_images) { |
| 656 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 659 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 657 | 660 |
| 658 if (!parse_success) { | 661 if (!parse_success) { |
| 659 SendResponse(false); | 662 SendResponse(false); |
| 660 return; | 663 return; |
| 661 } | 664 } |
| 662 | 665 |
| 663 DCHECK(metadata_dictionary.get()); | 666 DCHECK(metadata_dictionary.get()); |
| 664 DCHECK(attached_images.get()); | 667 DCHECK(attached_images.get()); |
| 665 | 668 |
| 666 scoped_ptr<base::DictionaryValue> result_dictionary( | 669 std::unique_ptr<base::DictionaryValue> result_dictionary( |
| 667 new base::DictionaryValue); | 670 new base::DictionaryValue); |
| 668 result_dictionary->Set(kMetadataKey, metadata_dictionary.release()); | 671 result_dictionary->Set(kMetadataKey, metadata_dictionary.release()); |
| 669 | 672 |
| 670 if (attached_images->empty()) { | 673 if (attached_images->empty()) { |
| 671 SetResult(result_dictionary.release()); | 674 SetResult(result_dictionary.release()); |
| 672 SendResponse(true); | 675 SendResponse(true); |
| 673 return; | 676 return; |
| 674 } | 677 } |
| 675 | 678 |
| 676 result_dictionary->Set(kAttachedImagesBlobInfoKey, new base::ListValue); | 679 result_dictionary->Set(kAttachedImagesBlobInfoKey, new base::ListValue); |
| 677 metadata::AttachedImage* first_image = &attached_images->front(); | 680 metadata::AttachedImage* first_image = &attached_images->front(); |
| 678 content::BrowserContext::CreateMemoryBackedBlob( | 681 content::BrowserContext::CreateMemoryBackedBlob( |
| 679 GetProfile(), | 682 GetProfile(), first_image->data.c_str(), first_image->data.size(), |
| 680 first_image->data.c_str(), | 683 base::Bind(&MediaGalleriesGetMetadataFunction::ConstructNextBlob, this, |
| 681 first_image->data.size(), | 684 base::Passed(&result_dictionary), |
| 682 base::Bind(&MediaGalleriesGetMetadataFunction::ConstructNextBlob, | |
| 683 this, base::Passed(&result_dictionary), | |
| 684 base::Passed(&attached_images), | 685 base::Passed(&attached_images), |
| 685 base::Passed(make_scoped_ptr(new std::vector<std::string>)))); | 686 base::Passed(base::WrapUnique(new std::vector<std::string>)))); |
| 686 } | 687 } |
| 687 | 688 |
| 688 void MediaGalleriesGetMetadataFunction::ConstructNextBlob( | 689 void MediaGalleriesGetMetadataFunction::ConstructNextBlob( |
| 689 scoped_ptr<base::DictionaryValue> result_dictionary, | 690 std::unique_ptr<base::DictionaryValue> result_dictionary, |
| 690 scoped_ptr<std::vector<metadata::AttachedImage> > attached_images, | 691 std::unique_ptr<std::vector<metadata::AttachedImage>> attached_images, |
| 691 scoped_ptr<std::vector<std::string> > blob_uuids, | 692 std::unique_ptr<std::vector<std::string>> blob_uuids, |
| 692 scoped_ptr<content::BlobHandle> current_blob) { | 693 std::unique_ptr<content::BlobHandle> current_blob) { |
| 693 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 694 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 694 | 695 |
| 695 DCHECK(result_dictionary.get()); | 696 DCHECK(result_dictionary.get()); |
| 696 DCHECK(attached_images.get()); | 697 DCHECK(attached_images.get()); |
| 697 DCHECK(blob_uuids.get()); | 698 DCHECK(blob_uuids.get()); |
| 698 DCHECK(current_blob.get()); | 699 DCHECK(current_blob.get()); |
| 699 | 700 |
| 700 DCHECK(!attached_images->empty()); | 701 DCHECK(!attached_images->empty()); |
| 701 DCHECK_LT(blob_uuids->size(), attached_images->size()); | 702 DCHECK_LT(blob_uuids->size(), attached_images->size()); |
| 702 | 703 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 MediaGalleriesAddGalleryWatchFunction:: | 750 MediaGalleriesAddGalleryWatchFunction:: |
| 750 ~MediaGalleriesAddGalleryWatchFunction() { | 751 ~MediaGalleriesAddGalleryWatchFunction() { |
| 751 } | 752 } |
| 752 | 753 |
| 753 bool MediaGalleriesAddGalleryWatchFunction::RunAsync() { | 754 bool MediaGalleriesAddGalleryWatchFunction::RunAsync() { |
| 754 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 755 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 755 DCHECK(GetProfile()); | 756 DCHECK(GetProfile()); |
| 756 if (!render_frame_host() || !render_frame_host()->GetProcess()) | 757 if (!render_frame_host() || !render_frame_host()->GetProcess()) |
| 757 return false; | 758 return false; |
| 758 | 759 |
| 759 scoped_ptr<AddGalleryWatch::Params> params( | 760 std::unique_ptr<AddGalleryWatch::Params> params( |
| 760 AddGalleryWatch::Params::Create(*args_)); | 761 AddGalleryWatch::Params::Create(*args_)); |
| 761 EXTENSION_FUNCTION_VALIDATE(params.get()); | 762 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 762 | 763 |
| 763 MediaGalleriesPreferences* preferences = | 764 MediaGalleriesPreferences* preferences = |
| 764 g_browser_process->media_file_system_registry()->GetPreferences( | 765 g_browser_process->media_file_system_registry()->GetPreferences( |
| 765 GetProfile()); | 766 GetProfile()); |
| 766 preferences->EnsureInitialized( | 767 preferences->EnsureInitialized( |
| 767 base::Bind(&MediaGalleriesAddGalleryWatchFunction::OnPreferencesInit, | 768 base::Bind(&MediaGalleriesAddGalleryWatchFunction::OnPreferencesInit, |
| 768 this, | 769 this, |
| 769 params->gallery_id)); | 770 params->gallery_id)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 | 834 |
| 834 MediaGalleriesRemoveGalleryWatchFunction:: | 835 MediaGalleriesRemoveGalleryWatchFunction:: |
| 835 ~MediaGalleriesRemoveGalleryWatchFunction() { | 836 ~MediaGalleriesRemoveGalleryWatchFunction() { |
| 836 } | 837 } |
| 837 | 838 |
| 838 bool MediaGalleriesRemoveGalleryWatchFunction::RunAsync() { | 839 bool MediaGalleriesRemoveGalleryWatchFunction::RunAsync() { |
| 839 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 840 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 840 if (!render_frame_host() || !render_frame_host()->GetProcess()) | 841 if (!render_frame_host() || !render_frame_host()->GetProcess()) |
| 841 return false; | 842 return false; |
| 842 | 843 |
| 843 scoped_ptr<RemoveGalleryWatch::Params> params( | 844 std::unique_ptr<RemoveGalleryWatch::Params> params( |
| 844 RemoveGalleryWatch::Params::Create(*args_)); | 845 RemoveGalleryWatch::Params::Create(*args_)); |
| 845 EXTENSION_FUNCTION_VALIDATE(params.get()); | 846 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 846 | 847 |
| 847 MediaGalleriesPreferences* preferences = | 848 MediaGalleriesPreferences* preferences = |
| 848 g_browser_process->media_file_system_registry()->GetPreferences( | 849 g_browser_process->media_file_system_registry()->GetPreferences( |
| 849 GetProfile()); | 850 GetProfile()); |
| 850 preferences->EnsureInitialized( | 851 preferences->EnsureInitialized( |
| 851 base::Bind(&MediaGalleriesRemoveGalleryWatchFunction::OnPreferencesInit, | 852 base::Bind(&MediaGalleriesRemoveGalleryWatchFunction::OnPreferencesInit, |
| 852 this, | 853 this, |
| 853 params->gallery_id)); | 854 params->gallery_id)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 867 SendResponse(false); | 868 SendResponse(false); |
| 868 return; | 869 return; |
| 869 } | 870 } |
| 870 | 871 |
| 871 gallery_watch_manager()->RemoveWatch( | 872 gallery_watch_manager()->RemoveWatch( |
| 872 GetProfile(), extension_id(), gallery_pref_id); | 873 GetProfile(), extension_id(), gallery_pref_id); |
| 873 SendResponse(true); | 874 SendResponse(true); |
| 874 } | 875 } |
| 875 | 876 |
| 876 } // namespace extensions | 877 } // namespace extensions |
| OLD | NEW |