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 15 matching lines...) Expand all Loading... | |
38 return; | 39 return; |
39 | 40 |
40 // Sanity checks for |device_path|. | 41 // Sanity checks for |device_path|. |
41 if (!device_path.IsAbsolute() || device_path.ReferencesParent()) { | 42 if (!device_path.IsAbsolute() || device_path.ReferencesParent()) { |
42 return; | 43 return; |
43 } | 44 } |
44 | 45 |
45 std::string device_name; | 46 std::string device_name; |
46 | 47 |
47 // Register device path as an isolated file system. | 48 // Register device path as an isolated file system. |
49 // TODO(kinuko, kmadhusu): Use a different file system type for MTP. | |
48 const std::string filesystem_id = | 50 const std::string filesystem_id = |
49 fileapi::IsolatedContext::GetInstance()->RegisterFileSystemForFile( | 51 fileapi::IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
50 device_path, &device_name); | 52 fileapi::kFileSystemTypeMedia, device_path, &device_name); |
kmadhusu
2012/07/24 22:02:12
Let the initial changes specify the file system ty
kinuko
2012/07/25 17:46:31
Done (in http://crrev.com/148291).
| |
51 | 53 |
52 CHECK(!filesystem_id.empty()); | 54 CHECK(!filesystem_id.empty()); |
53 webkit_glue::WebIntentData intent( | 55 webkit_glue::WebIntentData intent( |
54 ASCIIToUTF16("chrome-extension://attach"), | 56 ASCIIToUTF16("chrome-extension://attach"), |
55 ASCIIToUTF16("chrome-extension://filesystem"), | 57 ASCIIToUTF16("chrome-extension://filesystem"), |
56 device_name, | 58 device_name, |
57 filesystem_id); | 59 filesystem_id); |
58 | 60 |
59 content::WebIntentsDispatcher* dispatcher = | 61 content::WebIntentsDispatcher* dispatcher = |
60 content::WebIntentsDispatcher::Create(intent); | 62 content::WebIntentsDispatcher::Create(intent); |
61 delegate_->WebIntentDispatch(NULL, dispatcher); | 63 delegate_->WebIntentDispatch(NULL, dispatcher); |
62 } | 64 } |
OLD | NEW |