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" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/intents/web_intents_registry.h" | 14 #include "chrome/browser/intents/web_intents_registry.h" |
15 #include "chrome/browser/intents/web_intents_registry_factory.h" | 15 #include "chrome/browser/intents/web_intents_registry_factory.h" |
16 #include "chrome/browser/media_gallery/media_storage_util.h" | 16 #include "chrome/browser/media_gallery/media_storage_util.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
20 #include "content/public/browser/web_intents_dispatcher.h" | 20 #include "content/public/browser/web_intents_dispatcher.h" |
21 #include "content/public/browser/web_contents_delegate.h" | 21 #include "content/public/browser/web_contents_delegate.h" |
22 #include "webkit/fileapi/file_system_types.h" | 22 #include "webkit/fileapi/file_system_types.h" |
23 #include "webkit/fileapi/isolated_context.h" | 23 #include "webkit/fileapi/isolated_context.h" |
24 #include "webkit/glue/web_intent_data.h" | 24 #include "webkit/glue/web_intent_data.h" |
25 #include "webkit/glue/web_intent_service_data.h" | 25 #include "webkit/glue/web_intent_service_data.h" |
26 #include "webkit/fileapi/media/media_file_system_config.h" | |
27 | |
28 #if defined(SUPPORT_MEDIA_FILESYSTEM) | |
29 #include "webkit/fileapi/media/media_device_map_service.h" | |
30 | |
31 using fileapi::MediaDeviceMapService; | |
32 #endif | |
33 | 26 |
34 using base::SystemMonitor; | 27 using base::SystemMonitor; |
35 using chrome::MediaStorageUtil; | 28 using chrome::MediaStorageUtil; |
36 using content::WebContentsDelegate; | 29 using content::WebContentsDelegate; |
37 using webkit_glue::WebIntentServiceData; | 30 using webkit_glue::WebIntentServiceData; |
38 | 31 |
39 namespace { | 32 namespace { |
40 | 33 |
41 // Specifies device attached web intent kAction. | 34 // Specifies device attached web intent kAction. |
42 const char kAction[] = "chrome-extension://attach"; | 35 const char kAction[] = "chrome-extension://attach"; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 delegate_->WebIntentDispatch(NULL /* no WebContents */, | 143 delegate_->WebIntentDispatch(NULL /* no WebContents */, |
151 content::WebIntentsDispatcher::Create(intent)); | 144 content::WebIntentsDispatcher::Create(intent)); |
152 } | 145 } |
153 | 146 |
154 void DeviceAttachedIntentSource::OnRemovableStorageDetached( | 147 void DeviceAttachedIntentSource::OnRemovableStorageDetached( |
155 const std::string& id) { | 148 const std::string& id) { |
156 DeviceIdToInfoMap::iterator it = device_id_map_.find(id); | 149 DeviceIdToInfoMap::iterator it = device_id_map_.find(id); |
157 if (it == device_id_map_.end()) | 150 if (it == device_id_map_.end()) |
158 return; | 151 return; |
159 | 152 |
160 // TODO(kmadhusu) This should be something like | |
161 // RevokeFileSystemByDevice(std::string) | |
162 FilePath path(it->second.location); | 153 FilePath path(it->second.location); |
163 fileapi::IsolatedContext::GetInstance()->RevokeFileSystemByPath(path); | 154 fileapi::IsolatedContext::GetInstance()->RevokeFileSystemByPath(path); |
164 | |
165 #if defined(SUPPORT_MEDIA_FILESYSTEM) | |
166 // TODO(kmadhusu, vandebo): Clean up this code. http://crbug.com/140340. | |
167 MediaStorageUtil::Type type; | |
168 MediaStorageUtil::CrackDeviceId(it->second.device_id, &type, NULL); | |
169 if (type == MediaStorageUtil::USB_MTP) { | |
170 MediaDeviceMapService::GetInstance()->RemoveMediaDevice( | |
171 it->second.location); | |
172 } | |
173 #endif | |
174 device_id_map_.erase(it); | 155 device_id_map_.erase(it); |
175 } | 156 } |
OLD | NEW |