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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp

Issue 2850553002: Autoplay: use an autoplay policy setting in Blink. (Closed)
Patch Set: Created 3 years, 7 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 /* 1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 20 matching lines...) Expand all
31 #include "bindings/core/v8/ScriptPromiseResolver.h" 31 #include "bindings/core/v8/ScriptPromiseResolver.h"
32 #include "bindings/core/v8/ScriptState.h" 32 #include "bindings/core/v8/ScriptState.h"
33 #include "bindings/modules/v8/DecodeErrorCallback.h" 33 #include "bindings/modules/v8/DecodeErrorCallback.h"
34 #include "bindings/modules/v8/DecodeSuccessCallback.h" 34 #include "bindings/modules/v8/DecodeSuccessCallback.h"
35 #include "core/dom/DOMException.h" 35 #include "core/dom/DOMException.h"
36 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
37 #include "core/dom/ExceptionCode.h" 37 #include "core/dom/ExceptionCode.h"
38 #include "core/dom/TaskRunnerHelper.h" 38 #include "core/dom/TaskRunnerHelper.h"
39 #include "core/frame/Settings.h" 39 #include "core/frame/Settings.h"
40 #include "core/html/HTMLMediaElement.h" 40 #include "core/html/HTMLMediaElement.h"
41 #include "core/html/media/AutoplayPolicy.h"
41 #include "core/inspector/ConsoleMessage.h" 42 #include "core/inspector/ConsoleMessage.h"
42 #include "core/inspector/ConsoleTypes.h" 43 #include "core/inspector/ConsoleTypes.h"
43 #include "modules/mediastream/MediaStream.h" 44 #include "modules/mediastream/MediaStream.h"
44 #include "modules/webaudio/AnalyserNode.h" 45 #include "modules/webaudio/AnalyserNode.h"
45 #include "modules/webaudio/AudioBuffer.h" 46 #include "modules/webaudio/AudioBuffer.h"
46 #include "modules/webaudio/AudioBufferSourceNode.h" 47 #include "modules/webaudio/AudioBufferSourceNode.h"
47 #include "modules/webaudio/AudioContext.h" 48 #include "modules/webaudio/AudioContext.h"
48 #include "modules/webaudio/AudioListener.h" 49 #include "modules/webaudio/AudioListener.h"
49 #include "modules/webaudio/AudioNodeInput.h" 50 #include "modules/webaudio/AudioNodeInput.h"
50 #include "modules/webaudio/AudioNodeOutput.h" 51 #include "modules/webaudio/AudioNodeOutput.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 user_gesture_required_(false), 99 user_gesture_required_(false),
99 connection_count_(0), 100 connection_count_(0),
100 deferred_task_handler_(DeferredTaskHandler::Create()), 101 deferred_task_handler_(DeferredTaskHandler::Create()),
101 context_state_(kSuspended), 102 context_state_(kSuspended),
102 closed_context_sample_rate_(-1), 103 closed_context_sample_rate_(-1),
103 periodic_wave_sine_(nullptr), 104 periodic_wave_sine_(nullptr),
104 periodic_wave_square_(nullptr), 105 periodic_wave_square_(nullptr),
105 periodic_wave_sawtooth_(nullptr), 106 periodic_wave_sawtooth_(nullptr),
106 periodic_wave_triangle_(nullptr), 107 periodic_wave_triangle_(nullptr),
107 output_position_() { 108 output_position_() {
108 // If mediaPlaybackRequiresUserGesture is enabled, cross origin iframes will 109 // If the autoplay policy requires a user gesture, cross origin iframes will
109 // require user gesture for the AudioContext to produce sound. 110 // require user gesture for the AudioContext to produce sound. This apply even
110 if (document->GetSettings() && 111 // if the autoplay policy requires user gesture for top frames.
111 document->GetSettings()->GetMediaPlaybackRequiresUserGesture() && 112 if (AutoplayPolicy::GetAutoplayPolicyForDocument(*document) !=
113 AutoplayPolicy::Type::kNoUserGestureRequired &&
112 document->GetFrame() && document->GetFrame()->IsCrossOriginSubframe()) { 114 document->GetFrame() && document->GetFrame()->IsCrossOriginSubframe()) {
113 autoplay_status_ = AutoplayStatus::kAutoplayStatusFailed; 115 autoplay_status_ = AutoplayStatus::kAutoplayStatusFailed;
114 user_gesture_required_ = true; 116 user_gesture_required_ = true;
115 } 117 }
116 } 118 }
117 119
118 // Constructor for offline (non-realtime) rendering. 120 // Constructor for offline (non-realtime) rendering.
119 BaseAudioContext::BaseAudioContext(Document* document, 121 BaseAudioContext::BaseAudioContext(Document* document,
120 unsigned number_of_channels, 122 unsigned number_of_channels,
121 size_t number_of_frames, 123 size_t number_of_frames,
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 } 939 }
938 940
939 SecurityOrigin* BaseAudioContext::GetSecurityOrigin() const { 941 SecurityOrigin* BaseAudioContext::GetSecurityOrigin() const {
940 if (GetExecutionContext()) 942 if (GetExecutionContext())
941 return GetExecutionContext()->GetSecurityOrigin(); 943 return GetExecutionContext()->GetSecurityOrigin();
942 944
943 return nullptr; 945 return nullptr;
944 } 946 }
945 947
946 } // namespace blink 948 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698