| Index: chrome/browser/system_monitor/removable_device_notifications_window_win.cc
|
| diff --git a/chrome/browser/system_monitor/removable_device_notifications_window_win.cc b/chrome/browser/system_monitor/removable_device_notifications_window_win.cc
|
| index 74250b9ba9b7fcdbd60b32d7ce2615fcc7342c4d..6477c0d7f3867e235725309e83ff322d8c8cef86 100644
|
| --- a/chrome/browser/system_monitor/removable_device_notifications_window_win.cc
|
| +++ b/chrome/browser/system_monitor/removable_device_notifications_window_win.cc
|
| @@ -8,12 +8,11 @@
|
| #include <dbt.h>
|
| #include <fileapi.h>
|
|
|
| -#include "base/file_path.h"
|
| #include "base/win/wrapped_window_proc.h"
|
| #include "chrome/browser/system_monitor/media_storage_util.h"
|
| -
|
| -using base::SystemMonitor;
|
| -using base::win::WrappedWindowProc;
|
| +#include "chrome/browser/system_monitor/portable_device_watcher_win.h"
|
| +#include "chrome/browser/system_monitor/removable_device_constants.h"
|
| +#include "chrome/browser/system_monitor/volume_mount_watcher_win.h"
|
|
|
| namespace chrome {
|
|
|
| @@ -26,26 +25,33 @@ RemovableDeviceNotificationsWindowWin*
|
|
|
| } // namespace
|
|
|
| +
|
| +// RemovableDeviceNotificationsWindowWin --------------------------------------
|
| +
|
| // static
|
| RemovableDeviceNotificationsWindowWin*
|
| -RemovableDeviceNotificationsWindowWin::Create() {
|
| - return new RemovableDeviceNotificationsWindowWin(new VolumeMountWatcherWin());
|
| + RemovableDeviceNotificationsWindowWin::Create() {
|
| + return new RemovableDeviceNotificationsWindowWin(
|
| + new VolumeMountWatcherWin(), new PortableDeviceWatcherWin());
|
| }
|
|
|
| RemovableDeviceNotificationsWindowWin::
|
| -RemovableDeviceNotificationsWindowWin(
|
| - VolumeMountWatcherWin* volume_mount_watcher)
|
| + RemovableDeviceNotificationsWindowWin(
|
| + VolumeMountWatcherWin* volume_mount_watcher,
|
| + PortableDeviceWatcherWin* portable_device_watcher)
|
| : window_class_(0),
|
| instance_(NULL),
|
| window_(NULL),
|
| - volume_mount_watcher_(volume_mount_watcher) {
|
| + volume_mount_watcher_(volume_mount_watcher),
|
| + portable_device_watcher_(portable_device_watcher) {
|
| DCHECK(volume_mount_watcher_);
|
| + DCHECK(portable_device_watcher_);
|
| DCHECK(!g_removable_device_notifications_window_win);
|
| g_removable_device_notifications_window_win = this;
|
| }
|
|
|
| RemovableDeviceNotificationsWindowWin::
|
| -~RemovableDeviceNotificationsWindowWin() {
|
| + ~RemovableDeviceNotificationsWindowWin() {
|
| if (window_)
|
| DestroyWindow(window_);
|
|
|
| @@ -58,18 +64,17 @@ RemovableDeviceNotificationsWindowWin::
|
|
|
| // static
|
| RemovableDeviceNotificationsWindowWin*
|
| -RemovableDeviceNotificationsWindowWin::GetInstance() {
|
| + RemovableDeviceNotificationsWindowWin::GetInstance() {
|
| DCHECK(g_removable_device_notifications_window_win);
|
| return g_removable_device_notifications_window_win;
|
| }
|
|
|
| void RemovableDeviceNotificationsWindowWin::Init() {
|
| - volume_mount_watcher_->Init();
|
| -
|
| WNDCLASSEX window_class;
|
| base::win::InitializeWindowClass(
|
| kWindowClassName,
|
| - &WrappedWindowProc<RemovableDeviceNotificationsWindowWin::WndProcThunk>,
|
| + &base::win::WrappedWindowProc<
|
| + RemovableDeviceNotificationsWindowWin::WndProcThunk>,
|
| 0, 0, 0, NULL, NULL, NULL, NULL, NULL,
|
| &window_class);
|
| instance_ = window_class.hInstance;
|
| @@ -79,6 +84,8 @@ void RemovableDeviceNotificationsWindowWin::Init() {
|
| window_ = CreateWindow(MAKEINTATOM(window_class_), 0, 0, 0, 0, 0, 0, 0, 0,
|
| instance_, 0);
|
| SetWindowLongPtr(window_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
|
| + volume_mount_watcher_->Init();
|
| + portable_device_watcher_->Init(window_);
|
| }
|
|
|
| bool RemovableDeviceNotificationsWindowWin::GetDeviceInfoForPath(
|
| @@ -94,11 +101,11 @@ bool RemovableDeviceNotificationsWindowWin::GetDeviceInfoForPath(
|
| // To compute the device id, the device type is needed. For removable
|
| // devices, that requires knowing if there's a DCIM directory, which would
|
| // require bouncing over to the file thread. Instead, just iterate the
|
| - // devices in SystemMonitor.
|
| + // devices in base::SystemMonitor.
|
| std::string device_id;
|
| if (removable) {
|
| - std::vector<SystemMonitor::RemovableStorageInfo> attached_devices =
|
| - SystemMonitor::Get()->GetAttachedRemovableStorage();
|
| + std::vector<base::SystemMonitor::RemovableStorageInfo> attached_devices =
|
| + base::SystemMonitor::Get()->GetAttachedRemovableStorage();
|
| bool found = false;
|
| for (size_t i = 0; i < attached_devices.size(); i++) {
|
| MediaStorageUtil::Type type;
|
| @@ -153,6 +160,9 @@ LRESULT CALLBACK RemovableDeviceNotificationsWindowWin::WndProc(
|
| bool RemovableDeviceNotificationsWindowWin::GetDeviceInfo(
|
| const FilePath& device_path, string16* device_location,
|
| std::string* unique_id, string16* name, bool* removable) {
|
| + // TODO(kmadhusu) Implement PortableDeviceWatcherWin::GetDeviceInfo()
|
| + // function when we have the functionality to add a sub directory of
|
| + // portable device as a media gallery.
|
| return volume_mount_watcher_->GetDeviceInfo(device_path, device_location,
|
| unique_id, name, removable);
|
| }
|
| @@ -160,6 +170,7 @@ bool RemovableDeviceNotificationsWindowWin::GetDeviceInfo(
|
| void RemovableDeviceNotificationsWindowWin::OnDeviceChange(UINT event_type,
|
| LPARAM data) {
|
| volume_mount_watcher_->OnWindowMessage(event_type, data);
|
| + portable_device_watcher_->OnWindowMessage(event_type, data);
|
| }
|
|
|
| } // namespace chrome
|
|
|