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 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" | 5 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" |
6 | 6 |
7 #include "base/i18n/time_formatting.h" | 7 #include "base/i18n/time_formatting.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 bool IsAttachedDevice(const std::string& device_id) { | 32 bool IsAttachedDevice(const std::string& device_id) { |
33 if (!StorageInfo::IsRemovableDevice(device_id)) | 33 if (!StorageInfo::IsRemovableDevice(device_id)) |
34 return false; | 34 return false; |
35 | 35 |
36 std::vector<StorageInfo> removable_storages = | 36 std::vector<StorageInfo> removable_storages = |
37 StorageMonitor::GetInstance()->GetAttachedStorage(); | 37 StorageMonitor::GetInstance()->GetAttachedStorage(); |
38 for (size_t i = 0; i < removable_storages.size(); ++i) { | 38 for (size_t i = 0; i < removable_storages.size(); ++i) { |
39 if (removable_storages[i].device_id == device_id) | 39 if (removable_storages[i].device_id() == device_id) |
40 return true; | 40 return true; |
41 } | 41 } |
42 return false; | 42 return false; |
43 } | 43 } |
44 | 44 |
45 // Comparator for sorting GalleryPermissionsVector -- sorts | 45 // Comparator for sorting GalleryPermissionsVector -- sorts |
46 // allowed galleries low, and then sorts by absolute path. | 46 // allowed galleries low, and then sorts by absolute path. |
47 bool GalleriesVectorComparator( | 47 bool GalleriesVectorComparator( |
48 const MediaGalleriesDialogController::GalleryPermission& a, | 48 const MediaGalleriesDialogController::GalleryPermission& a, |
49 const MediaGalleriesDialogController::GalleryPermission& b) { | 49 const MediaGalleriesDialogController::GalleryPermission& b) { |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 } | 372 } |
373 } | 373 } |
374 | 374 |
375 // Lastly, add a new gallery to |new_galleries_|. | 375 // Lastly, add a new gallery to |new_galleries_|. |
376 new_galleries_.push_back(GalleryPermission(gallery, true)); | 376 new_galleries_.push_back(GalleryPermission(gallery, true)); |
377 dialog_->UpdateGallery(new_galleries_.back().pref_info, true); | 377 dialog_->UpdateGallery(new_galleries_.back().pref_info, true); |
378 } | 378 } |
379 | 379 |
380 void MediaGalleriesDialogController::OnRemovableStorageAttached( | 380 void MediaGalleriesDialogController::OnRemovableStorageAttached( |
381 const StorageInfo& info) { | 381 const StorageInfo& info) { |
382 UpdateGalleriesOnDeviceEvent(info.device_id); | 382 UpdateGalleriesOnDeviceEvent(info.device_id()); |
383 } | 383 } |
384 | 384 |
385 void MediaGalleriesDialogController::OnRemovableStorageDetached( | 385 void MediaGalleriesDialogController::OnRemovableStorageDetached( |
386 const StorageInfo& info) { | 386 const StorageInfo& info) { |
387 UpdateGalleriesOnDeviceEvent(info.device_id); | 387 UpdateGalleriesOnDeviceEvent(info.device_id()); |
388 } | 388 } |
389 | 389 |
390 void MediaGalleriesDialogController::OnGalleryChanged( | 390 void MediaGalleriesDialogController::OnGalleryChanged( |
391 MediaGalleriesPreferences* pref, const std::string& extension_id) { | 391 MediaGalleriesPreferences* pref, const std::string& extension_id) { |
392 DCHECK_EQ(preferences_, pref); | 392 DCHECK_EQ(preferences_, pref); |
393 if (extension_id.empty() || extension_id == extension_->id()) | 393 if (extension_id.empty() || extension_id == extension_->id()) |
394 UpdateGalleriesOnPreferencesEvent(); | 394 UpdateGalleriesOnPreferencesEvent(); |
395 } | 395 } |
396 | 396 |
397 void MediaGalleriesDialogController::InitializePermissions() { | 397 void MediaGalleriesDialogController::InitializePermissions() { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 if (iter->pref_info.device_id == device_id) | 507 if (iter->pref_info.device_id == device_id) |
508 dialog_->UpdateGallery(iter->pref_info, iter->allowed); | 508 dialog_->UpdateGallery(iter->pref_info, iter->allowed); |
509 } | 509 } |
510 } | 510 } |
511 | 511 |
512 // MediaGalleries dialog ------------------------------------------------------- | 512 // MediaGalleries dialog ------------------------------------------------------- |
513 | 513 |
514 MediaGalleriesDialog::~MediaGalleriesDialog() {} | 514 MediaGalleriesDialog::~MediaGalleriesDialog() {} |
515 | 515 |
516 } // namespace chrome | 516 } // namespace chrome |
OLD | NEW |