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

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

Issue 2654303002: Always call StorageMonitor::RemoveObserver in ~MediaFileSystemRegistry. (Closed)
Patch Set: add include Created 3 years, 10 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
« no previous file with comments | « chrome/browser/media_galleries/media_file_system_registry_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/logging.h"
8 #include "base/path_service.h" 9 #include "base/path_service.h"
9 #include "base/stl_util.h" 10 #include "base/stl_util.h"
10 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/extensions/api/file_system/file_system_api.h" 13 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
13 #include "chrome/browser/media_galleries/media_file_system_registry.h" 14 #include "chrome/browser/media_galleries/media_file_system_registry.h"
14 #include "chrome/browser/media_galleries/media_galleries_histograms.h" 15 #include "chrome/browser/media_galleries/media_galleries_histograms.h"
15 #include "chrome/browser/media_galleries/media_gallery_context_menu.h" 16 #include "chrome/browser/media_galleries/media_gallery_context_menu.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/chrome_select_file_policy.h" 18 #include "chrome/browser/ui/chrome_select_file_policy.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 base::Unretained(this))); 75 base::Unretained(this)));
75 76
76 // Unretained is safe because |this| owns |context_menu_|. 77 // Unretained is safe because |this| owns |context_menu_|.
77 context_menu_.reset( 78 context_menu_.reset(
78 new MediaGalleryContextMenu( 79 new MediaGalleryContextMenu(
79 base::Bind(&MediaGalleriesPermissionController::DidForgetEntry, 80 base::Bind(&MediaGalleriesPermissionController::DidForgetEntry,
80 base::Unretained(this)))); 81 base::Unretained(this))));
81 } 82 }
82 83
83 void MediaGalleriesPermissionController::OnPreferencesInitialized() { 84 void MediaGalleriesPermissionController::OnPreferencesInitialized() {
84 if (StorageMonitor::GetInstance()) 85 DCHECK(StorageMonitor::GetInstance());
85 StorageMonitor::GetInstance()->AddObserver(this); 86 StorageMonitor::GetInstance()->AddObserver(this);
86 87
87 // |preferences_| may be NULL in tests. 88 // |preferences_| may be NULL in tests.
88 if (preferences_) { 89 if (preferences_) {
89 preferences_->AddGalleryChangeObserver(this); 90 preferences_->AddGalleryChangeObserver(this);
90 InitializePermissions(); 91 InitializePermissions();
91 } 92 }
92 93
93 dialog_.reset(create_dialog_callback_.Run(this)); 94 dialog_.reset(create_dialog_callback_.Run(this));
94 } 95 }
95 96
96 MediaGalleriesPermissionController::MediaGalleriesPermissionController( 97 MediaGalleriesPermissionController::MediaGalleriesPermissionController(
97 const extensions::Extension& extension, 98 const extensions::Extension& extension,
98 MediaGalleriesPreferences* preferences, 99 MediaGalleriesPreferences* preferences,
99 const CreateDialogCallback& create_dialog_callback, 100 const CreateDialogCallback& create_dialog_callback,
100 const base::Closure& on_finish) 101 const base::Closure& on_finish)
101 : web_contents_(NULL), 102 : web_contents_(NULL),
102 extension_(&extension), 103 extension_(&extension),
103 on_finish_(on_finish), 104 on_finish_(on_finish),
104 preferences_(preferences), 105 preferences_(preferences),
105 create_dialog_callback_(create_dialog_callback) { 106 create_dialog_callback_(create_dialog_callback) {
106 OnPreferencesInitialized(); 107 OnPreferencesInitialized();
107 } 108 }
108 109
109 MediaGalleriesPermissionController::~MediaGalleriesPermissionController() { 110 MediaGalleriesPermissionController::~MediaGalleriesPermissionController() {
110 if (StorageMonitor::GetInstance()) 111 DCHECK(StorageMonitor::GetInstance());
111 StorageMonitor::GetInstance()->RemoveObserver(this); 112 StorageMonitor::GetInstance()->RemoveObserver(this);
112 113
113 // |preferences_| may be NULL in tests. 114 // |preferences_| may be NULL in tests.
114 if (preferences_) 115 if (preferences_)
115 preferences_->RemoveGalleryChangeObserver(this); 116 preferences_->RemoveGalleryChangeObserver(this);
116 117
117 if (select_folder_dialog_.get()) 118 if (select_folder_dialog_.get())
118 select_folder_dialog_->ListenerDestroyed(); 119 select_folder_dialog_->ListenerDestroyed();
119 } 120 }
120 121
121 base::string16 MediaGalleriesPermissionController::GetHeader() const { 122 base::string16 MediaGalleriesPermissionController::GetHeader() const {
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 MediaGalleryPrefId 540 MediaGalleryPrefId
540 MediaGalleriesPermissionController::DialogIdMap::GetPrefId( 541 MediaGalleriesPermissionController::DialogIdMap::GetPrefId(
541 GalleryDialogId id) const { 542 GalleryDialogId id) const {
542 DCHECK_LT(id, next_dialog_id_); 543 DCHECK_LT(id, next_dialog_id_);
543 return forward_mapping_[id]; 544 return forward_mapping_[id];
544 } 545 }
545 546
546 // MediaGalleries dialog ------------------------------------------------------- 547 // MediaGalleries dialog -------------------------------------------------------
547 548
548 MediaGalleriesDialog::~MediaGalleriesDialog() {} 549 MediaGalleriesDialog::~MediaGalleriesDialog() {}
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/media_file_system_registry_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698