| 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 "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| 11 #include "content/public/browser/web_intents_dispatcher.h" | 11 #include "content/public/browser/web_intents_dispatcher.h" |
| 12 #include "content/public/browser/web_contents_delegate.h" | 12 #include "content/public/browser/web_contents_delegate.h" |
| 13 #include "webkit/fileapi/file_system_types.h" |
| 13 #include "webkit/fileapi/isolated_context.h" | 14 #include "webkit/fileapi/isolated_context.h" |
| 14 #include "webkit/glue/web_intent_data.h" | 15 #include "webkit/glue/web_intent_data.h" |
| 15 | 16 |
| 16 using base::SystemMonitor; | 17 using base::SystemMonitor; |
| 17 using content::WebContentsDelegate; | 18 using content::WebContentsDelegate; |
| 18 | 19 |
| 19 DeviceAttachedIntentSource::DeviceAttachedIntentSource( | 20 DeviceAttachedIntentSource::DeviceAttachedIntentSource( |
| 20 Browser* browser, WebContentsDelegate* delegate) | 21 Browser* browser, WebContentsDelegate* delegate) |
| 21 : browser_(browser), delegate_(delegate) { | 22 : browser_(browser), delegate_(delegate) { |
| 22 SystemMonitor* sys_monitor = SystemMonitor::Get(); | 23 SystemMonitor* sys_monitor = SystemMonitor::Get(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 43 return; | 44 return; |
| 44 | 45 |
| 45 // Sanity checks for |device_path|. | 46 // Sanity checks for |device_path|. |
| 46 const FilePath device_path(location); | 47 const FilePath device_path(location); |
| 47 if (!device_path.IsAbsolute() || device_path.ReferencesParent()) | 48 if (!device_path.IsAbsolute() || device_path.ReferencesParent()) |
| 48 return; | 49 return; |
| 49 | 50 |
| 50 std::string device_name; | 51 std::string device_name; |
| 51 | 52 |
| 52 // Register device path as an isolated file system. | 53 // Register device path as an isolated file system. |
| 54 // TODO(kinuko, kmadhusu): Use a different file system type for MTP. |
| 53 const std::string filesystem_id = | 55 const std::string filesystem_id = |
| 54 fileapi::IsolatedContext::GetInstance()->RegisterFileSystemForFile( | 56 fileapi::IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
| 55 device_path, &device_name); | 57 fileapi::kFileSystemTypeIsolated, device_path, &device_name); |
| 56 | 58 |
| 57 CHECK(!filesystem_id.empty()); | 59 CHECK(!filesystem_id.empty()); |
| 58 webkit_glue::WebIntentData intent( | 60 webkit_glue::WebIntentData intent( |
| 59 ASCIIToUTF16("chrome-extension://attach"), | 61 ASCIIToUTF16("chrome-extension://attach"), |
| 60 ASCIIToUTF16("chrome-extension://filesystem"), | 62 ASCIIToUTF16("chrome-extension://filesystem"), |
| 61 device_name, | 63 device_name, |
| 62 filesystem_id); | 64 filesystem_id); |
| 63 | 65 |
| 64 delegate_->WebIntentDispatch(NULL /* no WebContents */, | 66 delegate_->WebIntentDispatch(NULL /* no WebContents */, |
| 65 content::WebIntentsDispatcher::Create(intent)); | 67 content::WebIntentsDispatcher::Create(intent)); |
| 66 } | 68 } |
| OLD | NEW |