review fixes
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "brave/browser/ipfs/ipfs_host_resolver.h"
|
||||
#include "brave/browser/ipfs/ipfs_service_factory.h"
|
||||
#include "brave/common/webui_url_constants.h"
|
||||
#include "brave/components/ipfs/imported_data.h"
|
||||
#include "brave/components/ipfs/ipfs_constants.h"
|
||||
#include "brave/components/ipfs/ipfs_service.h"
|
||||
@@ -163,7 +164,8 @@ base::string16 GetImportNotificationBody(ipfs::ImportState state,
|
||||
std::unique_ptr<message_center::Notification> CreateMessageCenterNotification(
|
||||
const base::string16& title,
|
||||
const base::string16& body,
|
||||
const std::string& uuid) {
|
||||
const std::string& uuid,
|
||||
const GURL& link) {
|
||||
message_center::RichNotificationData notification_data;
|
||||
|
||||
// hack to prevent origin from showing in the notification
|
||||
@@ -171,7 +173,7 @@ std::unique_ptr<message_center::Notification> CreateMessageCenterNotification(
|
||||
notification_data.context_message = base::ASCIIToUTF16(" ");
|
||||
auto notification = std::make_unique<message_center::Notification>(
|
||||
message_center::NOTIFICATION_TYPE_SIMPLE, uuid, title, body, gfx::Image(),
|
||||
base::string16(), GURL(),
|
||||
base::string16(), link,
|
||||
message_center::NotifierId(message_center::NotifierType::SYSTEM_COMPONENT,
|
||||
kNotifierId),
|
||||
notification_data, nullptr);
|
||||
@@ -381,9 +383,13 @@ GURL IPFSTabHelper::CreateAndCopyShareableLink(const ipfs::ImportedData& data) {
|
||||
}
|
||||
|
||||
void IPFSTabHelper::OnImportCompleted(const ipfs::ImportedData& data) {
|
||||
PushNotification(
|
||||
GetImportNotificationTitle(data.state),
|
||||
GetImportNotificationBody(data.state, CreateAndCopyShareableLink(data)));
|
||||
auto link = CreateAndCopyShareableLink(data);
|
||||
if (!link.is_valid()) {
|
||||
// Open node diagnostic page if import failed
|
||||
link = GURL(kIPFSWebUIURL);
|
||||
}
|
||||
PushNotification(GetImportNotificationTitle(data.state),
|
||||
GetImportNotificationBody(data.state, link), link);
|
||||
if (data.state == ipfs::IPFS_IMPORT_SUCCESS) {
|
||||
GURL url = ResolveWebUIFilesLocation(data.directory, chrome::GetChannel());
|
||||
content::OpenURLParams params(url, content::Referrer(),
|
||||
@@ -394,13 +400,14 @@ void IPFSTabHelper::OnImportCompleted(const ipfs::ImportedData& data) {
|
||||
}
|
||||
|
||||
void IPFSTabHelper::PushNotification(const base::string16& title,
|
||||
const base::string16& body) {
|
||||
const base::string16& body,
|
||||
const GURL& link) {
|
||||
auto notification =
|
||||
CreateMessageCenterNotification(title, body, base::GenerateGUID());
|
||||
CreateMessageCenterNotification(title, body, base::GenerateGUID(), link);
|
||||
Profile* profile =
|
||||
Profile::FromBrowserContext(web_contents()->GetBrowserContext());
|
||||
auto* display_service = NotificationDisplayService::GetForProfile(profile);
|
||||
display_service->Display(NotificationHandler::Type::ANNOUNCEMENT,
|
||||
display_service->Display(NotificationHandler::Type::SEND_TAB_TO_SELF,
|
||||
*notification, /*metadata=*/nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,8 @@ class IPFSTabHelper : public content::WebContentsObserver,
|
||||
explicit IPFSTabHelper(content::WebContents* web_contents);
|
||||
|
||||
void PushNotification(const base::string16& title,
|
||||
const base::string16& body);
|
||||
const base::string16& body,
|
||||
const GURL& link);
|
||||
GURL CreateAndCopyShareableLink(const ipfs::ImportedData& data);
|
||||
bool IsDNSLinkCheckEnabled() const;
|
||||
void IPFSLinkResolved(const GURL& ipfs);
|
||||
|
||||
@@ -38,12 +38,6 @@
|
||||
|
||||
namespace {
|
||||
|
||||
#if BUILDFLAG(IPFS_ENABLED)
|
||||
bool IsIpfsMenuEnabled(content::BrowserContext* browser_context) {
|
||||
return ipfs::IsIpfsEnabled(browser_context) &&
|
||||
ipfs::IsLocalGatewayConfigured(browser_context);
|
||||
}
|
||||
#endif
|
||||
GURL GetSelectionNavigationURL(Profile* profile, const base::string16& text) {
|
||||
AutocompleteMatch match;
|
||||
AutocompleteClassifier classifier(
|
||||
@@ -198,8 +192,9 @@ void BraveRenderViewContextMenu::AddSpellCheckServiceItem(
|
||||
// Suppress adding "Spellcheck->Ask Brave for suggestions" item.
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IPFS_ENABLED)
|
||||
bool BraveRenderViewContextMenu::IsIPFSCommandIdEnabled(int command) const {
|
||||
if (!IsIpfsMenuEnabled(browser_context_))
|
||||
if (!ipfs::IsIpfsMenuEnabled(browser_context_))
|
||||
return false;
|
||||
switch (command) {
|
||||
case IDC_CONTENT_CONTEXT_IMPORT_IPFS:
|
||||
@@ -225,7 +220,6 @@ bool BraveRenderViewContextMenu::IsIPFSCommandIdEnabled(int command) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IPFS_ENABLED)
|
||||
void BraveRenderViewContextMenu::SeIpfsIconAt(int index) {
|
||||
auto& bundle = ui::ResourceBundle::GetSharedInstance();
|
||||
const auto& ipfs_logo = *bundle.GetImageSkiaNamed(IDR_BRAVE_IPFS_LOGO);
|
||||
@@ -234,7 +228,7 @@ void BraveRenderViewContextMenu::SeIpfsIconAt(int index) {
|
||||
}
|
||||
|
||||
void BraveRenderViewContextMenu::BuildIPFSMenu() {
|
||||
if (!IsIpfsMenuEnabled(browser_context_))
|
||||
if (!ipfs::IsIpfsMenuEnabled(browser_context_))
|
||||
return;
|
||||
int index =
|
||||
menu_model_.GetIndexOfCommandId(IDC_CONTENT_CONTEXT_INSPECTELEMENT);
|
||||
|
||||
@@ -53,6 +53,9 @@ class IpfsImportWorkerBase {
|
||||
ImportCompletedCallback callback);
|
||||
virtual ~IpfsImportWorkerBase();
|
||||
|
||||
IpfsImportWorkerBase(const IpfsImportWorkerBase&) = delete;
|
||||
IpfsImportWorkerBase& operator=(const IpfsImportWorkerBase&) = delete;
|
||||
|
||||
using BlobBuilderCallback =
|
||||
base::OnceCallback<std::unique_ptr<storage::BlobDataBuilder>()>;
|
||||
|
||||
@@ -92,8 +95,6 @@ class IpfsImportWorkerBase {
|
||||
content::BrowserContext* browser_context_ = nullptr;
|
||||
scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
|
||||
base::WeakPtrFactory<IpfsImportWorkerBase> weak_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(IpfsImportWorkerBase);
|
||||
};
|
||||
|
||||
} // namespace ipfs
|
||||
|
||||
@@ -155,4 +155,5 @@ void IpfsLinkImportWorker::CreateRequestWithFile(
|
||||
|
||||
StartImport(std::move(blob_builder_callback), content_type, filename);
|
||||
}
|
||||
|
||||
} // namespace ipfs
|
||||
|
||||
@@ -12,13 +12,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/containers/queue.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "brave/components/ipfs/imported_data.h"
|
||||
#include "brave/components/ipfs/ipfs_import_worker_base.h"
|
||||
#include "components/version_info/channel.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace ipfs {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "brave/components/ipfs/ipfs_text_import_worker.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "base/command_line.h"
|
||||
|
||||
@@ -6,25 +6,15 @@
|
||||
#ifndef BRAVE_COMPONENTS_IPFS_IPFS_TEXT_IMPORT_WORKER_H_
|
||||
#define BRAVE_COMPONENTS_IPFS_IPFS_TEXT_IMPORT_WORKER_H_
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/containers/queue.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "brave/components/ipfs/imported_data.h"
|
||||
#include "brave/components/ipfs/ipfs_import_worker_base.h"
|
||||
#include "components/version_info/channel.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace ipfs {
|
||||
|
||||
// Implements preparation steps for importing text objects into ipfs.
|
||||
// Wraps text data to a request objec and puts it to the base class
|
||||
// Wraps text data to a request object and puts it to the base class
|
||||
// for the upload using IPFS api
|
||||
class IpfsTextImportWorker : public IpfsImportWorkerBase {
|
||||
public:
|
||||
|
||||
@@ -283,4 +283,9 @@ GURL ResolveWebUIFilesLocation(const std::string& directory,
|
||||
return url.ReplaceComponents(replacements);
|
||||
}
|
||||
|
||||
bool IsIpfsMenuEnabled(content::BrowserContext* browser_context) {
|
||||
return ipfs::IsIpfsEnabled(browser_context) &&
|
||||
ipfs::IsLocalGatewayConfigured(browser_context);
|
||||
}
|
||||
|
||||
} // namespace ipfs
|
||||
|
||||
@@ -51,6 +51,7 @@ bool TranslateIPFSURI(const GURL& url,
|
||||
GURL* new_url,
|
||||
const GURL& gateway_url,
|
||||
bool use_subdomain);
|
||||
bool IsIpfsMenuEnabled(content::BrowserContext* browser_context);
|
||||
|
||||
} // namespace ipfs
|
||||
|
||||
|
||||
@@ -544,3 +544,11 @@ TEST_F(IpfsUtilsUnitTest, ResolveWebUIFilesLocation) {
|
||||
EXPECT_EQ(url.path(), "/webui/");
|
||||
EXPECT_EQ(url.ref(), "/files/test_directory");
|
||||
}
|
||||
|
||||
TEST_F(IpfsUtilsUnitTest, IsIpfsMenuEnabled) {
|
||||
ASSERT_FALSE(ipfs::IsLocalGatewayConfigured(context()));
|
||||
ASSERT_FALSE(ipfs::IsIpfsMenuEnabled(context()));
|
||||
SetIPFSResolveMethodPref(ipfs::IPFSResolveMethodTypes::IPFS_LOCAL);
|
||||
ASSERT_TRUE(ipfs::IsLocalGatewayConfigured(context()));
|
||||
ASSERT_TRUE(ipfs::IsIpfsMenuEnabled(context()));
|
||||
}
|
||||
|
||||
+43
-107
@@ -176,12 +176,6 @@ dependencies = [
|
||||
"tiny-keccak",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "convert_case"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.7.0"
|
||||
@@ -219,7 +213,7 @@ version = "0.25.9"
|
||||
source = "git+https://github.com/AndriusA/rust-cssparser?branch=glibc#ad2f4d3c89e247ec1693a581ecace199e46f30fa"
|
||||
dependencies = [
|
||||
"autocfg 0.1.7",
|
||||
"cssparser-macros 0.3.6",
|
||||
"cssparser-macros",
|
||||
"dtoa-short",
|
||||
"itoa",
|
||||
"libm",
|
||||
@@ -228,24 +222,7 @@ dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"procedural-masquerade",
|
||||
"quote 1.0.7",
|
||||
"smallvec 0.6.14",
|
||||
"syn 1.0.60",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cssparser"
|
||||
version = "0.27.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "754b69d351cdc2d8ee09ae203db831e005560fc6030da058f86ad60c92a9cb0a"
|
||||
dependencies = [
|
||||
"cssparser-macros 0.6.0",
|
||||
"dtoa-short",
|
||||
"itoa",
|
||||
"matches",
|
||||
"phf 0.8.0",
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.7",
|
||||
"smallvec 1.6.1",
|
||||
"smallvec",
|
||||
"syn 1.0.60",
|
||||
]
|
||||
|
||||
@@ -261,28 +238,6 @@ dependencies = [
|
||||
"syn 1.0.60",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cssparser-macros"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfae75de57f2b2e85e8768c3ea840fd159c8f33e2b6522c7835b7abac81be16e"
|
||||
dependencies = [
|
||||
"quote 1.0.7",
|
||||
"syn 1.0.60",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_more"
|
||||
version = "0.99.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f82b1b72f1263f214c0f823371768776c4f5841b942c9883aa8e5ec584fd0ba6"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.7",
|
||||
"syn 1.0.60",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dtoa"
|
||||
version = "0.4.6"
|
||||
@@ -465,17 +420,6 @@ version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
|
||||
|
||||
[[package]]
|
||||
name = "kuchiki"
|
||||
version = "0.8.1"
|
||||
source = "git+https://github.com/brave/kuchiki?branch=speedreader#589eadca2c1d06ddda2919354590bfe1ace88a43"
|
||||
dependencies = [
|
||||
"cssparser 0.27.2",
|
||||
"html5ever",
|
||||
"matches",
|
||||
"selectors 0.22.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
@@ -523,13 +467,13 @@ checksum = "169299b3b58aa5cd8ad25fd8fe984e93748046d24c80f05aaadd9022f95423ec"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if 0.1.10",
|
||||
"cssparser 0.25.9",
|
||||
"cssparser",
|
||||
"encoding_rs",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"memchr",
|
||||
"safemem",
|
||||
"selectors 0.21.0",
|
||||
"selectors",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
@@ -556,6 +500,18 @@ dependencies = [
|
||||
"tendril",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "markup5ever_rcdom"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f015da43bcd8d4f144559a3423f4591d69b8ce0652c905374da7205df336ae2b"
|
||||
dependencies = [
|
||||
"html5ever",
|
||||
"markup5ever",
|
||||
"tendril",
|
||||
"xml5ever",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.8"
|
||||
@@ -704,9 +660,7 @@ version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12"
|
||||
dependencies = [
|
||||
"phf_macros",
|
||||
"phf_shared 0.8.0",
|
||||
"proc-macro-hack",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -749,20 +703,6 @@ dependencies = [
|
||||
"rand 0.7.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_macros"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f6fde18ff429ffc8fe78e2bf7f8b7a5a5a6e2a8b58bc5a9ac69198bbda9189c"
|
||||
dependencies = [
|
||||
"phf_generator 0.8.0",
|
||||
"phf_shared 0.8.0",
|
||||
"proc-macro-hack",
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.7",
|
||||
"syn 1.0.60",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_shared"
|
||||
version = "0.7.24"
|
||||
@@ -1053,8 +993,8 @@ name = "readability"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"html5ever",
|
||||
"kuchiki",
|
||||
"lazy_static",
|
||||
"markup5ever_rcdom",
|
||||
"regex",
|
||||
"url 1.7.2",
|
||||
]
|
||||
@@ -1207,7 +1147,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b86b100bede4f651059740afc3b6cb83458d7401cb7c1ad96d8a11e91742c86"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cssparser 0.25.9",
|
||||
"cssparser",
|
||||
"fxhash",
|
||||
"log",
|
||||
"matches",
|
||||
@@ -1215,27 +1155,7 @@ dependencies = [
|
||||
"phf_codegen 0.7.24",
|
||||
"precomputed-hash",
|
||||
"servo_arc",
|
||||
"smallvec 0.6.14",
|
||||
"thin-slice",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "selectors"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df320f1889ac4ba6bc0cdc9c9af7af4bd64bb927bccdf32d81140dc1f9be12fe"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cssparser 0.27.2",
|
||||
"derive_more",
|
||||
"fxhash",
|
||||
"log",
|
||||
"matches",
|
||||
"phf 0.8.0",
|
||||
"phf_codegen 0.8.0",
|
||||
"precomputed-hash",
|
||||
"servo_arc",
|
||||
"smallvec 1.6.1",
|
||||
"smallvec",
|
||||
"thin-slice",
|
||||
]
|
||||
|
||||
@@ -1322,12 +1242,6 @@ dependencies = [
|
||||
"maybe-uninit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
|
||||
|
||||
[[package]]
|
||||
name = "speedreader"
|
||||
version = "0.1.0"
|
||||
@@ -1335,11 +1249,11 @@ dependencies = [
|
||||
"adblock",
|
||||
"flate2",
|
||||
"html5ever",
|
||||
"kuchiki",
|
||||
"lazy_static",
|
||||
"lifeguard",
|
||||
"lol_html",
|
||||
"markup5ever",
|
||||
"markup5ever_rcdom",
|
||||
"readability",
|
||||
"regex",
|
||||
"serde",
|
||||
@@ -1469,6 +1383,16 @@ dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tiny-keccak"
|
||||
version = "2.0.2"
|
||||
@@ -1509,7 +1433,7 @@ version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426"
|
||||
dependencies = [
|
||||
"smallvec 0.6.14",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1597,3 +1521,15 @@ name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "xml5ever"
|
||||
version = "0.16.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b1b52e6e8614d4a58b8e70cf51ec0cc21b256ad8206708bcff8139b5bbd6a59"
|
||||
dependencies = [
|
||||
"log",
|
||||
"mac",
|
||||
"markup5ever",
|
||||
"time",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user