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

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

Issue 10780023: Change base::SystemMonitor's media device functions to take a type and string16 instead of a FilePa… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros 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 13 matching lines...) Expand all
24 sys_monitor->AddDevicesChangedObserver(this); 24 sys_monitor->AddDevicesChangedObserver(this);
25 } 25 }
26 26
27 DeviceAttachedIntentSource::~DeviceAttachedIntentSource() { 27 DeviceAttachedIntentSource::~DeviceAttachedIntentSource() {
28 SystemMonitor* sys_monitor = SystemMonitor::Get(); 28 SystemMonitor* sys_monitor = SystemMonitor::Get();
29 if (sys_monitor) 29 if (sys_monitor)
30 sys_monitor->RemoveDevicesChangedObserver(this); 30 sys_monitor->RemoveDevicesChangedObserver(this);
31 } 31 }
32 32
33 void DeviceAttachedIntentSource::OnMediaDeviceAttached( 33 void DeviceAttachedIntentSource::OnMediaDeviceAttached(
34 const base::SystemMonitor::DeviceIdType& id, 34 const std::string& id,
35 const std::string& name, 35 const string16& name,
36 const FilePath& device_path) { 36 base::SystemMonitor::MediaDeviceType type,
37 const FilePath::StringType& location) {
37 if (!browser_->window()->IsActive()) 38 if (!browser_->window()->IsActive())
38 return; 39 return;
39 40
41 // Only handle FilePaths for now.
42 if (type != SystemMonitor::TYPE_PATH)
43 return;
44
40 // Sanity checks for |device_path|. 45 // Sanity checks for |device_path|.
41 if (!device_path.IsAbsolute() || device_path.ReferencesParent()) { 46 const FilePath device_path(location);
47 if (!device_path.IsAbsolute() || device_path.ReferencesParent())
42 return; 48 return;
43 }
44 49
45 std::string device_name; 50 std::string device_name;
46 51
47 // Register device path as an isolated file system. 52 // Register device path as an isolated file system.
48 const std::string filesystem_id = 53 const std::string filesystem_id =
49 fileapi::IsolatedContext::GetInstance()->RegisterFileSystemForFile( 54 fileapi::IsolatedContext::GetInstance()->RegisterFileSystemForFile(
50 device_path, &device_name); 55 device_path, &device_name);
51 56
52 CHECK(!filesystem_id.empty()); 57 CHECK(!filesystem_id.empty());
53 webkit_glue::WebIntentData intent( 58 webkit_glue::WebIntentData intent(
54 ASCIIToUTF16("chrome-extension://attach"), 59 ASCIIToUTF16("chrome-extension://attach"),
55 ASCIIToUTF16("chrome-extension://filesystem"), 60 ASCIIToUTF16("chrome-extension://filesystem"),
56 device_name, 61 device_name,
57 filesystem_id); 62 filesystem_id);
58 63
59 content::WebIntentsDispatcher* dispatcher = 64 delegate_->WebIntentDispatch(NULL /* no WebContents */,
60 content::WebIntentsDispatcher::Create(intent); 65 content::WebIntentsDispatcher::Create(intent));
61 delegate_->WebIntentDispatch(NULL, dispatcher);
62 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698