Chromium Code Reviews| 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_client.h" | 5 #include "chrome/browser/ui/ash/media_client.h" |
| 6 | 6 |
| 7 #include "ash/common/session/session_state_delegate.h" | |
| 8 #include "ash/common/wm_shell.h" | |
| 9 #include "ash/content/shell_content_state.h" | |
| 10 #include "base/location.h" | 7 #include "base/location.h" |
| 11 #include "base/logging.h" | 8 #include "base/logging.h" |
| 12 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 13 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "chrome/browser/chromeos/extensions/media_player_api.h" | 12 #include "chrome/browser/chromeos/extensions/media_player_api.h" |
| 16 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" | 13 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" |
| 17 #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h" | 14 #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/browser/ui/ash/ash_util.h" | 16 #include "chrome/browser/ui/ash/ash_util.h" |
| 17 #include "chrome/browser/ui/ash/chrome_shell_content_state.h" | |
| 20 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/browser_list.h" | 19 #include "chrome/browser/ui/browser_list.h" |
| 22 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
| 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 22 #include "components/user_manager/user_manager.h" | |
| 24 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
| 25 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 26 #include "content/public/common/service_manager_connection.h" | 25 #include "content/public/common/service_manager_connection.h" |
| 27 #include "extensions/browser/app_window/app_window.h" | 26 #include "extensions/browser/app_window/app_window.h" |
| 28 #include "extensions/browser/app_window/app_window_registry.h" | 27 #include "extensions/browser/app_window/app_window_registry.h" |
| 29 #include "extensions/browser/process_manager.h" | 28 #include "extensions/browser/process_manager.h" |
| 30 #include "services/service_manager/public/cpp/connector.h" | 29 #include "services/service_manager/public/cpp/connector.h" |
| 31 | 30 |
| 32 using ash::mojom::MediaCaptureState; | 31 using ash::mojom::MediaCaptureState; |
| 33 | 32 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 ->NotifyPrevTrack(); | 162 ->NotifyPrevTrack(); |
| 164 } | 163 } |
| 165 | 164 |
| 166 void MediaClient::RequestCaptureState() { | 165 void MediaClient::RequestCaptureState() { |
| 167 // TODO(erg): Ash doesn't have stable user indexes. Given the asynchronous | 166 // TODO(erg): Ash doesn't have stable user indexes. Given the asynchronous |
| 168 // nature of sending messages over mojo pipes, this could theoretically cause | 167 // nature of sending messages over mojo pipes, this could theoretically cause |
| 169 // bad data, as one side thinks the vector is [user1, user2] while the other | 168 // bad data, as one side thinks the vector is [user1, user2] while the other |
| 170 // thinks [user2, user1]. However, since parts of this system are already | 169 // thinks [user2, user1]. However, since parts of this system are already |
| 171 // asynchronous (see OnRequestUpdate's PostTask()), we're not worrying about | 170 // asynchronous (see OnRequestUpdate's PostTask()), we're not worrying about |
| 172 // this right now. | 171 // this right now. |
| 173 ash::SessionStateDelegate* session_state_delegate = | |
| 174 ash::WmShell::Get()->GetSessionStateDelegate(); | |
| 175 std::vector<MediaCaptureState> state; | 172 std::vector<MediaCaptureState> state; |
| 176 for (ash::UserIndex i = 0; | 173 for (ash::UserIndex i = 0; |
| 177 i < session_state_delegate->NumberOfLoggedInUsers(); ++i) { | 174 static_cast<size_t>(i) < |
|
James Cook
2017/01/09 21:07:19
nit: This might be easier to read if |i| was a uin
riajiang
2017/01/09 23:46:51
Done.
| |
| 175 user_manager::UserManager::Get()->GetLoggedInUsers().size(); | |
| 176 ++i) { | |
| 178 state.push_back(GetMediaCaptureStateByIndex(i)); | 177 state.push_back(GetMediaCaptureStateByIndex(i)); |
| 179 } | 178 } |
| 180 | 179 |
| 181 media_controller_->NotifyCaptureState(std::move(state)); | 180 media_controller_->NotifyCaptureState(std::move(state)); |
| 182 } | 181 } |
| 183 | 182 |
| 184 void MediaClient::OnRequestUpdate(int render_process_id, | 183 void MediaClient::OnRequestUpdate(int render_process_id, |
| 185 int render_frame_id, | 184 int render_frame_id, |
| 186 content::MediaStreamType stream_type, | 185 content::MediaStreamType stream_type, |
| 187 const content::MediaRequestState state) { | 186 const content::MediaRequestState state) { |
| 188 DCHECK(base::MessageLoopForUI::IsCurrent()); | 187 DCHECK(base::MessageLoopForUI::IsCurrent()); |
| 189 // The PostTask is necessary because the state of MediaStreamCaptureIndicator | 188 // The PostTask is necessary because the state of MediaStreamCaptureIndicator |
| 190 // gets updated after this. | 189 // gets updated after this. |
| 191 base::ThreadTaskRunnerHandle::Get()->PostTask( | 190 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 192 FROM_HERE, base::Bind(&MediaClient::RequestCaptureState, | 191 FROM_HERE, base::Bind(&MediaClient::RequestCaptureState, |
| 193 weak_ptr_factory_.GetWeakPtr())); | 192 weak_ptr_factory_.GetWeakPtr())); |
| 194 } | 193 } |
| 195 | 194 |
| 196 MediaCaptureState MediaClient::GetMediaCaptureStateByIndex(int user_index) { | 195 MediaCaptureState MediaClient::GetMediaCaptureStateByIndex(int user_index) { |
| 197 content::BrowserContext* context = | 196 content::BrowserContext* context = |
| 198 ash::ShellContentState::GetInstance()->GetBrowserContextByIndex( | 197 ChromeShellContentState::GetInstance()->GetBrowserContextByIndex( |
| 199 user_index); | 198 user_index); |
| 200 return GetMediaCaptureStateOfAllWebContents(context); | 199 return GetMediaCaptureStateOfAllWebContents(context); |
| 201 } | 200 } |
| OLD | NEW |