Skip to content

Commit

Permalink
Merge pull request #776 from brave/user_gesture
Browse files Browse the repository at this point in the history
Issue 542: Request user confirmation before opening all external applications
  • Loading branch information
jumde authored Nov 13, 2018
2 parents bb3cbda + ebbd576 commit 1698b31
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "chrome/browser/external_protocol/external_protocol_handler.h"

#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"

class ExternalProtocolHandlerTest : public testing::Test {
protected:
void SetUp() override {
profile_.reset(new TestingProfile());
}

void TearDown() override {
TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr);
}

content::TestBrowserThreadBundle test_browser_thread_bundle_;
std::unique_ptr<TestingProfile> profile_;
};

TEST_F(ExternalProtocolHandlerTest, TestGetBlockStateMailto) {
ExternalProtocolHandler::BlockState block_state =
ExternalProtocolHandler::GetBlockState("mailto", profile_.get());
EXPECT_EQ(ExternalProtocolHandler::UNKNOWN, block_state);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/chrome/browser/external_protocol/external_protocol_handler.cc b/chrome/browser/external_protocol/external_protocol_handler.cc
index 3779df927d069657d0e244703739811c8eed2d6f..422f10a87fdb1b80495e314ec685a3347f32dc28 100644
--- a/chrome/browser/external_protocol/external_protocol_handler.cc
+++ b/chrome/browser/external_protocol/external_protocol_handler.cc
@@ -183,7 +183,7 @@ ExternalProtocolHandler::BlockState ExternalProtocolHandler::GetBlockState(
// Always allow the hard-coded allowed schemes.
for (size_t i = 0; i < arraysize(kAllowedSchemes); ++i) {
if (kAllowedSchemes[i] == scheme)
- return DONT_BLOCK;
+ return UNKNOWN;
}

PrefService* profile_prefs = profile->GetPrefs();
1 change: 1 addition & 0 deletions test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ test("brave_unit_tests") {
"//brave/browser/profiles/tor_unittest_profile_manager.h",
"//brave/browser/profiles/brave_profile_manager_unittest.cc",
"//brave/browser/resources/settings/reset_report_uploader_unittest.cc",
"//brave/chromium_src/chrome/browser/external_protocol/external_protocol_handler_unittest.cc",
"//brave/chromium_src/chrome/browser/signin/account_consistency_disabled_unittest.cc",
"//brave\chromium_src/chrome/browser/ui/bookmarks/brave_bookmark_context_menu_controller_unittest.cc",
"//brave/chromium_src/components/search_engines/brave_template_url_prepopulate_data_unittest.cc",
Expand Down

0 comments on commit 1698b31

Please sign in to comment.