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

Side by Side Diff: chrome/browser/media_galleries/media_galleries_permission_controller.cc

Issue 329643002: Media Galleries: Allow readding blacklisted iApps libraries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: narrow down folders which imply iphoto Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_permission_controller.h " 5 #include "chrome/browser/media_galleries/media_galleries_permission_controller.h "
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.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/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 280 }
281 281
282 content::WebContents* MediaGalleriesPermissionController::WebContents() { 282 content::WebContents* MediaGalleriesPermissionController::WebContents() {
283 return web_contents_; 283 return web_contents_;
284 } 284 }
285 285
286 void MediaGalleriesPermissionController::FileSelected( 286 void MediaGalleriesPermissionController::FileSelected(
287 const base::FilePath& path, 287 const base::FilePath& path,
288 int /*index*/, 288 int /*index*/,
289 void* /*params*/) { 289 void* /*params*/) {
290 extensions::file_system_api::SetLastChooseEntryDirectory( 290 // |web_contents_| is NULL in tests.
291 extensions::ExtensionPrefs::Get(GetProfile()), 291 if (web_contents_) {
vandebo (ex-Chrome) 2014/06/11 16:40:56 Is this needed? Why are the existing tests ok?
tommycli 2014/06/11 18:17:56 Test crashes when the controller calls GetProfile(
292 extension_->id(), 292 extensions::file_system_api::SetLastChooseEntryDirectory(
293 path); 293 extensions::ExtensionPrefs::Get(GetProfile()),
294 extension_->id(),
295 path);
296 }
294 297
295 // Try to find it in the prefs. 298 // Try to find it in the prefs.
296 MediaGalleryPrefInfo gallery; 299 MediaGalleryPrefInfo gallery;
297 DCHECK(preferences_); 300 DCHECK(preferences_);
298 bool gallery_exists = preferences_->LookUpGalleryByPath(path, &gallery); 301 bool gallery_exists = preferences_->LookUpGalleryByPath(path, &gallery);
299 if (gallery_exists && !gallery.IsBlackListedType()) { 302 if (gallery_exists && !gallery.IsBlackListedType()) {
300 // The prefs are in sync with |known_galleries_|, so it should exist in 303 // The prefs are in sync with |known_galleries_|, so it should exist in
301 // |known_galleries_| as well. User selecting a known gallery effectively 304 // |known_galleries_| as well. User selecting a known gallery effectively
302 // just sets the gallery to permitted. 305 // just sets the gallery to permitted.
303 GalleryDialogId gallery_id = GetDialogId(gallery.pref_id); 306 GalleryDialogId gallery_id = GetDialogId(gallery.pref_id);
(...skipping 10 matching lines...) Expand all
314 iter != new_galleries_.end(); ++iter) { 317 iter != new_galleries_.end(); ++iter) {
315 if (iter->second.pref_info.path == gallery.path && 318 if (iter->second.pref_info.path == gallery.path &&
316 iter->second.pref_info.device_id == gallery.device_id) { 319 iter->second.pref_info.device_id == gallery.device_id) {
317 iter->second.selected = true; 320 iter->second.selected = true;
318 dialog_->UpdateGalleries(); 321 dialog_->UpdateGalleries();
319 return; 322 return;
320 } 323 }
321 } 324 }
322 325
323 // Lastly, if not found, add a new gallery to |new_galleries_|. 326 // Lastly, if not found, add a new gallery to |new_galleries_|.
324 DCHECK_EQ(kInvalidMediaGalleryPrefId, gallery.pref_id); 327 // prefId == kInvalidMediaGalleryPrefId for completely new galleries.
325 gallery.pref_id = GetDialogId(kInvalidMediaGalleryPrefId); 328 // The old prefId is retained for blacklisted galleries.
329 gallery.pref_id = GetDialogId(gallery.pref_id);
326 new_galleries_[gallery.pref_id] = Entry(gallery, true); 330 new_galleries_[gallery.pref_id] = Entry(gallery, true);
327 dialog_->UpdateGalleries(); 331 dialog_->UpdateGalleries();
328 } 332 }
329 333
330 void MediaGalleriesPermissionController::OnRemovableStorageAttached( 334 void MediaGalleriesPermissionController::OnRemovableStorageAttached(
331 const StorageInfo& info) { 335 const StorageInfo& info) {
332 UpdateGalleriesOnDeviceEvent(info.device_id()); 336 UpdateGalleriesOnDeviceEvent(info.device_id());
333 } 337 }
334 338
335 void MediaGalleriesPermissionController::OnRemovableStorageDetached( 339 void MediaGalleriesPermissionController::OnRemovableStorageDetached(
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 MediaGalleryPrefId 542 MediaGalleryPrefId
539 MediaGalleriesPermissionController::DialogIdMap::GetPrefId( 543 MediaGalleriesPermissionController::DialogIdMap::GetPrefId(
540 GalleryDialogId id) { 544 GalleryDialogId id) {
541 DCHECK_LT(id, next_dialog_id_); 545 DCHECK_LT(id, next_dialog_id_);
542 return forward_mapping_[id]; 546 return forward_mapping_[id];
543 } 547 }
544 548
545 // MediaGalleries dialog ------------------------------------------------------- 549 // MediaGalleries dialog -------------------------------------------------------
546 550
547 MediaGalleriesDialog::~MediaGalleriesDialog() {} 551 MediaGalleriesDialog::~MediaGalleriesDialog() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698