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 "content/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <utility> | 10 #include <utility> |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
875 | 875 |
876 ++number_of_messages; | 876 ++number_of_messages; |
877 IPC::Message* message_copy = new IPC::Message(*message); | 877 IPC::Message* message_copy = new IPC::Message(*message); |
878 message_copy->set_routing_id(rfh->GetRoutingID()); | 878 message_copy->set_routing_id(rfh->GetRoutingID()); |
879 rfh->Send(message_copy); | 879 rfh->Send(message_copy); |
880 } | 880 } |
881 delete message; | 881 delete message; |
882 return number_of_messages; | 882 return number_of_messages; |
883 } | 883 } |
884 | 884 |
885 int WebContentsImpl::SendToAllViews(IPC::Message* message) { | |
clamy
2016/10/05 12:11:35
I think it would make a lot more sense to have the
altimin
2016/10/05 13:26:37
Done.
| |
886 std::unordered_set<RenderViewHost*> render_view_hosts; | |
887 for (RenderFrameHost* rfh : GetAllFrames()) { | |
888 if (!rfh->IsRenderFrameLive()) | |
889 continue; | |
890 | |
891 render_view_hosts.insert(rfh->GetRenderViewHost()); | |
892 } | |
893 | |
894 int number_of_messages = 0; | |
895 for (RenderViewHost* rvh : render_view_hosts) { | |
896 if (!rvh->IsRenderViewLive()) | |
897 continue; | |
898 | |
899 ++number_of_messages; | |
900 IPC::Message* message_copy = new IPC::Message(*message); | |
901 message_copy->set_routing_id(rvh->GetRoutingID()); | |
902 rvh->Send(message_copy); | |
903 } | |
904 delete message; | |
905 return number_of_messages; | |
906 } | |
907 | |
885 void WebContentsImpl::SendPageMessage(IPC::Message* msg) { | 908 void WebContentsImpl::SendPageMessage(IPC::Message* msg) { |
886 frame_tree_.root()->render_manager()->SendPageMessage(msg, nullptr); | 909 frame_tree_.root()->render_manager()->SendPageMessage(msg, nullptr); |
887 } | 910 } |
888 | 911 |
889 RenderViewHostImpl* WebContentsImpl::GetRenderViewHost() const { | 912 RenderViewHostImpl* WebContentsImpl::GetRenderViewHost() const { |
890 return GetRenderManager()->current_host(); | 913 return GetRenderManager()->current_host(); |
891 } | 914 } |
892 | 915 |
893 int WebContentsImpl::GetRoutingID() const { | 916 int WebContentsImpl::GetRoutingID() const { |
894 if (!GetRenderViewHost()) | 917 if (!GetRenderViewHost()) |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1271 audio_muter_.reset(new WebContentsAudioMuter(this)); | 1294 audio_muter_.reset(new WebContentsAudioMuter(this)); |
1272 audio_muter_->StartMuting(); | 1295 audio_muter_->StartMuting(); |
1273 } else { | 1296 } else { |
1274 DCHECK(audio_muter_); | 1297 DCHECK(audio_muter_); |
1275 audio_muter_->StopMuting(); | 1298 audio_muter_->StopMuting(); |
1276 } | 1299 } |
1277 | 1300 |
1278 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1301 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
1279 DidUpdateAudioMutingState(mute)); | 1302 DidUpdateAudioMutingState(mute)); |
1280 | 1303 |
1281 // Notification for UI updates in response to the changed muting state. | 1304 OnAudioStateChanged(!mute && audio_stream_monitor_.IsCurrentlyAudible()); |
1282 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); | |
1283 } | 1305 } |
1284 | 1306 |
1285 bool WebContentsImpl::IsConnectedToBluetoothDevice() const { | 1307 bool WebContentsImpl::IsConnectedToBluetoothDevice() const { |
1286 return bluetooth_connected_device_count_ > 0; | 1308 return bluetooth_connected_device_count_ > 0; |
1287 } | 1309 } |
1288 | 1310 |
1289 bool WebContentsImpl::IsCrashed() const { | 1311 bool WebContentsImpl::IsCrashed() const { |
1290 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED || | 1312 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED || |
1291 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || | 1313 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || |
1292 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED || | 1314 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED || |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1332 media_web_contents_observer_->MaybeUpdateAudibleState(); | 1354 media_web_contents_observer_->MaybeUpdateAudibleState(); |
1333 } | 1355 } |
1334 | 1356 |
1335 if (delegate_) | 1357 if (delegate_) |
1336 delegate_->NavigationStateChanged(this, changed_flags); | 1358 delegate_->NavigationStateChanged(this, changed_flags); |
1337 | 1359 |
1338 if (GetOuterWebContents()) | 1360 if (GetOuterWebContents()) |
1339 GetOuterWebContents()->NotifyNavigationStateChanged(changed_flags); | 1361 GetOuterWebContents()->NotifyNavigationStateChanged(changed_flags); |
1340 } | 1362 } |
1341 | 1363 |
1364 void WebContentsImpl::OnAudioStateChanged(bool is_audio_playing) { | |
1365 SendToAllViews( | |
1366 new ViewMsg_AudioStateChanged(GetRoutingID(), is_audio_playing)); | |
1367 | |
1368 // Notification for UI updates in response to the changed muting state. | |
1369 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); | |
1370 } | |
1371 | |
1342 base::TimeTicks WebContentsImpl::GetLastActiveTime() const { | 1372 base::TimeTicks WebContentsImpl::GetLastActiveTime() const { |
1343 return last_active_time_; | 1373 return last_active_time_; |
1344 } | 1374 } |
1345 | 1375 |
1346 void WebContentsImpl::SetLastActiveTime(base::TimeTicks last_active_time) { | 1376 void WebContentsImpl::SetLastActiveTime(base::TimeTicks last_active_time) { |
1347 last_active_time_ = last_active_time; | 1377 last_active_time_ = last_active_time; |
1348 } | 1378 } |
1349 | 1379 |
1350 void WebContentsImpl::WasShown() { | 1380 void WebContentsImpl::WasShown() { |
1351 controller_.SetActive(true); | 1381 controller_.SetActive(true); |
(...skipping 3915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5267 dialog_manager_ = dialog_manager; | 5297 dialog_manager_ = dialog_manager; |
5268 } | 5298 } |
5269 | 5299 |
5270 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { | 5300 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { |
5271 auto it = binding_sets_.find(interface_name); | 5301 auto it = binding_sets_.find(interface_name); |
5272 if (it != binding_sets_.end()) | 5302 if (it != binding_sets_.end()) |
5273 binding_sets_.erase(it); | 5303 binding_sets_.erase(it); |
5274 } | 5304 } |
5275 | 5305 |
5276 } // namespace content | 5306 } // namespace content |
OLD | NEW |