OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chromeos/extensions/file_browser_event_router.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/chromeos/cros/cros_library.h" | 11 #include "chrome/browser/chromeos/cros/cros_library.h" |
12 #include "chrome/browser/chromeos/login/user_manager.h" | 12 #include "chrome/browser/chromeos/login/user_manager.h" |
13 #include "chrome/browser/chromeos/notifications/system_notification.h" | 13 #include "chrome/browser/chromeos/notifications/system_notification.h" |
14 #include "chrome/browser/extensions/extension_event_names.h" | 14 #include "chrome/browser/extensions/extension_event_names.h" |
15 #include "chrome/browser/extensions/extension_event_router.h" | 15 #include "chrome/browser/extensions/extension_event_router.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/extensions/file_manager_util.h" |
17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
18 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
20 | 21 |
21 ExtensionFileBrowserEventRouter::ExtensionFileBrowserEventRouter() | 22 ExtensionFileBrowserEventRouter::ExtensionFileBrowserEventRouter() |
22 : profile_(NULL) { | 23 : profile_(NULL) { |
23 } | 24 } |
24 | 25 |
25 ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { | 26 ExtensionFileBrowserEventRouter::~ExtensionFileBrowserEventRouter() { |
26 } | 27 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 const chromeos::MountLibrary::Disk* disk) { | 138 const chromeos::MountLibrary::Disk* disk) { |
138 VLOG(1) << "Disk changed : " << disk->device_path(); | 139 VLOG(1) << "Disk changed : " << disk->device_path(); |
139 if (!disk->mount_path().empty()) { | 140 if (!disk->mount_path().empty()) { |
140 HideDeviceNotification(disk->system_path()); | 141 HideDeviceNotification(disk->system_path()); |
141 // Remember this mount point. | 142 // Remember this mount point. |
142 if (mounted_devices_.find(disk->device_path()) == mounted_devices_.end()) { | 143 if (mounted_devices_.find(disk->device_path()) == mounted_devices_.end()) { |
143 mounted_devices_.insert( | 144 mounted_devices_.insert( |
144 std::pair<std::string, std::string>(disk->device_path(), | 145 std::pair<std::string, std::string>(disk->device_path(), |
145 disk->mount_path())); | 146 disk->mount_path())); |
146 DispatchEvent(disk->mount_path()); | 147 DispatchEvent(disk->mount_path()); |
147 // TODO(zelidrag): Find better icon here. | 148 HideDeviceNotification(disk->system_path()); |
148 ShowDeviceNotification(disk->system_path(), IDR_PAGEINFO_INFO, | 149 FileManagerUtil::ShowFullTabUrl(profile_, FilePath(disk->mount_path())); |
149 l10n_util::GetStringUTF16(IDS_REMOVABLE_DEVICE_MOUNTED_MESSAGE)); | |
150 } | 150 } |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 void ExtensionFileBrowserEventRouter::OnDeviceAdded( | 154 void ExtensionFileBrowserEventRouter::OnDeviceAdded( |
155 const std::string& device_path) { | 155 const std::string& device_path) { |
156 VLOG(1) << "Device added : " << device_path; | 156 VLOG(1) << "Device added : " << device_path; |
157 // TODO(zelidrag): Find better icon here. | 157 // TODO(zelidrag): Find better icon here. |
158 ShowDeviceNotification(device_path, IDR_PAGEINFO_INFO, | 158 ShowDeviceNotification(device_path, IDR_PAGEINFO_INFO, |
159 l10n_util::GetStringUTF16(IDS_REMOVABLE_DEVICE_SCANNING_MESSAGE)); | 159 l10n_util::GetStringUTF16(IDS_REMOVABLE_DEVICE_SCANNING_MESSAGE)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 ++iter) { | 211 ++iter) { |
212 const std::string& notification_device_path = iter->first; | 212 const std::string& notification_device_path = iter->first; |
213 // Doing a sub string match so that we find if this new one is a subdevice | 213 // Doing a sub string match so that we find if this new one is a subdevice |
214 // of another already inserted device. | 214 // of another already inserted device. |
215 if (StartsWithASCII(system_path, notification_device_path, true)) { | 215 if (StartsWithASCII(system_path, notification_device_path, true)) { |
216 return iter; | 216 return iter; |
217 } | 217 } |
218 } | 218 } |
219 return notifications_.end(); | 219 return notifications_.end(); |
220 } | 220 } |
OLD | NEW |