Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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)); |
|
Lei Zhang
2012/09/04 23:38:51
I think you need to remove this?
vandebo (ex-Chrome)
2012/09/05 00:58:12
Why? Device attach intent should only trigger for
| |
| 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( |
| 118 AsWeakPtr(), device_info); | 116 AsWeakPtr(), device_info); |
| 119 WebIntentsRegistryFactory::GetForProfile(browser_->profile())-> | 117 WebIntentsRegistryFactory::GetForProfile(browser_->profile())-> |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 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 } |
| OLD | NEW |