Skip to content

Commit 1b25b61

Browse files
author
Reis Can
committed
feat: save spoofed user agent
1 parent a039118 commit 1b25b61

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

cobalt/h5vcc/h5vcc.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ H5vcc::H5vcc(const Settings& settings) {
3737
settings.user_agent_data, settings.global_environment,
3838
settings.persistent_settings);
3939

40-
tizentube_ = new H5vccTizenTube(settings.network_module);
40+
tizentube_ =
41+
new H5vccTizenTube(settings.network_module, settings.persistent_settings);
4142
storage_ =
4243
new H5vccStorage(settings.network_module, settings.persistent_settings);
4344
trace_event_ = new H5vccTraceEvent();

cobalt/h5vcc/h5vcc_tizen_tube.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ using starboard::android::shared::ScopedLocalJavaRef;
3333
#endif
3434

3535

36-
H5vccTizenTube::H5vccTizenTube(cobalt::network::NetworkModule* network_module)
37-
: network_module_{network_module} {}
36+
H5vccTizenTube::H5vccTizenTube(
37+
cobalt::network::NetworkModule* network_module,
38+
cobalt::persistent_storage::PersistentSettings* persistent_settings)
39+
: network_module_{network_module},
40+
persistent_settings_{persistent_settings} {}
3841

3942
bool H5vccTizenTube::InstallAppFromURL(const std::string& url) const {
4043
#if defined(ANDROID)
@@ -62,6 +65,7 @@ std::string H5vccTizenTube::GetVersion() const {
6265
}
6366

6467
bool H5vccTizenTube::SetUserAgent(const std::string& user_agent) const {
68+
persistent_settings_->Set("userAgent", base::Value(user_agent));
6569
network_module_->task_runner()->PostTask(
6670
FROM_HERE, base::Bind(
6771
[](cobalt::network::NetworkModule* network_module,

cobalt/h5vcc/h5vcc_tizen_tube.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ namespace h5vcc {
3737
// This class is used for internal methods for TizenTube Cobalt.
3838
class H5vccTizenTube : public script::Wrappable {
3939
public:
40-
explicit H5vccTizenTube(cobalt::network::NetworkModule* network_module);
40+
explicit H5vccTizenTube(
41+
cobalt::network::NetworkModule* network_module,
42+
cobalt::persistent_storage::PersistentSettings* persistent_settings);
4143

4244
H5vccTizenTube();
4345

@@ -51,6 +53,8 @@ class H5vccTizenTube : public script::Wrappable {
5153

5254
private:
5355
cobalt::network::NetworkModule* network_module_ = nullptr;
56+
cobalt::persistent_storage::PersistentSettings* persistent_settings_ =
57+
nullptr;
5458
DISALLOW_COPY_AND_ASSIGN(H5vccTizenTube);
5559
};
5660

cobalt/network/network_module.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,16 @@ void NetworkModule::Initialize(const std::string& user_agent_string,
350350

351351
#endif // ENABLE_DEBUG_COMMAND_LINE_SWITCHES
352352

353+
354+
base::Value ua_string_value;
355+
356+
options_.persistent_settings->Get("userAgent", &ua_string_value);
357+
std::string* ua_string = ua_string_value.GetIfString();
358+
if (ua_string && !ua_string->empty()) {
359+
http_user_agent_settings.reset(new net::StaticHttpUserAgentSettings(
360+
options_.preferred_language, *ua_string));
361+
}
362+
353363
// Launch the IO thread.
354364
base::Thread::Options thread_options;
355365
thread_options.message_pump_type = base::MessagePumpType::IO;

starboard/android/apk/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ android {
8080
minSdkVersion MIN_SUPPORTED_SDK_VERSION
8181
targetSdkVersion LATEST_SUPPORTED_SDK_VERSION
8282
compileSdkVersion LATEST_SUPPORTED_SDK_VERSION
83-
versionCode 105
83+
versionCode 106
8484
versionName "${buildId}"
8585
manifestPlaceholders = [
8686
applicationName: "TizenTube",

0 commit comments

Comments
 (0)