Commit c458db90 authored by eriksson_monteiro's avatar eriksson_monteiro

enable macos build

parent 6fecb8ec
......@@ -324,7 +324,7 @@ input:focus {
margin-top: 0px;
border: solid 1px lightgray;
border-radius: 4px 0px 0px 4px;
width: 200px;
width: 190px;
padding-left: 10px;
}
......
......@@ -178,7 +178,7 @@ window.addEventListener('message', ({ data }) => {
addressKeyIdentifier = data.wallet.address_key_identifier;
}
window.parent.postMessage({ type: 'millix_session', data }, 'tangled://millix-bar')
}).catch(_ => setTimeout(() => window.postMessage({ type: 'get_session', data }), 1000));
}).catch(_ => setTimeout(() => window.postMessage({ type: 'get_session' }), 1000));
break;
case 'new_session':
API.newSession(data.password)
......
......@@ -158,6 +158,7 @@ void MillixBarUI::ReadNodeConfig() {
base::FilePath file_path;
base::PathService::Get(base::DIR_HOME, &file_path);
file_path = file_path.AppendASCII("millix-tangled").AppendASCII("node.json");
LOG(ERROR) << "reading node config from " << file_path.value().c_str();
this->node_config_file_reader = storage::FileStreamReader::CreateForLocalFile(
base::ThreadPool::CreateTaskRunner(
{base::MayBlock(), base::TaskPriority::USER_VISIBLE}),
......@@ -167,6 +168,7 @@ void MillixBarUI::ReadNodeConfig() {
}
void MillixBarUI::ReadNodeConfigJson(int64_t size = -1) {
LOG(ERROR) << "reading node config. size: " << size;
if (size <= 0) {
// retry later
content::GetIOThreadTaskRunner({})->PostDelayedTask(
......@@ -175,35 +177,56 @@ void MillixBarUI::ReadNodeConfigJson(int64_t size = -1) {
base::TimeDelta::FromMilliseconds(1000));
return;
}
this->node_config_buffer = new net::IOBuffer(size);
this->node_config_file_reader->Read(
this->node_config_buffer, size,
this->node_config_buffer = base::MakeRefCounted<net::IOBufferWithSize>(size);
int rv = this->node_config_file_reader->Read(
this->node_config_buffer.get(), size,
base::BindOnce(&MillixBarUI::OnReadNodeConfigJson,
base::Unretained(this)));
if (rv > 0) {
this->OnReadNodeConfigJson(rv);
}
}
void MillixBarUI::OnReadNodeConfigJson(int result) {
char* data = this->node_config_buffer->data();
LOG(ERROR) << "reading node config. json (" << result << ") " << base::StringPiece(data);
#if defined(OS_WIN)
base::Optional<base::Value> node_config_json =
base::JSONReader::Read(base::StringPiece(data).substr(0, result));
#else
base::Optional<base::Value> node_config_json =
base::JSONReader::Read(base::StringPiece(data));
#endif
if (node_config_json.has_value()) {
std::string* node_id = node_config_json->FindStringKey("node_id");
std::string* node_signature =
node_config_json->FindStringKey("node_signature");
if (!node_id || !node_signature) {
if (!node_id || !node_signature || node_id->empty() || node_signature->empty()) {
LOG(ERROR) << "reading node config. invalid configs! ";
this->ReadNodeConfigJson();
return;
}
LOG(ERROR) << "reading node config. id " << *node_id <<" signature " << *node_signature;
this->message_handler->node_id = *node_id;
this->message_handler->node_signature = *node_signature;
content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce(&MillixBarUI::OnUpdateNodeApiConfig,
base::Unretained(this)));
} else {
LOG(ERROR) << "reading node config. invalid json";
// retry later
content::GetIOThreadTaskRunner({})->PostDelayedTask(
FROM_HERE,
base::BindOnce(&MillixBarUI::ReadNodeConfig, base::Unretained(this)),
base::TimeDelta::FromMilliseconds(1000));
}
this->node_config_buffer = nullptr;
}
void MillixBarUI::OnUpdateNodeApiConfig() {
LOG(ERROR) << "sending node config. id " << this->message_handler->node_id <<" signature " << this->message_handler->node_signature;
base::DictionaryValue apiConfig;
apiConfig.SetStringKey("node_id", this->message_handler->node_id);
apiConfig.SetStringKey("node_signature",
......
......@@ -41,7 +41,7 @@ class MillixBarUI : public ui::MojoWebUIController {
void OnReadNodeConfigJson(int result);
void OnUpdateNodeApiConfig();
std::unique_ptr<storage::FileStreamReader> node_config_file_reader;
net::IOBuffer* node_config_buffer;
scoped_refptr<net::IOBufferWithSize> node_config_buffer;
MillixBarMessageHandler* message_handler;
DISALLOW_COPY_AND_ASSIGN(MillixBarUI);
};
......
......@@ -53,7 +53,7 @@ UntrustedMillixAppUI::UntrustedMillixAppUI(content::WebUI* web_ui)
network::mojom::CSPDirectiveName::ConnectSrc, "connect-src https:;");
untrusted_source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::DefaultSrc, "script-src 'self' 'unsafe-inline';");
network::mojom::CSPDirectiveName::DefaultSrc, "default-src 'self' 'unsafe-inline';");
untrusted_source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ScriptSrc, "script-src tangled://resources 'self' 'unsafe-inline';");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment