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

Side by Side Diff: chrome/browser/media_gallery/media_device_notifications_window_win.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/media_gallery/media_device_notifications_window_win.h" 5 #include "chrome/browser/media_gallery/media_device_notifications_window_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <dbt.h> 8 #include <dbt.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/sys_string_conversions.h" 13 #include "base/string_number_conversions.h"
14 #include "base/system_monitor/system_monitor.h" 14 #include "base/system_monitor/system_monitor.h"
15 #include "base/win/wrapped_window_proc.h" 15 #include "base/win/wrapped_window_proc.h"
16 #include "chrome/browser/media_gallery/media_device_notifications_utils.h" 16 #include "chrome/browser/media_gallery/media_device_notifications_utils.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 18
19 using content::BrowserThread; 19 using content::BrowserThread;
20 20
21 namespace { 21 namespace {
22 22
23 const wchar_t WindowClassName[] = L"Chrome_MediaDeviceNotificationWindow"; 23 const wchar_t WindowClassName[] = L"Chrome_MediaDeviceNotificationWindow";
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 DWORD unitmask = GetVolumeBitMaskFromBroadcastHeader(data); 95 DWORD unitmask = GetVolumeBitMaskFromBroadcastHeader(data);
96 for (int i = 0; unitmask; ++i, unitmask >>= 1) { 96 for (int i = 0; unitmask; ++i, unitmask >>= 1) {
97 if (unitmask & 0x01) { 97 if (unitmask & 0x01) {
98 FilePath::StringType drive(L"_:\\"); 98 FilePath::StringType drive(L"_:\\");
99 drive[0] = L'A' + i; 99 drive[0] = L'A' + i;
100 WCHAR volume_name[MAX_PATH + 1]; 100 WCHAR volume_name[MAX_PATH + 1];
101 if ((*volume_name_func_)(drive.c_str(), volume_name, MAX_PATH + 1)) { 101 if ((*volume_name_func_)(drive.c_str(), volume_name, MAX_PATH + 1)) {
102 BrowserThread::PostTask( 102 BrowserThread::PostTask(
103 BrowserThread::FILE, FROM_HERE, 103 BrowserThread::FILE, FROM_HERE,
104 base::Bind(&MediaDeviceNotificationsWindowWin:: 104 base::Bind(&MediaDeviceNotificationsWindowWin::
105 CheckDeviceTypeOnFileThread, this, i, 105 CheckDeviceTypeOnFileThread, this, base::IntToString(i),
106 FilePath::StringType(volume_name), FilePath(drive))); 106 FilePath::StringType(volume_name), FilePath(drive)));
107 } 107 }
108 } 108 }
109 } 109 }
110 break; 110 break;
111 } 111 }
112 case DBT_DEVICEREMOVECOMPLETE: { 112 case DBT_DEVICEREMOVECOMPLETE: {
113 DWORD unitmask = GetVolumeBitMaskFromBroadcastHeader(data); 113 DWORD unitmask = GetVolumeBitMaskFromBroadcastHeader(data);
114 for (int i = 0; unitmask; ++i, unitmask >>= 1) { 114 for (int i = 0; unitmask; ++i, unitmask >>= 1) {
115 if (unitmask & 0x01) { 115 if (unitmask & 0x01) {
116 base::SystemMonitor* monitor = base::SystemMonitor::Get(); 116 base::SystemMonitor* monitor = base::SystemMonitor::Get();
117 monitor->ProcessMediaDeviceDetached(i); 117 monitor->ProcessMediaDeviceDetached(base::IntToString(i));
118 } 118 }
119 } 119 }
120 break; 120 break;
121 } 121 }
122 } 122 }
123 return TRUE; 123 return TRUE;
124 } 124 }
125 125
126 void MediaDeviceNotificationsWindowWin::CheckDeviceTypeOnFileThread( 126 void MediaDeviceNotificationsWindowWin::CheckDeviceTypeOnFileThread(
127 unsigned int id, 127 const std::string& id,
128 const FilePath::StringType& device_name, 128 const FilePath::StringType& device_name,
129 const FilePath& path) { 129 const FilePath& path) {
130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
131 if (!IsMediaDevice(path.value())) 131 if (!IsMediaDevice(path.value()))
132 return; 132 return;
133 133
134 BrowserThread::PostTask( 134 BrowserThread::PostTask(
135 BrowserThread::UI, FROM_HERE, 135 BrowserThread::UI, FROM_HERE,
136 base::Bind( 136 base::Bind(
137 &MediaDeviceNotificationsWindowWin:: 137 &MediaDeviceNotificationsWindowWin::
138 ProcessMediaDeviceAttachedOnUIThread, 138 ProcessMediaDeviceAttachedOnUIThread,
139 this, id, device_name, path)); 139 this, id, device_name, path));
140 } 140 }
141 141
142 void MediaDeviceNotificationsWindowWin::ProcessMediaDeviceAttachedOnUIThread( 142 void MediaDeviceNotificationsWindowWin::ProcessMediaDeviceAttachedOnUIThread(
143 unsigned int id, 143 const std::string& id,
144 const FilePath::StringType& device_name, 144 const FilePath::StringType& device_name,
145 const FilePath& path) { 145 const FilePath& path) {
146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
147 147
148 const std::string device_name_utf8(base::SysWideToUTF8(device_name));
149 base::SystemMonitor* monitor = base::SystemMonitor::Get(); 148 base::SystemMonitor* monitor = base::SystemMonitor::Get();
150 monitor->ProcessMediaDeviceAttached(id, device_name_utf8, path); 149 monitor->ProcessMediaDeviceAttached(id,
150 device_name,
151 base::SystemMonitor::TYPE_PATH,
152 path.value());
151 } 153 }
152 154
153 LRESULT CALLBACK MediaDeviceNotificationsWindowWin::WndProc( 155 LRESULT CALLBACK MediaDeviceNotificationsWindowWin::WndProc(
154 HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { 156 HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
155 switch (message) { 157 switch (message) {
156 case WM_DEVICECHANGE: 158 case WM_DEVICECHANGE:
157 return OnDeviceChange(static_cast<UINT>(wparam), 159 return OnDeviceChange(static_cast<UINT>(wparam),
158 static_cast<DWORD>(lparam)); 160 static_cast<DWORD>(lparam));
159 default: 161 default:
160 break; 162 break;
(...skipping 10 matching lines...) Expand all
171 LPARAM lparam) { 173 LPARAM lparam) {
172 MediaDeviceNotificationsWindowWin* msg_wnd = 174 MediaDeviceNotificationsWindowWin* msg_wnd =
173 reinterpret_cast<MediaDeviceNotificationsWindowWin*>( 175 reinterpret_cast<MediaDeviceNotificationsWindowWin*>(
174 GetWindowLongPtr(hwnd, GWLP_USERDATA)); 176 GetWindowLongPtr(hwnd, GWLP_USERDATA));
175 if (msg_wnd) 177 if (msg_wnd)
176 return msg_wnd->WndProc(hwnd, message, wparam, lparam); 178 return msg_wnd->WndProc(hwnd, message, wparam, lparam);
177 return ::DefWindowProc(hwnd, message, wparam, lparam); 179 return ::DefWindowProc(hwnd, message, wparam, lparam);
178 } 180 }
179 181
180 } // namespace chrome 182 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698