Revert "Show "Initializing Tor..." on omnibox and disable it until Tor process"
This reverts commit fdf34239cbcdba737305a99ea59d9c0dde97a653. Revert "Add test case WaitForTorProcess to BraveOmniboxViewViewsTest" This reverts commit f3e67266a58ab2f733fbe480986d34a776dc666a. Revert "Fixed WaitForTorProcess failed on linux" This reverts commit 5927c8452be67f1eebebe1bc980ca3a0294ee199.
This commit is contained in:
@@ -317,9 +317,6 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
|
||||
<message name="IDS_PROFILES_OPEN_TOR_PROFILE_BUTTON" desc="Button in the avatar menu bubble view to open a Tor window.">
|
||||
Open Tor Window
|
||||
</message>
|
||||
<message name="IDS_OMNIBOX_INITIALIZING_TOR" desc="Omnibox indicator to show Tor executable is downloading or launching">
|
||||
Initializing Tor...
|
||||
</message>
|
||||
<if expr="use_titlecase">
|
||||
<message name="IDS_NEW_OFFTHERECORD_WINDOW_TOR" desc="Title case: The text label of a menu item to open a new off-the-record window with Tor.">
|
||||
New Private Window with Tor
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
# Copyright (c) 2020 The Brave Authors. All rights reserved.
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import("//ui/base/ui_features.gni")
|
||||
|
||||
brave_browser_ui_sources = []
|
||||
brave_browser_ui_deps = [
|
||||
"//brave/browser/ui",
|
||||
]
|
||||
|
||||
if (toolkit_views) {
|
||||
brave_browser_ui_sources += [
|
||||
"//brave/browser/ui/views/omnibox/brave_omnibox_view_views.cc",
|
||||
"//brave/browser/ui/views/omnibox/brave_omnibox_view_views.h",
|
||||
]
|
||||
|
||||
brave_browser_ui_deps += [
|
||||
"//brave/app:brave_generated_resources_grit",
|
||||
"//brave/browser/profiles",
|
||||
"//brave/browser/tor",
|
||||
]
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "brave/browser/ui/views/omnibox/brave_omnibox_view_views.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "brave/browser/profiles/profile_util.h"
|
||||
#include "brave/browser/tor/tor_profile_service.h"
|
||||
#include "brave/browser/tor/tor_profile_service_factory.h"
|
||||
#include "brave/grit/brave_generated_resources.h"
|
||||
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
BraveOmniboxViewViews::BraveOmniboxViewViews(
|
||||
OmniboxEditController* controller,
|
||||
std::unique_ptr<OmniboxClient> client,
|
||||
bool popup_window_mode,
|
||||
LocationBarView* location_bar,
|
||||
const gfx::FontList& font_list)
|
||||
: OmniboxViewViews(controller,
|
||||
std::move(client),
|
||||
popup_window_mode,
|
||||
location_bar,
|
||||
font_list) {
|
||||
if (brave::IsTorProfile(location_bar->profile())) {
|
||||
tor_profile_service_ =
|
||||
TorProfileServiceFactory::GetForProfile(location_bar->profile());
|
||||
DCHECK(tor_profile_service_);
|
||||
tor_profile_service_->AddObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
BraveOmniboxViewViews::~BraveOmniboxViewViews() {
|
||||
if (tor_profile_service_)
|
||||
tor_profile_service_->RemoveObserver(this);
|
||||
}
|
||||
|
||||
void BraveOmniboxViewViews::OnFocus() {
|
||||
OmniboxViewViews::OnFocus();
|
||||
if (tor_profile_service_) {
|
||||
if (!tor_profile_service_->IsTorLaunched()) {
|
||||
SetPlaceholderText(
|
||||
l10n_util::GetStringUTF16(IDS_OMNIBOX_INITIALIZING_TOR));
|
||||
SetUserText(l10n_util::GetStringUTF16(IDS_OMNIBOX_INITIALIZING_TOR),
|
||||
false);
|
||||
SetReadOnly(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BraveOmniboxViewViews::OnTorLaunched(bool result, int64_t pid) {
|
||||
InstallPlaceholderText();
|
||||
RevertAll();
|
||||
SetReadOnly(false);
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BRAVE_BROWSER_UI_VIEWS_OMNIBOX_BRAVE_OMNIBOX_VIEW_VIEWS_H_
|
||||
#define BRAVE_BROWSER_UI_VIEWS_OMNIBOX_BRAVE_OMNIBOX_VIEW_VIEWS_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "brave/browser/tor/tor_launcher_service_observer.h"
|
||||
#include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
|
||||
|
||||
namespace tor {
|
||||
class TorProfileService;
|
||||
} // namespace tor
|
||||
|
||||
class BraveOmniboxViewViews : public OmniboxViewViews,
|
||||
public tor::TorLauncherServiceObserver {
|
||||
public:
|
||||
BraveOmniboxViewViews(OmniboxEditController* controller,
|
||||
std::unique_ptr<OmniboxClient> client,
|
||||
bool popup_window_mode,
|
||||
LocationBarView* location_bar,
|
||||
const gfx::FontList& font_list);
|
||||
~BraveOmniboxViewViews() override;
|
||||
|
||||
// tor::TorLauncherServiceObserver:
|
||||
void OnTorLaunched(bool result, int64_t pid) override;
|
||||
|
||||
private:
|
||||
// views::Textfield:
|
||||
void OnFocus() override;
|
||||
|
||||
tor::TorProfileService* tor_profile_service_ = nullptr;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(BraveOmniboxViewViews);
|
||||
};
|
||||
|
||||
#endif // BRAVE_BROWSER_UI_VIEWS_OMNIBOX_BRAVE_OMNIBOX_VIEW_VIEWS_H_
|
||||
@@ -3,14 +3,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "brave/browser/profiles/profile_util.h"
|
||||
#include "brave/browser/ui/browser_commands.h"
|
||||
#include "brave/browser/ui/views/omnibox/brave_omnibox_view_views.h"
|
||||
#include "brave/grit/brave_generated_resources.h"
|
||||
#include "chrome/browser/chrome_notification_types.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/browser/ui/browser_commands.h"
|
||||
#include "chrome/browser/ui/browser_list.h"
|
||||
#include "chrome/browser/ui/views/frame/browser_view.h"
|
||||
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
|
||||
#include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
|
||||
@@ -20,28 +12,16 @@
|
||||
#include "content/public/test/browser_test.h"
|
||||
#include "url/gurl.h"
|
||||
#include "ui/base/clipboard/clipboard.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/strings/grit/ui_strings.h"
|
||||
#include "ui/views/controls/textfield/textfield.h"
|
||||
#include "ui/views/view_observer.h"
|
||||
|
||||
class BraveOmniboxViewViewsTest : public InProcessBrowserTest,
|
||||
public views::ViewObserver {
|
||||
class BraveOmniboxViewViewsTest : public InProcessBrowserTest {
|
||||
public:
|
||||
LocationBarView* location_bar(Browser* browser) {
|
||||
auto* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
|
||||
LocationBarView* location_bar() {
|
||||
auto* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
|
||||
return browser_view->toolbar()->location_bar();
|
||||
}
|
||||
OmniboxViewViews* omnibox_view(Browser* browser) {
|
||||
return location_bar(browser)->omnibox_view();
|
||||
}
|
||||
|
||||
// views::ViewObserver overrides:
|
||||
void OnViewFocused(views::View* observed_view) override {
|
||||
run_loop_->Quit();
|
||||
}
|
||||
|
||||
base::RunLoop* run_loop_ = nullptr;
|
||||
OmniboxViewViews* omnibox_view() { return location_bar()->omnibox_view(); }
|
||||
};
|
||||
|
||||
// Load brave url and check copied url also has brave scheme.
|
||||
@@ -49,8 +29,8 @@ IN_PROC_BROWSER_TEST_F(BraveOmniboxViewViewsTest, CopyURLToClipboardTest) {
|
||||
const std::string test_url("brave://version/");
|
||||
ui_test_utils::NavigateToURL(browser(), GURL(test_url));
|
||||
|
||||
omnibox_view(browser())->SelectAll(true);
|
||||
omnibox_view(browser())->ExecuteCommand(views::Textfield::kCopy, 0);
|
||||
omnibox_view()->SelectAll(true);
|
||||
omnibox_view()->ExecuteCommand(views::Textfield::kCopy, 0);
|
||||
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
|
||||
std::string text_from_clipboard;
|
||||
clipboard->ReadAsciiText(ui::ClipboardBuffer::kCopyPaste,
|
||||
@@ -63,52 +43,3 @@ IN_PROC_BROWSER_TEST_F(BraveOmniboxViewViewsTest, CopyURLToClipboardTest) {
|
||||
EXPECT_EQ(test_url, text_from_clipboard);
|
||||
#endif
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(BraveOmniboxViewViewsTest, WaitForTorProcess) {
|
||||
auto* browser_list = BrowserList::GetInstance();
|
||||
content::WindowedNotificationObserver tor_browser_creation_observer(
|
||||
chrome::NOTIFICATION_BROWSER_OPENED,
|
||||
content::NotificationService::AllSources());
|
||||
brave::NewOffTheRecordWindowTor(browser());
|
||||
tor_browser_creation_observer.Wait();
|
||||
Browser* tor_browser = nullptr;
|
||||
for (Browser* browser : *browser_list) {
|
||||
if (brave::IsTorProfile(browser->profile())) {
|
||||
tor_browser = browser;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DCHECK(tor_browser);
|
||||
OmniboxViewViews* tor_views = omnibox_view(tor_browser);
|
||||
chrome::FocusLocationBar(tor_browser);
|
||||
|
||||
tor_views->AddObserver(this);
|
||||
|
||||
base::RunLoop run_loop;
|
||||
if (!tor_views->HasFocus()) {
|
||||
// Wait for omnibox get focused.
|
||||
run_loop_ = &run_loop;
|
||||
run_loop.Run();
|
||||
}
|
||||
|
||||
// Check indicator
|
||||
EXPECT_EQ(tor_views->GetPlaceholderText(),
|
||||
l10n_util::GetStringUTF16(IDS_OMNIBOX_INITIALIZING_TOR));
|
||||
EXPECT_EQ(tor_views->GetText(),
|
||||
l10n_util::GetStringUTF16(IDS_OMNIBOX_INITIALIZING_TOR));
|
||||
|
||||
// Check read only
|
||||
tor_views->SelectAll(true);
|
||||
tor_views->ExecuteCommand(views::Textfield::kCut, 0);
|
||||
EXPECT_EQ(tor_views->GetText(),
|
||||
l10n_util::GetStringUTF16(IDS_OMNIBOX_INITIALIZING_TOR));
|
||||
|
||||
// Emulate tor process launched
|
||||
static_cast<BraveOmniboxViewViews*>(tor_views)->OnTorLaunched(true, 5566);
|
||||
EXPECT_NE(tor_views->GetPlaceholderText(),
|
||||
l10n_util::GetStringUTF16(IDS_OMNIBOX_INITIALIZING_TOR));
|
||||
EXPECT_NE(tor_views->GetText(),
|
||||
l10n_util::GetStringUTF16(IDS_OMNIBOX_INITIALIZING_TOR));
|
||||
|
||||
tor_views->RemoveObserver(this);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import("//brave/brave_repack_locales.gni")
|
||||
import("//brave/build/config/compiler.gni")
|
||||
import("//brave/build/features.gni")
|
||||
import("//brave/browser/ui/sources.gni")
|
||||
import("//brave/components/sync/driver/sources.gni")
|
||||
import("//brave/net/sources.gni")
|
||||
import("//brave/third_party/blink/renderer/includes.gni")
|
||||
|
||||
@@ -4,15 +4,12 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "brave/browser/ui/omnibox/brave_omnibox_client_impl.h"
|
||||
#include "brave/browser/ui/views/omnibox/brave_omnibox_view_views.h"
|
||||
|
||||
#define BRAVE_LAYOUT_TRAILING_DECORATIONS \
|
||||
if (right_most && right_most->GetVisible()) \
|
||||
trailing_decorations.AddDecoration(0, height(), false, 0, 0, right_most);
|
||||
|
||||
#define ChromeOmniboxClient BraveOmniboxClientImpl
|
||||
#define OmniboxViewViews BraveOmniboxViewViews
|
||||
#include "../../../../../../../chrome/browser/ui/views/location_bar/location_bar_view.cc"
|
||||
#undef OmniboxViewViews
|
||||
#undef ChromeOmniboxClient
|
||||
#undef BRAVE_LAYOUT_TRAILING_DECORATIONS
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_
|
||||
#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_
|
||||
|
||||
#define BRAVE_OMNIBOX_VIEW_VIEWS_H_ \
|
||||
private: \
|
||||
friend class BraveOmniboxViewViews;
|
||||
#include "../../../../../../../chrome/browser/ui/views/omnibox/omnibox_view_views.h"
|
||||
#undef BRAVE_OMNIBOX_VIEW_VIEWS_H_
|
||||
|
||||
#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_VIEW_VIEWS_H_
|
||||
@@ -1,12 +1,12 @@
|
||||
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn
|
||||
index 4a31f9315ce898ed714a7efca6a8afca9d4baf76..e21eec373f85bea5ab53db88428b68f752ed9b05 100644
|
||||
index 4a31f9315ce898ed714a7efca6a8afca9d4baf76..aecb571950fb6de7659e11883a21baf6bbf5e948 100644
|
||||
--- a/chrome/browser/ui/BUILD.gn
|
||||
+++ b/chrome/browser/ui/BUILD.gn
|
||||
@@ -608,6 +608,7 @@ static_library("ui") {
|
||||
"//ui/webui",
|
||||
"//v8:v8_version",
|
||||
]
|
||||
+ sources += brave_browser_ui_sources deps += brave_browser_ui_deps
|
||||
+ deps+= [ "//brave/browser/ui" ]
|
||||
allow_circular_includes_from +=
|
||||
[ "//chrome/browser/ui/webui/bluetooth_internals" ]
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.h b/chrome/browser/ui/views/omnibox/omnibox_view_views.h
|
||||
index 090122ae64681209581ea2e81dbd795e920b25d1..a67dccea75bcf01112c8298cc12fef8d30ffa2de 100644
|
||||
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.h
|
||||
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.h
|
||||
@@ -154,6 +154,7 @@ class OmniboxViewViews : public OmniboxView,
|
||||
void OnThemeChanged() override;
|
||||
bool IsDropCursorForInsertion() const override;
|
||||
|
||||
+ BRAVE_OMNIBOX_VIEW_VIEWS_H_
|
||||
private:
|
||||
// TODO(tommycli): Remove the rest of these friends after porting these
|
||||
// browser tests to unit tests.
|
||||
Reference in New Issue
Block a user