| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/ash/media_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/media_delegate_chromeos.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/tray/system_tray_notifier.h" | 8 #include "ash/system/tray/system_tray_notifier.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "chrome/browser/chromeos/extensions/media_player_api.h" | 10 #include "chrome/browser/chromeos/extensions/media_player_api.h" |
| 11 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" | 11 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" |
| 12 #include "chrome/browser/media/media_stream_capture_indicator.h" | 12 #include "chrome/browser/media/media_stream_capture_indicator.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_list.h" | 15 #include "chrome/browser/ui/browser_list.h" |
| 16 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
| 19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "extensions/browser/app_window/app_window.h" | 20 #include "extensions/browser/app_window/app_window.h" |
| 21 #include "extensions/browser/app_window/app_window_registry.h" | 21 #include "extensions/browser/app_window/app_window_registry.h" |
| 22 #include "extensions/browser/extension_system.h" | |
| 23 #include "extensions/browser/process_manager.h" | 22 #include "extensions/browser/process_manager.h" |
| 24 | 23 |
| 25 namespace { | 24 namespace { |
| 26 | 25 |
| 27 void GetMediaCaptureState( | 26 void GetMediaCaptureState( |
| 28 const MediaStreamCaptureIndicator* indicator, | 27 const MediaStreamCaptureIndicator* indicator, |
| 29 content::WebContents* web_contents, | 28 content::WebContents* web_contents, |
| 30 int* media_state_out) { | 29 int* media_state_out) { |
| 31 if (indicator->IsCapturingVideo(web_contents)) | 30 if (indicator->IsCapturingVideo(web_contents)) |
| 32 *media_state_out |= ash::MEDIA_CAPTURE_VIDEO; | 31 *media_state_out |= ash::MEDIA_CAPTURE_VIDEO; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 GetMediaCaptureState(indicator, (*iter)->web_contents(), media_state_out); | 69 GetMediaCaptureState(indicator, (*iter)->web_contents(), media_state_out); |
| 71 if (*media_state_out == ash::MEDIA_CAPTURE_AUDIO_VIDEO) | 70 if (*media_state_out == ash::MEDIA_CAPTURE_AUDIO_VIDEO) |
| 72 return; | 71 return; |
| 73 } | 72 } |
| 74 } | 73 } |
| 75 | 74 |
| 76 void GetExtensionMediaCaptureState( | 75 void GetExtensionMediaCaptureState( |
| 77 const MediaStreamCaptureIndicator* indicator, | 76 const MediaStreamCaptureIndicator* indicator, |
| 78 content::BrowserContext* context, | 77 content::BrowserContext* context, |
| 79 int* media_state_out) { | 78 int* media_state_out) { |
| 80 extensions::ProcessManager* process_manager = | |
| 81 extensions::ExtensionSystem::Get(context)->process_manager(); | |
| 82 const extensions::ProcessManager::ViewSet view_set = | 79 const extensions::ProcessManager::ViewSet view_set = |
| 83 process_manager->GetAllViews(); | 80 extensions::ProcessManager::Get(context)->GetAllViews(); |
| 84 for (extensions::ProcessManager::ViewSet::const_iterator iter = | 81 for (extensions::ProcessManager::ViewSet::const_iterator iter = |
| 85 view_set.begin(); | 82 view_set.begin(); |
| 86 iter != view_set.end(); | 83 iter != view_set.end(); |
| 87 ++iter) { | 84 ++iter) { |
| 88 content::WebContents* web_contents = | 85 content::WebContents* web_contents = |
| 89 content::WebContents::FromRenderViewHost(*iter); | 86 content::WebContents::FromRenderViewHost(*iter); |
| 90 // RVH may not have web contents. | 87 // RVH may not have web contents. |
| 91 if (!web_contents) | 88 if (!web_contents) |
| 92 continue; | 89 continue; |
| 93 GetMediaCaptureState(indicator, web_contents, media_state_out); | 90 GetMediaCaptureState(indicator, web_contents, media_state_out); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 FROM_HERE, | 161 FROM_HERE, |
| 165 base::Bind(&MediaDelegateChromeOS::NotifyMediaCaptureChange, | 162 base::Bind(&MediaDelegateChromeOS::NotifyMediaCaptureChange, |
| 166 weak_ptr_factory_.GetWeakPtr())); | 163 weak_ptr_factory_.GetWeakPtr())); |
| 167 } | 164 } |
| 168 | 165 |
| 169 void MediaDelegateChromeOS::NotifyMediaCaptureChange() { | 166 void MediaDelegateChromeOS::NotifyMediaCaptureChange() { |
| 170 ash::Shell::GetInstance() | 167 ash::Shell::GetInstance() |
| 171 ->system_tray_notifier() | 168 ->system_tray_notifier() |
| 172 ->NotifyMediaCaptureChanged(); | 169 ->NotifyMediaCaptureChanged(); |
| 173 } | 170 } |
| OLD | NEW |