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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1848663002: bluetooth: Remove indicator only when there are no more devices connected (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Ref count connections Created 4 years, 8 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
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 "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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 render_frame_message_source_(NULL), 351 render_frame_message_source_(NULL),
352 fullscreen_widget_routing_id_(MSG_ROUTING_NONE), 352 fullscreen_widget_routing_id_(MSG_ROUTING_NONE),
353 fullscreen_widget_had_focus_at_shutdown_(false), 353 fullscreen_widget_had_focus_at_shutdown_(false),
354 is_subframe_(false), 354 is_subframe_(false),
355 force_disable_overscroll_content_(false), 355 force_disable_overscroll_content_(false),
356 last_dialog_suppressed_(false), 356 last_dialog_suppressed_(false),
357 geolocation_service_context_(new GeolocationServiceContext()), 357 geolocation_service_context_(new GeolocationServiceContext()),
358 accessibility_mode_( 358 accessibility_mode_(
359 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()), 359 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()),
360 audio_stream_monitor_(this), 360 audio_stream_monitor_(this),
361 bluetooth_device_connected_(false), 361 bluetooth_connected_devices_(0),
362 virtual_keyboard_requested_(false), 362 virtual_keyboard_requested_(false),
363 page_scale_factor_is_one_(true), 363 page_scale_factor_is_one_(true),
364 loading_weak_factory_(this), 364 loading_weak_factory_(this),
365 weak_factory_(this) { 365 weak_factory_(this) {
366 frame_tree_.SetFrameRemoveListener( 366 frame_tree_.SetFrameRemoveListener(
367 base::Bind(&WebContentsImpl::OnFrameRemoved, 367 base::Bind(&WebContentsImpl::OnFrameRemoved,
368 base::Unretained(this))); 368 base::Unretained(this)));
369 #if defined(OS_ANDROID) 369 #if defined(OS_ANDROID)
370 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this)); 370 media_web_contents_observer_.reset(new MediaWebContentsObserverAndroid(this));
371 #else 371 #else
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 audio_muter_->StopMuting(); 1118 audio_muter_->StopMuting();
1119 } 1119 }
1120 1120
1121 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1121 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1122 DidUpdateAudioMutingState(mute)); 1122 DidUpdateAudioMutingState(mute));
1123 1123
1124 // Notification for UI updates in response to the changed muting state. 1124 // Notification for UI updates in response to the changed muting state.
1125 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); 1125 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
1126 } 1126 }
1127 1127
1128 bool WebContentsImpl::IsBluetoothDeviceConnected() const { 1128 void WebContentsImpl::IncrementBluetoothConnectedDeviceCount() {
1129 return bluetooth_device_connected_; 1129 // Notification for UI updates if the state changes.
1130 if (bluetooth_connected_device_count_++ == 0) {
Jeffrey Yasskin 2016/03/31 18:00:25 I hate post-increment, because I have to think too
ortuno 2016/04/04 21:20:56 Done.
1131 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
1132 }
1130 } 1133 }
1131 1134
1132 void WebContentsImpl::SetBluetoothDeviceConnected(bool connected) { 1135 void WebContentsImpl::DecrementBluetoothConnectedDeviceCount() {
1133 bluetooth_device_connected_ = connected; 1136 // Notification for UI updates if the state changes.
1134 // Notification for UI updates in response to the connected device. 1137 if (bluetooth_connected_device_count_-- == 1) {
1135 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); 1138 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
1139 }
1140 }
1141
1142 bool WebContentsImpl::IsConnectedToBluetoothDevice() const {
1143 return bluetooth_connected_devices_ > 0;
1136 } 1144 }
1137 1145
1138 bool WebContentsImpl::IsCrashed() const { 1146 bool WebContentsImpl::IsCrashed() const {
1139 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED || 1147 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED ||
1140 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || 1148 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||
1141 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED || 1149 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ||
1142 #if defined(OS_CHROMEOS) 1150 #if defined(OS_CHROMEOS)
1143 crashed_status_ == 1151 crashed_status_ ==
1144 base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM || 1152 base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM ||
1145 #endif 1153 #endif
(...skipping 3690 matching lines...) Expand 10 before | Expand all | Expand 10 after
4836 else 4844 else
4837 WasHidden(); 4845 WasHidden();
4838 } 4846 }
4839 4847
4840 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( 4848 void WebContentsImpl::SetJavaScriptDialogManagerForTesting(
4841 JavaScriptDialogManager* dialog_manager) { 4849 JavaScriptDialogManager* dialog_manager) {
4842 dialog_manager_ = dialog_manager; 4850 dialog_manager_ = dialog_manager;
4843 } 4851 }
4844 4852
4845 } // namespace content 4853 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698