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

Side by Side Diff: chrome/browser/media_gallery/media_file_system_registry.cc

Issue 10821077: Add gallery permissions to Media Galleries Preferences (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 8 years, 4 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 (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 // MediaFileSystemRegistry implementation. 5 // MediaFileSystemRegistry implementation.
6 6
7 #include "chrome/browser/media_gallery/media_file_system_registry.h" 7 #include "chrome/browser/media_gallery/media_file_system_registry.h"
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
142 const RenderProcessHost* rph = 142 const RenderProcessHost* rph =
143 content::Source<content::RenderProcessHost>(source).ptr(); 143 content::Source<content::RenderProcessHost>(source).ptr();
144 ChildIdToMediaFSMap::iterator child_it = media_fs_map_.find(rph); 144 ChildIdToMediaFSMap::iterator child_it = media_fs_map_.find(rph);
145 CHECK(child_it != media_fs_map_.end()); 145 CHECK(child_it != media_fs_map_.end());
146 // No need to revoke the isolated file systems. The RPH will do that. 146 // No need to revoke the isolated file systems. The RPH will do that.
147 media_fs_map_.erase(child_it); 147 media_fs_map_.erase(child_it);
148 UnregisterForRPHGoneNotifications(rph); 148 UnregisterForRPHGoneNotifications(rph);
149 } 149 }
150 150
151 std::string MediaFileSystemRegistry::GetDeviceIdFromPath(
152 const FilePath& path) const {
153 // TODO(vandebo) Do something better here, at least iterate system monitor
154 // attached media devices looking for a match. If not, return the path.
155 return path.AsUTF8Unsafe();
156 }
157
151 /****************** 158 /******************
152 * Private methods 159 * Private methods
153 ******************/ 160 ******************/
154 161
155 MediaFileSystemRegistry::MediaFileSystemRegistry() { 162 MediaFileSystemRegistry::MediaFileSystemRegistry() {
156 SystemMonitor::Get()->AddDevicesChangedObserver(this); 163 // SystemMonitor may be NULL in unit tests.
164 SystemMonitor* system_monitor = SystemMonitor::Get();
165 if (system_monitor)
166 system_monitor->AddDevicesChangedObserver(this);
157 } 167 }
158 168
159 MediaFileSystemRegistry::~MediaFileSystemRegistry() { 169 MediaFileSystemRegistry::~MediaFileSystemRegistry() {
160 SystemMonitor::Get()->RemoveDevicesChangedObserver(this); 170 // SystemMonitor may be NULL in unit tests.
171 SystemMonitor* system_monitor = SystemMonitor::Get();
172 if (system_monitor)
173 system_monitor->RemoveDevicesChangedObserver(this);
161 } 174 }
162 175
163 void MediaFileSystemRegistry::RegisterForRPHGoneNotifications( 176 void MediaFileSystemRegistry::RegisterForRPHGoneNotifications(
164 const content::RenderProcessHost* rph) { 177 const content::RenderProcessHost* rph) {
165 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 178 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
166 content::Source<RenderProcessHost>(rph)); 179 content::Source<RenderProcessHost>(rph));
167 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 180 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
168 content::Source<RenderProcessHost>(rph)); 181 content::Source<RenderProcessHost>(rph));
169 } 182 }
170 183
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 #endif 242 #endif
230 break; 243 break;
231 case SystemMonitor::TYPE_PATH: 244 case SystemMonitor::TYPE_PATH:
232 break; 245 break;
233 } 246 }
234 child_map.erase(media_path_it); 247 child_map.erase(media_path_it);
235 } 248 }
236 } 249 }
237 250
238 } // namespace chrome 251 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/media_gallery/media_file_system_registry.h ('k') | chrome/browser/media_gallery/media_galleries_preferences.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698