| 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" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 else | 109 else |
| 110 id = IDS_MEDIA_GALLERIES_DIALOG_SUBTEXT_READ_ONLY; | 110 id = IDS_MEDIA_GALLERIES_DIALOG_SUBTEXT_READ_ONLY; |
| 111 | 111 |
| 112 return l10n_util::GetStringFUTF16(id, UTF8ToUTF16(extension_->name())); | 112 return l10n_util::GetStringFUTF16(id, UTF8ToUTF16(extension_->name())); |
| 113 } | 113 } |
| 114 | 114 |
| 115 string16 MediaGalleriesDialogController::GetUnattachedLocationsHeader() const { | 115 string16 MediaGalleriesDialogController::GetUnattachedLocationsHeader() const { |
| 116 return l10n_util::GetStringUTF16(IDS_MEDIA_GALLERIES_UNATTACHED_LOCATIONS); | 116 return l10n_util::GetStringUTF16(IDS_MEDIA_GALLERIES_UNATTACHED_LOCATIONS); |
| 117 } | 117 } |
| 118 | 118 |
| 119 string16 MediaGalleriesDialogController::GetForgetMenuCommand() const { |
| 120 return l10n_util::GetStringUTF16(IDS_MEDIA_GALLERIES_DIALOG_FORGET); |
| 121 } |
| 122 |
| 119 // TODO(gbillock): Call this something a bit more connected to the | 123 // TODO(gbillock): Call this something a bit more connected to the |
| 120 // messaging in the dialog. | 124 // messaging in the dialog. |
| 121 bool MediaGalleriesDialogController::HasPermittedGalleries() const { | 125 bool MediaGalleriesDialogController::HasPermittedGalleries() const { |
| 122 for (KnownGalleryPermissions::const_iterator iter = known_galleries_.begin(); | 126 for (KnownGalleryPermissions::const_iterator iter = known_galleries_.begin(); |
| 123 iter != known_galleries_.end(); ++iter) { | 127 iter != known_galleries_.end(); ++iter) { |
| 124 if (iter->second.allowed) | 128 if (iter->second.allowed) |
| 125 return true; | 129 return true; |
| 126 } | 130 } |
| 127 | 131 |
| 128 // Do this? Views did. | 132 // Do this? Views did. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 for (GalleryPermissionsVector::iterator iter = new_galleries_.begin(); | 215 for (GalleryPermissionsVector::iterator iter = new_galleries_.begin(); |
| 212 iter != new_galleries_.end(); ++iter) { | 216 iter != new_galleries_.end(); ++iter) { |
| 213 if (iter->pref_info.path == gallery.path && | 217 if (iter->pref_info.path == gallery.path && |
| 214 iter->pref_info.device_id == gallery.device_id) { | 218 iter->pref_info.device_id == gallery.device_id) { |
| 215 iter->allowed = enabled; | 219 iter->allowed = enabled; |
| 216 return; | 220 return; |
| 217 } | 221 } |
| 218 } | 222 } |
| 219 } | 223 } |
| 220 | 224 |
| 225 void MediaGalleriesDialogController::DidForgetGallery( |
| 226 MediaGalleryPrefId pref_id) { |
| 227 DCHECK(preferences_); |
| 228 preferences_->ForgetGalleryById(pref_id); |
| 229 } |
| 230 |
| 221 void MediaGalleriesDialogController::DialogFinished(bool accepted) { | 231 void MediaGalleriesDialogController::DialogFinished(bool accepted) { |
| 222 // The dialog has finished, so there is no need to watch for more updates | 232 // The dialog has finished, so there is no need to watch for more updates |
| 223 // from |preferences_|. Do this here and not in the dtor since this is the | 233 // from |preferences_|. Do this here and not in the dtor since this is the |
| 224 // only non-test code path that deletes |this|. The test ctor never adds | 234 // only non-test code path that deletes |this|. The test ctor never adds |
| 225 // this observer in the first place. | 235 // this observer in the first place. |
| 226 preferences_->RemoveGalleryChangeObserver(this); | 236 preferences_->RemoveGalleryChangeObserver(this); |
| 227 | 237 |
| 228 if (accepted) | 238 if (accepted) |
| 229 SavePermissions(); | 239 SavePermissions(); |
| 230 | 240 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 } | 418 } |
| 409 | 419 |
| 410 void MediaGalleriesDialogController::UpdateGalleriesOnDeviceEvent( | 420 void MediaGalleriesDialogController::UpdateGalleriesOnDeviceEvent( |
| 411 const std::string& device_id) { | 421 const std::string& device_id) { |
| 412 dialog_->UpdateGalleries(); | 422 dialog_->UpdateGalleries(); |
| 413 } | 423 } |
| 414 | 424 |
| 415 // MediaGalleries dialog ------------------------------------------------------- | 425 // MediaGalleries dialog ------------------------------------------------------- |
| 416 | 426 |
| 417 MediaGalleriesDialog::~MediaGalleriesDialog() {} | 427 MediaGalleriesDialog::~MediaGalleriesDialog() {} |
| OLD | NEW |