| 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/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/media_galleries/media_file_system_registry.h" | 11 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/storage_monitor/storage_info.h" | 13 #include "chrome/browser/storage_monitor/storage_info.h" |
| 14 #include "chrome/browser/storage_monitor/storage_monitor.h" | 14 #include "chrome/browser/storage_monitor/storage_monitor.h" |
| 15 #include "chrome/browser/ui/chrome_select_file_policy.h" | 15 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 16 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 17 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 18 #include "chrome/common/extensions/permissions/media_galleries_permission.h" | 18 #include "chrome/common/extensions/permissions/media_galleries_permission.h" |
| 19 #include "chrome/common/extensions/permissions/permissions_data.h" | 19 #include "chrome/common/extensions/permissions/permissions_data.h" |
| 20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/browser/web_contents_view.h" | 21 #include "content/public/browser/web_contents_view.h" |
| 22 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/base/text/bytes_formatting.h" | 24 #include "ui/base/text/bytes_formatting.h" |
| 25 | 25 |
| 26 using extensions::APIPermission; | 26 using extensions::APIPermission; |
| 27 using extensions::Extension; | 27 using extensions::Extension; |
| 28 | 28 |
| 29 namespace chrome { | |
| 30 | |
| 31 namespace { | 29 namespace { |
| 32 | 30 |
| 33 // Comparator for sorting GalleryPermissionsVector -- sorts | 31 // Comparator for sorting GalleryPermissionsVector -- sorts |
| 34 // allowed galleries low, and then sorts by absolute path. | 32 // allowed galleries low, and then sorts by absolute path. |
| 35 bool GalleriesVectorComparator( | 33 bool GalleriesVectorComparator( |
| 36 const MediaGalleriesDialogController::GalleryPermission& a, | 34 const MediaGalleriesDialogController::GalleryPermission& a, |
| 37 const MediaGalleriesDialogController::GalleryPermission& b) { | 35 const MediaGalleriesDialogController::GalleryPermission& b) { |
| 38 if (a.allowed && !b.allowed) | 36 if (a.allowed && !b.allowed) |
| 39 return true; | 37 return true; |
| 40 if (!a.allowed && b.allowed) | 38 if (!a.allowed && b.allowed) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 preferences_->AddGalleryChangeObserver(this); | 72 preferences_->AddGalleryChangeObserver(this); |
| 75 } | 73 } |
| 76 | 74 |
| 77 MediaGalleriesDialogController::MediaGalleriesDialogController( | 75 MediaGalleriesDialogController::MediaGalleriesDialogController( |
| 78 const extensions::Extension& extension) | 76 const extensions::Extension& extension) |
| 79 : web_contents_(NULL), | 77 : web_contents_(NULL), |
| 80 extension_(&extension), | 78 extension_(&extension), |
| 81 preferences_(NULL) {} | 79 preferences_(NULL) {} |
| 82 | 80 |
| 83 MediaGalleriesDialogController::~MediaGalleriesDialogController() { | 81 MediaGalleriesDialogController::~MediaGalleriesDialogController() { |
| 84 if (chrome::StorageMonitor::GetInstance()) | 82 if (StorageMonitor::GetInstance()) |
| 85 StorageMonitor::GetInstance()->RemoveObserver(this); | 83 StorageMonitor::GetInstance()->RemoveObserver(this); |
| 86 | 84 |
| 87 if (select_folder_dialog_.get()) | 85 if (select_folder_dialog_.get()) |
| 88 select_folder_dialog_->ListenerDestroyed(); | 86 select_folder_dialog_->ListenerDestroyed(); |
| 89 } | 87 } |
| 90 | 88 |
| 91 string16 MediaGalleriesDialogController::GetHeader() const { | 89 string16 MediaGalleriesDialogController::GetHeader() const { |
| 92 return l10n_util::GetStringUTF16(IDS_MEDIA_GALLERIES_DIALOG_HEADER); | 90 return l10n_util::GetStringUTF16(IDS_MEDIA_GALLERIES_DIALOG_HEADER); |
| 93 } | 91 } |
| 94 | 92 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 for (GalleryPermissionsVector::iterator iter = new_galleries_.begin(); | 401 for (GalleryPermissionsVector::iterator iter = new_galleries_.begin(); |
| 404 iter != new_galleries_.end(); ++iter) { | 402 iter != new_galleries_.end(); ++iter) { |
| 405 if (iter->pref_info.device_id == device_id) | 403 if (iter->pref_info.device_id == device_id) |
| 406 dialog_->UpdateGallery(iter->pref_info, iter->allowed); | 404 dialog_->UpdateGallery(iter->pref_info, iter->allowed); |
| 407 } | 405 } |
| 408 } | 406 } |
| 409 | 407 |
| 410 // MediaGalleries dialog ------------------------------------------------------- | 408 // MediaGalleries dialog ------------------------------------------------------- |
| 411 | 409 |
| 412 MediaGalleriesDialog::~MediaGalleriesDialog() {} | 410 MediaGalleriesDialog::~MediaGalleriesDialog() {} |
| 413 | |
| 414 } // namespace chrome | |
| OLD | NEW |