Skip to content

Commit

Permalink
Merge branch '25.lts.1+' into minimal-post-processing
Browse files Browse the repository at this point in the history
  • Loading branch information
at-ninja committed Dec 20, 2024
2 parents e9f7cd4 + 974ad46 commit 019a2e8
Show file tree
Hide file tree
Showing 38 changed files with 444 additions and 88 deletions.
6 changes: 6 additions & 0 deletions cobalt/black_box_tests/testdata/h5vcc_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@
]);
assertTrue(reset());
assertFalse(reset());

assertTrue(window.h5vcc.settings.set('QUICConnectionOptions', 'AKDU'));
assertTrue(window.h5vcc.settings.set('QUICClientConnectionOptions', 'TBBR'));
assertTrue(window.h5vcc.settings.set('QUICConnectionOptions', ''));
assertTrue(window.h5vcc.settings.set('QUICClientConnectionOptions', ''));

onEndTest();
</script>
</body>
Expand Down
4 changes: 4 additions & 0 deletions cobalt/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ source_set("browser_switches") {
"switches.cc",
"switches.h",
]
deps = [
"//cobalt/css_parser:switches",
"//cobalt/network:switches",
]
public_deps = [ "//starboard:starboard_headers_only" ]
}

Expand Down
21 changes: 15 additions & 6 deletions cobalt/browser/application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,21 +212,30 @@ GURL GetInitialURL(bool should_preload) {
GURL initial_url = GURL(kDefaultURL);
// Allow the user to override the default URL via a command line parameter.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kInitialURL)) {
std::string url_switch =
command_line->GetSwitchValueASCII(switches::kInitialURL);
bool has_initial_url_switch = command_line->HasSwitch(switches::kInitialURL);

const base::CommandLine::StringVector& args = command_line->GetArgs();
if (has_initial_url_switch || !args.empty()) {
std::string url_string =
has_initial_url_switch
? command_line->GetSwitchValueASCII(switches::kInitialURL)
: args[0];
#if defined(ENABLE_ABOUT_SCHEME)
// Check the switch itself since some non-empty strings parse to empty URLs.
if (url_switch.empty()) {
if (url_string.empty()) {
LOG(ERROR) << "URL from parameter is empty, using " << kAboutBlankURL;
return GURL(kAboutBlankURL);
}
#endif // defined(ENABLE_ABOUT_SCHEME)
GURL url = GURL(url_switch);
GURL url = GURL(url_string);
if (!url.is_valid() && !url.has_scheme()) {
LOG(INFO) << __FUNCTION__ << "URL was not valid: " << url_string;
url = GURL("https://" + url_string);
}
if (url.is_valid()) {
initial_url = url;
} else {
LOG(ERROR) << "URL \"" << url_switch
LOG(ERROR) << "URL \"" << url_string
<< "\" from parameter is not valid, using default URL "
<< initial_url;
}
Expand Down
4 changes: 4 additions & 0 deletions cobalt/browser/browser_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ BrowserModule::BrowserModule(const GURL& url,
base::Unretained(this))));
}

if (command_line->HasSwitch(switches::kDisableProgressivePlayback)) {
can_play_type_handler_->DisableProgressiveSupport();
}

// Set the fallback splash screen url to the default fallback url.
fallback_splash_screen_url_ = options.fallback_splash_screen_url;

Expand Down
6 changes: 2 additions & 4 deletions cobalt/browser/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "cobalt/base/wrap_main.h"
#include "cobalt/browser/application.h"
#include "cobalt/browser/switches.h"
#include "cobalt/css_parser/switches.h"
#include "cobalt/version.h"

namespace {
Expand All @@ -40,16 +39,15 @@ bool CheckForAndExecuteVersionSwitch() {
bool CheckForAndExecuteHelpSwitch() {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
cobalt::browser::switches::kHelp)) {
SbLogRaw("Options: \n");
SbLogRaw("Usage:\n cobalt [options] [url]\n");
SbLogRaw(cobalt::browser::switches::HelpMessage().c_str());
SbLogRaw(cobalt::css_parser::switches::HelpMessage().c_str());
return true;
}
return false;
}

// If startup switches are set, the Cobalt browser application will not be
// initiallized and will exit early.
// initialized and will exit early.
bool CheckForAndExecuteStartupSwitches() {
if (CheckForAndExecuteVersionSwitch()) g_is_startup_switch_set = true;
if (CheckForAndExecuteHelpSwitch()) g_is_startup_switch_set = true;
Expand Down
31 changes: 19 additions & 12 deletions cobalt/browser/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include "cobalt/browser/switches.h"

#include <map>
#include <string>

#include "cobalt/css_parser/switches.h"
#include "cobalt/network/switches.h"

namespace cobalt {
namespace browser {
Expand Down Expand Up @@ -173,15 +177,6 @@ const char kTimedTraceHelp[] =
"for before ending and saving the results to disk. Results will be saved"
" to the file timed_trace.json in the log output directory.";

const char kUserAgent[] = "user_agent";
const char kUserAgentHelp[] =
"Specifies a custom user agent for device simulations. The expected "
"format is \"Mozilla/5.0 ('os_name_and_version') Cobalt/'cobalt_version'."
"'cobalt_build_version_number'-'build_configuration' (unlike Gecko) "
"'javascript_engine_version' 'rasterizer_type' 'starboard_version', "
"'network_operator'_'device_type'_'chipset_model_number'_'model_year'/"
"'firmware_version' ('brand', 'model', 'connection_type') 'aux_field'\".";

const char kUserAgentClientHints[] = "user_agent_client_hints";
const char kUserAgentClientHintsHelp[] =
"Specify custom user agent client hints for device simulations. "
Expand Down Expand Up @@ -333,6 +328,10 @@ const char kOmitDeviceAuthenticationQueryParametersHelp[] =
"When set, no device authentication parameters will be appended to the"
"initial URL.";

const char kDisableProgressivePlayback[] = "disable_progressive_playback";
const char kDisableProgressivePlaybackHelp[] =
"Setting this switch disables support for progressive media playback";

const char kProxy[] = "proxy";
const char kProxyHelp[] =
"Specifies a proxy to use for network connections. "
Expand Down Expand Up @@ -444,8 +443,7 @@ const char kVideoPlaybackRateMultiplierHelp[] =
"than 1.0 to play video faster. Set to a value less than 1.0 to play "
"video slower.";

std::string HelpMessage() {
std::string help_message;
std::map<std::string, const char*> HelpMap() {
std::map<std::string, const char*> help_map{
#if defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES)
{kDebugConsoleMode, kDebugConsoleModeHelp},
Expand Down Expand Up @@ -477,7 +475,6 @@ std::string HelpMessage() {
{kStubImageDecoder, kStubImageDecoderHelp},
{kSuspendFuzzer, kSuspendFuzzerHelp},
{kTimedTrace, kTimedTraceHelp},
{kUserAgent, kUserAgentHelp},
{kUserAgentClientHints, kUserAgentClientHintsHelp},
{kUserAgentOsNameVersion, kUserAgentOsNameVersionHelp},
{kUseTTS, kUseTTSHelp},
Expand Down Expand Up @@ -507,6 +504,7 @@ std::string HelpMessage() {
{kOffscreenTargetCacheSizeInBytes, kOffscreenTargetCacheSizeInBytesHelp},
{kOmitDeviceAuthenticationQueryParameters,
kOmitDeviceAuthenticationQueryParametersHelp},
{kDisableProgressivePlayback, kDisableProgressivePlaybackHelp},
{kProxy, kProxyHelp},
{kQrCodeOverlay, kQrCodeOverlayHelp},
{kRemoteTypefaceCacheSizeInBytes, kRemoteTypefaceCacheSizeInBytesHelp},
Expand All @@ -525,6 +523,14 @@ std::string HelpMessage() {
{kVideoPlaybackRateMultiplier, kVideoPlaybackRateMultiplierHelp},
};

return help_map;
}

std::string HelpMessage() {
std::string help_message;
std::map<std::string, const char*> help_map = HelpMap();
help_map.merge(cobalt::css_parser::switches::HelpMap());
help_map.merge(cobalt::network::switches::HelpMap());
for (const auto& switch_message : help_map) {
help_message.append(" --")
.append(switch_message.first)
Expand All @@ -536,6 +542,7 @@ std::string HelpMessage() {
return help_message;
}


} // namespace switches
} // namespace browser
} // namespace cobalt
4 changes: 3 additions & 1 deletion cobalt/browser/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <map>
#include <string>

#include "starboard/configuration.h"
Expand Down Expand Up @@ -131,6 +132,7 @@ extern const char kOffscreenTargetCacheSizeInBytes[];
extern const char kOffscreenTargetCacheSizeInBytesHelp[];
extern const char kOmitDeviceAuthenticationQueryParameters[];
extern const char kOmitDeviceAuthenticationQueryParametersHelp[];
extern const char kDisableProgressivePlayback[];
extern const char kProxy[];
extern const char kProxyHelp[];
extern const char kQrCodeOverlay[];
Expand Down Expand Up @@ -164,8 +166,8 @@ extern const char kViewportHelp[];
extern const char kVideoPlaybackRateMultiplier[];
extern const char kVideoPlaybackRateMultiplierHelp[];

std::map<std::string, const char*> HelpMap();
std::string HelpMessage();

} // namespace switches
} // namespace browser
} // namespace cobalt
Expand Down
12 changes: 10 additions & 2 deletions cobalt/css_parser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ action("css_grammar") {
]
}

source_set("switches") {
has_pedantic_warnings = true
sources = [
"switches.cc",
"switches.h",
]
public_deps = [ "//starboard:starboard_headers_only" ]
}

static_library("css_parser") {
has_pedantic_warnings = true

Expand Down Expand Up @@ -76,8 +85,6 @@ static_library("css_parser") {
"shadow_property_parse_structures.cc",
"shadow_property_parse_structures.h",
"string_pool.h",
"switches.cc",
"switches.h",
"text_decoration_shorthand_property_parse_structures.cc",
"text_decoration_shorthand_property_parse_structures.h",
"transition_shorthand_property_parse_structures.cc",
Expand All @@ -94,6 +101,7 @@ static_library("css_parser") {

deps = [
":css_grammar",
":switches",
"//base",
"//cobalt/base",
"//cobalt/cssom",
Expand Down
15 changes: 3 additions & 12 deletions cobalt/css_parser/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "cobalt/css_parser/switches.h"

#include <map>
#include <string>

namespace cobalt {
namespace css_parser {
Expand All @@ -29,23 +30,13 @@ const char kOnCssWarning[] = "on_css_warning";
const char kOnCssWarningHelp[] = "If set to \"crash\", crashes on CSS warning.";
#endif // !defined(COBALT_BUILD_TYPE_GOLD)

std::string HelpMessage() {
std::string help_message;
std::map<std::string, const char*> HelpMap() {
std::map<std::string, const char*> help_map {
#if !defined(COBALT_BUILD_TYPE_GOLD)
{kOnCssError, kOnCssErrorHelp}, {kOnCssWarning, kOnCssWarningHelp},
#endif // !defined(COBALT_BUILD_TYPE_GOLD)
};

for (const auto& switch_message : help_map) {
help_message.append(" --")
.append(switch_message.first)
.append("\n")
.append(" ")
.append(switch_message.second)
.append("\n\n");
}
return help_message;
return help_map;
}

} // namespace switches
Expand Down
3 changes: 2 additions & 1 deletion cobalt/css_parser/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef COBALT_CSS_PARSER_SWITCHES_H_
#define COBALT_CSS_PARSER_SWITCHES_H_

#include <map>
#include <string>

namespace cobalt {
Expand All @@ -28,7 +29,7 @@ extern const char kOnCssWarning[];
extern const char kOnCssWarningHelp[];
#endif // !defined(COBALT_BUILD_TYPE_GOLD)

std::string HelpMessage();
std::map<std::string, const char*> HelpMap();

} // namespace switches
} // namespace css_parser
Expand Down
2 changes: 1 addition & 1 deletion cobalt/dom/same_thread_media_source_attachment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool SameThreadMediaSourceAttachment::StartAttachingToMediaElement(
HTMLMediaElement* media_element) {
DCHECK(task_runner_->RunsTasksInCurrentSequence());

if (attached_element_) {
if (!media_source_) {
return false;
}
attached_element_ = base::AsWeakPtr(media_element);
Expand Down
17 changes: 16 additions & 1 deletion cobalt/h5vcc/h5vcc_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ bool H5vccSettings::Set(const std::string& name, SetValueType value) const {
const char kMediaPrefix[] = "Media.";
const char kMediaCodecBlockList[] = "MediaCodecBlockList";
const char kNavigatorUAData[] = "NavigatorUAData";
const char kDeprecatedProtocolFilter[] = "protocolfilter";
const char kQUIC[] = "QUIC";
const char kQUICConectionOptions[] = "QUICConnectionOptions";
const char kQUICClientConectionOptions[] = "QUICClientConnectionOptions";
const char kHTTP2[] = "HTTP2";
const char kHTTP3[] = "HTTP3";
const char kSkiaRasterizer[] = "SkiaRasterizer";
Expand Down Expand Up @@ -111,6 +114,18 @@ bool H5vccSettings::Set(const std::string& name, SetValueType value) const {
}
}

if (name.compare(kQUICConectionOptions) == 0 && value.IsType<std::string>()) {
network_module_->SetQuicConnectionOptions(value.AsType<std::string>());
return true;
}

if (name.compare(kQUICClientConectionOptions) == 0 &&
value.IsType<std::string>()) {
network_module_->SetQuicClientConnectionOptions(
value.AsType<std::string>());
return true;
}

if (name.compare(kHTTP2) == 0 && value.IsType<int32>()) {
if (!persistent_settings_ || !network_module_) {
return false;
Expand All @@ -134,7 +149,7 @@ bool H5vccSettings::Set(const std::string& name, SetValueType value) const {
}

// Disabled due to a bug with previous implementation.
if (name.compare("protocolfilter") == 0) {
if (name.compare(kDeprecatedProtocolFilter) == 0) {
return false;
}
if (name.compare(network::kProtocolFilterKey) == 0 &&
Expand Down
1 change: 1 addition & 0 deletions cobalt/media/can_play_type_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class CanPlayTypeHandler {
virtual void SetDisabledMediaCodecs(const std::string& codecs) = 0;
virtual void SetDisabledMediaEncryptionSchemes(
const std::string& disabled_encryption_schemes) = 0;
virtual void DisableProgressiveSupport() = 0;

protected:
CanPlayTypeHandler() {}
Expand Down
Loading

0 comments on commit 019a2e8

Please sign in to comment.