OLD | NEW |
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/media_stream_capture_indicator.h" | 5 #include "chrome/browser/media/media_stream_capture_indicator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 extension, | 278 extension, |
279 extension->GetIconResource(32, ExtensionIconSet::MATCH_BIGGER), | 279 extension->GetIconResource(32, ExtensionIconSet::MATCH_BIGGER), |
280 gfx::Size(32, 32), | 280 gfx::Size(32, 32), |
281 ImageLoadingTracker::CACHE); | 281 ImageLoadingTracker::CACHE); |
282 return; | 282 return; |
283 } | 283 } |
284 | 284 |
285 string16 title = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 285 string16 title = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
286 string16 body = l10n_util::GetStringFUTF16(message_id, | 286 string16 body = l10n_util::GetStringFUTF16(message_id, |
287 GetSecurityOrigin(render_process_id, render_view_id)); | 287 GetSecurityOrigin(render_process_id, render_view_id)); |
288 status_icon_->DisplayBalloon(*balloon_image_, title, body); | 288 status_icon_->DisplayBalloon(*balloon_image_->bitmap(), title, body); |
289 } | 289 } |
290 | 290 |
291 void MediaStreamCaptureIndicator::OnImageLoaded( | 291 void MediaStreamCaptureIndicator::OnImageLoaded( |
292 const gfx::Image& image, | 292 const gfx::Image& image, |
293 const std::string& extension_id, | 293 const std::string& extension_id, |
294 int index) { | 294 int index) { |
295 string16 message; | 295 string16 message; |
296 message.swap(pending_messages_[index]); | 296 message.swap(pending_messages_[index]); |
297 pending_messages_.erase(index); | 297 pending_messages_.erase(index); |
298 | 298 |
299 status_icon_->DisplayBalloon( | 299 const gfx::ImageSkia* image_skia = !image.IsEmpty() ? image.ToImageSkia() : |
300 !image.IsEmpty() ? *image.ToImageSkia() : | 300 ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
301 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 301 IDR_APP_DEFAULT_ICON); |
302 IDR_APP_DEFAULT_ICON), | 302 status_icon_->DisplayBalloon(*image_skia->bitmap(), string16(), message); |
303 string16(), | |
304 message); | |
305 } | 303 } |
306 | 304 |
307 void MediaStreamCaptureIndicator::Hide() { | 305 void MediaStreamCaptureIndicator::Hide() { |
308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 306 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
309 DCHECK(tabs_.empty()); | 307 DCHECK(tabs_.empty()); |
310 if (!status_icon_) | 308 if (!status_icon_) |
311 return; | 309 return; |
312 | 310 |
313 // If there is no browser process, we should not do anything. | 311 // If there is no browser process, we should not do anything. |
314 if (!g_browser_process) | 312 if (!g_browser_process) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 UpdateStatusTrayIconDisplay(audio, video); | 361 UpdateStatusTrayIconDisplay(audio, video); |
364 } | 362 } |
365 | 363 |
366 void MediaStreamCaptureIndicator::UpdateStatusTrayIconDisplay( | 364 void MediaStreamCaptureIndicator::UpdateStatusTrayIconDisplay( |
367 bool audio, bool video) { | 365 bool audio, bool video) { |
368 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 366 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
369 DCHECK(audio || video); | 367 DCHECK(audio || video); |
370 int message_id = 0; | 368 int message_id = 0; |
371 if (audio && video) { | 369 if (audio && video) { |
372 message_id = IDS_MEDIA_STREAM_STATUS_TRAY_TEXT_AUDIO_AND_VIDEO; | 370 message_id = IDS_MEDIA_STREAM_STATUS_TRAY_TEXT_AUDIO_AND_VIDEO; |
373 status_icon_->SetImage(*camera_image_); | 371 status_icon_->SetImage(*camera_image_->bitmap()); |
374 } else if (audio && !video) { | 372 } else if (audio && !video) { |
375 message_id = IDS_MEDIA_STREAM_STATUS_TRAY_TEXT_AUDIO_ONLY; | 373 message_id = IDS_MEDIA_STREAM_STATUS_TRAY_TEXT_AUDIO_ONLY; |
376 status_icon_->SetImage(*mic_image_); | 374 status_icon_->SetImage(*mic_image_->bitmap()); |
377 } else if (!audio && video) { | 375 } else if (!audio && video) { |
378 message_id = IDS_MEDIA_STREAM_STATUS_TRAY_TEXT_VIDEO_ONLY; | 376 message_id = IDS_MEDIA_STREAM_STATUS_TRAY_TEXT_VIDEO_ONLY; |
379 status_icon_->SetImage(*camera_image_); | 377 status_icon_->SetImage(*camera_image_->bitmap()); |
380 } | 378 } |
381 | 379 |
382 status_icon_->SetToolTip(l10n_util::GetStringFUTF16( | 380 status_icon_->SetToolTip(l10n_util::GetStringFUTF16( |
383 message_id, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 381 message_id, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
384 } | 382 } |
385 | 383 |
386 void MediaStreamCaptureIndicator::AddCaptureDeviceTab( | 384 void MediaStreamCaptureIndicator::AddCaptureDeviceTab( |
387 int render_process_id, | 385 int render_process_id, |
388 int render_view_id, | 386 int render_view_id, |
389 const content::MediaStreamDevices& devices) { | 387 const content::MediaStreamDevices& devices) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 DCHECK_GE(iter->video_ref_count, 0); | 436 DCHECK_GE(iter->video_ref_count, 0); |
439 } | 437 } |
440 | 438 |
441 // Remove the tab if all the devices have been closed. | 439 // Remove the tab if all the devices have been closed. |
442 if (iter->audio_ref_count == 0 && iter->video_ref_count == 0) | 440 if (iter->audio_ref_count == 0 && iter->video_ref_count == 0) |
443 tabs_.erase(iter); | 441 tabs_.erase(iter); |
444 | 442 |
445 UpdateStatusTrayIconContextMenu(); | 443 UpdateStatusTrayIconContextMenu(); |
446 } | 444 } |
447 | 445 |
OLD | NEW |