-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1825 from brave/status_bubble_view_brave_url
Show brave url on status bubble
- Loading branch information
Showing
7 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* Copyright (c) 2019 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/brave_status_bubble_views.h" | ||
|
||
#include "content/public/common/url_constants.h" | ||
#include "url/gurl.h" | ||
|
||
void BraveStatusBubbleViews::SetURL(const GURL& url) { | ||
GURL revised_url = url; | ||
if (revised_url.SchemeIs(content::kChromeUIScheme)) { | ||
GURL::Replacements replacements; | ||
replacements.SetSchemeStr(content::kBraveUIScheme); | ||
revised_url = revised_url.ReplaceComponents(replacements); | ||
} | ||
|
||
StatusBubbleViews::SetURL(revised_url); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* Copyright (c) 2019 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_BRAVE_STATUS_BUBBLE_VIEWS_H_ | ||
#define BRAVE_BROWSER_UI_VIEWS_BRAVE_STATUS_BUBBLE_VIEWS_H_ | ||
|
||
#include "chrome/browser/ui/views/status_bubble_views.h" | ||
|
||
class BraveStatusBubbleViews : public StatusBubbleViews { | ||
public: | ||
using StatusBubbleViews::StatusBubbleViews; | ||
~BraveStatusBubbleViews() override = default; | ||
|
||
// StatusBubbleViews overrides: | ||
void SetURL(const GURL& url) override; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(BraveStatusBubbleViews); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_UI_VIEWS_BRAVE_STATUS_BUBBLE_VIEWS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* Copyright (c) 2019 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/brave_status_bubble_views.h" | ||
|
||
#include "chrome/test/views/chrome_views_test_base.h" | ||
#include "ui/views/widget/widget.h" | ||
|
||
class BraveStatusBubbleViewsTest : public ChromeViewsTestBase { | ||
protected: | ||
// ChromeViewsTestBase overrides: | ||
void SetUp() override { | ||
ChromeViewsTestBase::SetUp(); | ||
CreateWidget(); | ||
} | ||
|
||
void TearDown() override { | ||
if (widget_ && !widget_->IsClosed()) | ||
widget_->Close(); | ||
|
||
ChromeViewsTestBase::TearDown(); | ||
} | ||
|
||
views::Widget* widget() const { | ||
return widget_; | ||
} | ||
|
||
private: | ||
void CreateWidget() { | ||
DCHECK(!widget_); | ||
widget_ = new views::Widget; | ||
views::Widget::InitParams params = | ||
CreateParams(views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | ||
widget_->Init(params); | ||
} | ||
|
||
views::Widget* widget_ = nullptr; | ||
}; | ||
|
||
TEST_F(BraveStatusBubbleViewsTest, SetURLTest) { | ||
BraveStatusBubbleViews bubble(widget()->GetContentsView()); | ||
bubble.SetURL(GURL("chrome://settings/")); | ||
EXPECT_EQ(GURL("brave://settings/"), bubble.url_); | ||
|
||
const GURL brave_url("https://www.brave.com/"); | ||
bubble.SetURL(brave_url); | ||
EXPECT_EQ(brave_url, bubble.url_); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
/* Copyright (c) 2019 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 "chrome/browser/ui/views/toolbar/toolbar_view.h" | ||
#include "brave/browser/ui/views/brave_status_bubble_views.h" | ||
#include "brave/browser/ui/views/toolbar/brave_toolbar_view.h" | ||
|
||
#define ToolbarView BraveToolbarView | ||
#define StatusBubbleViews BraveStatusBubbleViews | ||
|
||
#include "../../../../../../../chrome/browser/ui/views/frame/browser_view.cc" | ||
#include "../../../../../../../chrome/browser/ui/views/frame/browser_view.cc" // NOLINT |
14 changes: 14 additions & 0 deletions
14
patches/chrome-browser-ui-views-status_bubble_views.h.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
diff --git a/chrome/browser/ui/views/status_bubble_views.h b/chrome/browser/ui/views/status_bubble_views.h | ||
index b2ad6e5d19f119f58df8deb7fa8a840a04681628..036d48dbdccc20eb300ba43bff0413e1ac281f99 100644 | ||
--- a/chrome/browser/ui/views/status_bubble_views.h | ||
+++ b/chrome/browser/ui/views/status_bubble_views.h | ||
@@ -70,6 +70,9 @@ class StatusBubbleViews : public StatusBubble { | ||
|
||
private: | ||
friend class StatusBubbleViewsTest; | ||
+#if defined(BRAVE_CHROMIUM_BUILD) | ||
+ FRIEND_TEST_ALL_PREFIXES(BraveStatusBubbleViewsTest, SetURLTest); | ||
+#endif | ||
|
||
class StatusView; | ||
class StatusViewAnimation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters