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

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: Add a default gallery 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
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/system_monitor/system_monitor.h" 13 #include "base/system_monitor/system_monitor.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
16 #include "chrome/common/extensions/extension_constants.h" 17 #include "chrome/common/extensions/extension_constants.h"
17 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
20 #include "content/public/browser/notification_types.h" 21 #include "content/public/browser/notification_types.h"
21 #include "content/public/browser/render_process_host.h" 22 #include "content/public/browser/render_process_host.h"
22 #include "webkit/fileapi/file_system_types.h" 23 #include "webkit/fileapi/file_system_types.h"
23 #include "webkit/fileapi/isolated_context.h" 24 #include "webkit/fileapi/isolated_context.h"
24 25
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 MediaFileSystemRegistry* MediaFileSystemRegistry::GetInstance() { 57 MediaFileSystemRegistry* MediaFileSystemRegistry::GetInstance() {
57 return g_media_file_system_registry.Pointer(); 58 return g_media_file_system_registry.Pointer();
58 } 59 }
59 60
60 std::vector<MediaFileSystemRegistry::MediaFSInfo> 61 std::vector<MediaFileSystemRegistry::MediaFSInfo>
61 MediaFileSystemRegistry::GetMediaFileSystemsForExtension( 62 MediaFileSystemRegistry::GetMediaFileSystemsForExtension(
62 const content::RenderProcessHost* rph, 63 const content::RenderProcessHost* rph,
63 const extensions::Extension& extension) { 64 const extensions::Extension& extension) {
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
65 66
67 //Profile* profile = Profile::FromBrowserContext(rph->GetBrowserContext());
Elliot Glaysher 2012/08/02 23:23:51 stray line?
66 std::vector<MediaFSInfo> results; 68 std::vector<MediaFSInfo> results;
67 std::pair<ChildIdToMediaFSMap::iterator, bool> ret = 69 std::pair<ChildIdToMediaFSMap::iterator, bool> ret =
68 media_fs_map_.insert(std::make_pair(rph, MediaPathToFSIDMap())); 70 media_fs_map_.insert(std::make_pair(rph, MediaPathToFSIDMap()));
69 ChildIdToMediaFSMap::iterator& child_it = ret.first; 71 ChildIdToMediaFSMap::iterator& child_it = ret.first;
70 if (ret.second) { 72 if (ret.second) {
71 // Never seen a GetMediaFileSystems call from this RPH. Initialize its 73 // Never seen a GetMediaFileSystems call from this RPH. Initialize its
72 // file system mappings. 74 // file system mappings.
73 RegisterForRPHGoneNotifications(rph); 75 RegisterForRPHGoneNotifications(rph);
74 FilePath pictures_path; 76 FilePath pictures_path;
75 // TODO(vandebo) file system galleries need a unique id as well. 77 // TODO(vandebo) file system galleries need a unique id as well.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
130 const RenderProcessHost* rph = 132 const RenderProcessHost* rph =
131 content::Source<content::RenderProcessHost>(source).ptr(); 133 content::Source<content::RenderProcessHost>(source).ptr();
132 ChildIdToMediaFSMap::iterator child_it = media_fs_map_.find(rph); 134 ChildIdToMediaFSMap::iterator child_it = media_fs_map_.find(rph);
133 CHECK(child_it != media_fs_map_.end()); 135 CHECK(child_it != media_fs_map_.end());
134 // No need to revoke the isolated file systems. The RPH will do that. 136 // No need to revoke the isolated file systems. The RPH will do that.
135 media_fs_map_.erase(child_it); 137 media_fs_map_.erase(child_it);
136 UnregisterForRPHGoneNotifications(rph); 138 UnregisterForRPHGoneNotifications(rph);
137 } 139 }
138 140
141 std::string MediaFileSystemRegistry::GetDeviceIdFromPath(const FilePath& path) {
142 // TODO(vandebo) Do something better here.
143 // Iterate system monitor attached media devices looking for a match. If not,
144 // return the path.
145 return path.value();
146 }
147
139 /****************** 148 /******************
140 * Private methods 149 * Private methods
141 ******************/ 150 ******************/
142 151
143 MediaFileSystemRegistry::MediaFileSystemRegistry() { 152 MediaFileSystemRegistry::MediaFileSystemRegistry() {
144 SystemMonitor::Get()->AddDevicesChangedObserver(this); 153 SystemMonitor::Get()->AddDevicesChangedObserver(this);
145 } 154 }
146 155
147 MediaFileSystemRegistry::~MediaFileSystemRegistry() { 156 MediaFileSystemRegistry::~MediaFileSystemRegistry() {
148 SystemMonitor::Get()->RemoveDevicesChangedObserver(this); 157 SystemMonitor::Get()->RemoveDevicesChangedObserver(this);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 MediaPathToFSIDMap& child_map = child_it->second; 201 MediaPathToFSIDMap& child_map = child_it->second;
193 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path); 202 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path);
194 if (media_path_it == child_map.end()) 203 if (media_path_it == child_map.end())
195 continue; 204 continue;
196 isolated_context->RevokeFileSystem(media_path_it->second); 205 isolated_context->RevokeFileSystem(media_path_it->second);
197 child_map.erase(media_path_it); 206 child_map.erase(media_path_it);
198 } 207 }
199 } 208 }
200 209
201 } // namespace chrome 210 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698