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

Side by Side Diff: chrome/browser/intents/device_attached_intent_source.cc

Issue 10871049: Connect MediaFileSystemRegistry with MediaGalleriesPreferences (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 3 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 #include "chrome/browser/intents/device_attached_intent_source.h" 5 #include "chrome/browser/intents/device_attached_intent_source.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 const FilePath::StringType& location) { 95 const FilePath::StringType& location) {
96 if (!browser_->window()->IsActive()) 96 if (!browser_->window()->IsActive())
97 return; 97 return;
98 98
99 // TODO(kmadhusu): Dispatch intents on incognito window. 99 // TODO(kmadhusu): Dispatch intents on incognito window.
100 if (browser_->profile()->IsOffTheRecord()) 100 if (browser_->profile()->IsOffTheRecord())
101 return; 101 return;
102 102
103 // Only handle mass storage for now. 103 // Only handle mass storage for now.
104 // TODO(kmadhusu): Handle all device types. http://crbug.com/140353. 104 // TODO(kmadhusu): Handle all device types. http://crbug.com/140353.
105 MediaStorageUtil::Type type; 105 if (!MediaStorageUtil::IsMassStorageDevice(id))
106 MediaStorageUtil::CrackDeviceId(id, &type, NULL);
107 if (type == MediaStorageUtil::MTP_OR_PTP)
108 return; 106 return;
109 DCHECK(MediaStorageUtil::IsRemovableDevice(id)); 107 DCHECK(MediaStorageUtil::IsRemovableDevice(id));
110 108
111 // Sanity checks for |device_path|. 109 // Sanity checks for |device_path|.
112 const FilePath device_path(location); 110 const FilePath device_path(location);
113 if (!device_path.IsAbsolute() || device_path.ReferencesParent()) 111 if (!device_path.IsAbsolute() || device_path.ReferencesParent())
114 return; 112 return;
115 113
116 SystemMonitor::RemovableStorageInfo device_info(id, name, location); 114 SystemMonitor::RemovableStorageInfo device_info(id, name, location);
117 scoped_refptr<DispatchIntentTaskHelper> task = new DispatchIntentTaskHelper( 115 scoped_refptr<DispatchIntentTaskHelper> task = new DispatchIntentTaskHelper(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 void DeviceAttachedIntentSource::OnRemovableStorageDetached( 147 void DeviceAttachedIntentSource::OnRemovableStorageDetached(
150 const std::string& id) { 148 const std::string& id) {
151 DeviceIdToInfoMap::iterator it = device_id_map_.find(id); 149 DeviceIdToInfoMap::iterator it = device_id_map_.find(id);
152 if (it == device_id_map_.end()) 150 if (it == device_id_map_.end())
153 return; 151 return;
154 152
155 FilePath path(it->second.location); 153 FilePath path(it->second.location);
156 fileapi::IsolatedContext::GetInstance()->RevokeFileSystemByPath(path); 154 fileapi::IsolatedContext::GetInstance()->RevokeFileSystemByPath(path);
157 device_id_map_.erase(it); 155 device_id_map_.erase(it);
158 } 156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698