Skip to content

Commit

Permalink
Patch to OmniboxEditModel::AdjustTextForCopy to get brave scheme.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhong committed Feb 12, 2020
1 parent d245eb6 commit fcdc84a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
trailing_decorations.AddDecoration(0, height(), false, 0, 0, right_most);

#define ChromeOmniboxClient BraveOmniboxClientImpl
#include "../../../../../../../chrome/browser/ui/views/location_bar/location_bar_view.cc" // NOLINT
#include "../../../../../../../chrome/browser/ui/views/location_bar/location_bar_view.cc"
#undef ChromeOmniboxClient
#undef BRAVE_LAYOUT_TRAILING_DECORATIONS
45 changes: 0 additions & 45 deletions chromium_src/chrome/browser/ui/views/omnibox/omnibox_view_views.cc

This file was deleted.

22 changes: 22 additions & 0 deletions chromium_src/components/omnibox/browser/omnibox_edit_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#include "brave/components/omnibox/browser/brave_omnibox_client.h"
#include "components/omnibox/browser/omnibox_client.h"
#include "components/omnibox/browser/omnibox_controller.h"
#include "url/gurl.h"

#if !defined(OS_IOS)
#include "content/public/common/url_constants.h"
#endif

class BraveOmniboxController : public OmniboxController {
public:
Expand All @@ -29,6 +34,23 @@ class BraveOmniboxController : public OmniboxController {
DISALLOW_COPY_AND_ASSIGN(BraveOmniboxController);
};

namespace {
void BraveAdjustTextForCopy(GURL* url) {
#if !defined(OS_IOS)
if (url->scheme() == content::kChromeUIScheme) {
GURL::Replacements replacements;
replacements.SetSchemeStr(content::kBraveUIScheme);
*url = url->ReplaceComponents(replacements);
}
#endif
}

} // namespace

#define BRAVE_ADJUST_TEXT_FOR_COPY \
BraveAdjustTextForCopy(url_from_text);

#define OmniboxController BraveOmniboxController
#include "../../../../../components/omnibox/browser/omnibox_edit_model.cc" // NOLINT
#undef OmniboxController
#undef BRAVE_ADJUST_TEXT_FOR_COPY
7 changes: 7 additions & 0 deletions components/omnibox/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,12 @@ source_set("browser") {
"//skia",
"//third_party/icu",
"//third_party/metrics_proto",
"//url",
]

if (!is_ios) {
deps += [
"//content/public/common",
]
}
}

This file was deleted.

12 changes: 12 additions & 0 deletions patches/components-omnibox-browser-omnibox_edit_model.cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/components/omnibox/browser/omnibox_edit_model.cc b/components/omnibox/browser/omnibox_edit_model.cc
index 3cfedd66eff30f1966c10fdb6a8b62961a61a8bb..ba76ebe4d5aa54f65db3b157884e5a4c6d9e7c78 100644
--- a/components/omnibox/browser/omnibox_edit_model.cc
+++ b/components/omnibox/browser/omnibox_edit_model.cc
@@ -384,6 +384,7 @@ void OmniboxEditModel::AdjustTextForCopy(int sel_min,
(*text == display_text_ || *text == url_for_editing_)) {
*url_from_text = controller()->GetLocationBarModel()->GetURL();
*write_url = true;
+ BRAVE_ADJUST_TEXT_FOR_COPY

// If the omnibox is displaying a URL, set the hyperlink text to the URL's
// spec. This undoes any URL elisions.

0 comments on commit fcdc84a

Please sign in to comment.