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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 namespace { | 118 namespace { |
119 | 119 |
120 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; | 120 const int kMinimumDelayBetweenLoadingUpdatesMS = 100; |
121 | 121 |
122 // This matches what Blink's ProgressTracker has traditionally used for a | 122 // This matches what Blink's ProgressTracker has traditionally used for a |
123 // minimum progress value. | 123 // minimum progress value. |
124 const double kMinimumLoadingProgress = 0.1; | 124 const double kMinimumLoadingProgress = 0.1; |
125 | 125 |
126 const char kDotGoogleDotCom[] = ".google.com"; | 126 const char kDotGoogleDotCom[] = ".google.com"; |
127 | 127 |
| 128 // String to indicate that muted state change is initial |
| 129 // (instead of by user, tab capture, or an extension id). |
| 130 const char kMutedToggleCauseInit[] = "initial"; |
| 131 |
128 #if defined(OS_ANDROID) | 132 #if defined(OS_ANDROID) |
129 const char kWebContentsAndroidKey[] = "web_contents_android"; | 133 const char kWebContentsAndroidKey[] = "web_contents_android"; |
130 #endif // OS_ANDROID | 134 #endif // OS_ANDROID |
131 | 135 |
132 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > | 136 base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > |
133 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; | 137 g_created_callbacks = LAZY_INSTANCE_INITIALIZER; |
134 | 138 |
135 static int StartDownload(RenderFrameHost* rfh, | 139 static int StartDownload(RenderFrameHost* rfh, |
136 const GURL& url, | 140 const GURL& url, |
137 bool is_favicon, | 141 bool is_favicon, |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 307 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
304 crashed_error_code_(0), | 308 crashed_error_code_(0), |
305 waiting_for_response_(false), | 309 waiting_for_response_(false), |
306 load_state_(net::LOAD_STATE_IDLE, base::string16()), | 310 load_state_(net::LOAD_STATE_IDLE, base::string16()), |
307 loading_total_progress_(0.0), | 311 loading_total_progress_(0.0), |
308 loading_frames_in_progress_(0), | 312 loading_frames_in_progress_(0), |
309 upload_size_(0), | 313 upload_size_(0), |
310 upload_position_(0), | 314 upload_position_(0), |
311 displayed_insecure_content_(false), | 315 displayed_insecure_content_(false), |
312 has_accessed_initial_document_(false), | 316 has_accessed_initial_document_(false), |
| 317 mutedToggleCause_(kMutedToggleCauseInit), |
313 capturer_count_(0), | 318 capturer_count_(0), |
314 should_normally_be_visible_(true), | 319 should_normally_be_visible_(true), |
315 is_being_destroyed_(false), | 320 is_being_destroyed_(false), |
316 notify_disconnection_(false), | 321 notify_disconnection_(false), |
317 dialog_manager_(NULL), | 322 dialog_manager_(NULL), |
318 is_showing_before_unload_dialog_(false), | 323 is_showing_before_unload_dialog_(false), |
319 last_active_time_(base::TimeTicks::Now()), | 324 last_active_time_(base::TimeTicks::Now()), |
320 closed_by_user_gesture_(false), | 325 closed_by_user_gesture_(false), |
321 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), | 326 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), |
322 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), | 327 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 } | 947 } |
943 | 948 |
944 int WebContentsImpl::GetCapturerCount() const { | 949 int WebContentsImpl::GetCapturerCount() const { |
945 return capturer_count_; | 950 return capturer_count_; |
946 } | 951 } |
947 | 952 |
948 bool WebContentsImpl::IsAudioMuted() const { | 953 bool WebContentsImpl::IsAudioMuted() const { |
949 return audio_muter_.get() && audio_muter_->is_muting(); | 954 return audio_muter_.get() && audio_muter_->is_muting(); |
950 } | 955 } |
951 | 956 |
952 void WebContentsImpl::SetAudioMuted(bool mute) { | 957 void WebContentsImpl::SetAudioMuted(bool muted, const std::string& cause) { |
953 DVLOG(1) << "SetAudioMuted(mute=" << mute << "), was " << IsAudioMuted() | 958 DVLOG(1) << "SetAudioMuted(muted=" << muted << ", cause =" << cause |
954 << " for WebContentsImpl@" << this; | 959 << "), was " << IsAudioMuted() << " for WebContentsImpl@" << this; |
955 | 960 |
956 if (mute == IsAudioMuted()) | 961 if (muted == IsAudioMuted()) |
957 return; | 962 return; |
958 | 963 |
959 if (mute) { | 964 mutedToggleCause_ = cause; |
| 965 |
| 966 if (muted) { |
960 if (!audio_muter_) | 967 if (!audio_muter_) |
961 audio_muter_.reset(new WebContentsAudioMuter(this)); | 968 audio_muter_.reset(new WebContentsAudioMuter(this)); |
962 audio_muter_->StartMuting(); | 969 audio_muter_->StartMuting(); |
963 } else { | 970 } else { |
964 DCHECK(audio_muter_); | 971 DCHECK(audio_muter_); |
965 audio_muter_->StopMuting(); | 972 audio_muter_->StopMuting(); |
966 } | 973 } |
967 | 974 |
968 // Notification for UI updates in response to the changed muting state. | 975 // Notification for UI updates in response to the changed muting state. |
969 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); | 976 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); |
970 } | 977 } |
971 | 978 |
| 979 const std::string& WebContentsImpl::GetAudioMutedCause() const { |
| 980 return mutedToggleCause_; |
| 981 } |
| 982 |
972 bool WebContentsImpl::IsCrashed() const { | 983 bool WebContentsImpl::IsCrashed() const { |
973 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED || | 984 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED || |
974 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || | 985 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || |
975 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED); | 986 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED); |
976 } | 987 } |
977 | 988 |
978 void WebContentsImpl::SetIsCrashed(base::TerminationStatus status, | 989 void WebContentsImpl::SetIsCrashed(base::TerminationStatus status, |
979 int error_code) { | 990 int error_code) { |
980 if (status == crashed_status_) | 991 if (status == crashed_status_) |
981 return; | 992 return; |
(...skipping 3366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4348 node->render_manager()->ResumeResponseDeferredAtStart(); | 4359 node->render_manager()->ResumeResponseDeferredAtStart(); |
4349 } | 4360 } |
4350 | 4361 |
4351 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4362 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4352 force_disable_overscroll_content_ = force_disable; | 4363 force_disable_overscroll_content_ = force_disable; |
4353 if (view_) | 4364 if (view_) |
4354 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4365 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4355 } | 4366 } |
4356 | 4367 |
4357 } // namespace content | 4368 } // namespace content |
OLD | NEW |