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

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

Issue 10713007: Make isolated file system works for a device root (e.g. X:\\) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 "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"
(...skipping 20 matching lines...) Expand all
31 } 31 }
32 32
33 void DeviceAttachedIntentSource::OnMediaDeviceAttached( 33 void DeviceAttachedIntentSource::OnMediaDeviceAttached(
34 const base::SystemMonitor::DeviceIdType& id, 34 const base::SystemMonitor::DeviceIdType& id,
35 const std::string& name, 35 const std::string& name,
36 const FilePath& device_path) { 36 const FilePath& device_path) {
37 if (!browser_->window()->IsActive()) 37 if (!browser_->window()->IsActive())
38 return; 38 return;
39 39
40 // Sanity checks for |device_path|. 40 // Sanity checks for |device_path|.
41 if (!device_path.IsAbsolute() || device_path.ReferencesParent() || 41 if (!device_path.IsAbsolute() || device_path.ReferencesParent()) {
42 device_path.BaseName().IsAbsolute() || device_path.BaseName().empty()) {
43 return; 42 return;
44 } 43 }
44 std::string device_name = fileapi::IsolatedContext::GetNameForPath(
45 device_path);
46 DCHECK(!device_name.empty());
45 47
46 // Register device path as an isolated file system. 48 // Register device path as an isolated file system.
47 std::set<FilePath> fileset;
48 fileset.insert(device_path);
49 const std::string filesystem_id = 49 const std::string filesystem_id =
50 fileapi::IsolatedContext::GetInstance()-> 50 fileapi::IsolatedContext::GetInstance()->RegisterFileSystemForFile(
51 RegisterIsolatedFileSystem(fileset); 51 device_name, device_path);
52
52 CHECK(!filesystem_id.empty()); 53 CHECK(!filesystem_id.empty());
53 webkit_glue::WebIntentData intent( 54 webkit_glue::WebIntentData intent(
54 ASCIIToUTF16("chrome-extension://attach"), 55 ASCIIToUTF16("chrome-extension://attach"),
55 ASCIIToUTF16("chrome-extension://filesystem"), 56 ASCIIToUTF16("chrome-extension://filesystem"),
56 device_path, 57 device_name,
57 filesystem_id); 58 filesystem_id);
58 59
59 content::WebIntentsDispatcher* dispatcher = 60 content::WebIntentsDispatcher* dispatcher =
60 content::WebIntentsDispatcher::Create(intent); 61 content::WebIntentsDispatcher::Create(intent);
61 delegate_->WebIntentDispatch(NULL, dispatcher); 62 delegate_->WebIntentDispatch(NULL, dispatcher);
62 } 63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698