0

Rename NewTabWithUrl to OpenUrl.

Follow up CL for crrev.com/c/3096815.

Bug: None
Change-Id: I5da52626d41c10270b3abb9e18833d4b3b571a11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3114412
Reviewed-by: James Cook <jamescook@chromium.org>
Commit-Queue: Hidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#914983}
This commit is contained in:
Hidehiko Abe
2021-08-25 00:15:19 +00:00
committed by Chromium LUCI CQ
parent 4d7e3691be
commit c8d7df00f1
24 changed files with 70 additions and 70 deletions

@ -247,7 +247,7 @@ class MockNewWindowDelegate : public testing::NiceMock<TestNewWindowDelegate> {
MOCK_METHOD(void, OpenCalculator, (), (override));
MOCK_METHOD(void, ShowKeyboardShortcutViewer, (), (override));
MOCK_METHOD(void,
NewTabWithUrl,
OpenUrl,
(const GURL& url, bool from_user_interaction),
(override));
};
@ -2387,7 +2387,7 @@ TEST_F(AcceleratorControllerStartupNotificationTest,
// Setup the expectation that the learn more button opens this shortcut
// help link.
EXPECT_CALL(*new_window_delegate_, NewTabWithUrl)
EXPECT_CALL(*new_window_delegate_, OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL(kKeyboardShortcutHelpPageUrl), url);
EXPECT_TRUE(from_user_interaction);

@ -202,7 +202,7 @@ void ShowShortcutsChangedNotification() {
if (button_index.has_value()) {
DCHECK_EQ(0, button_index.value());
NewWindowDelegate::GetInstance()->NewTabWithUrl(
NewWindowDelegate::GetInstance()->OpenUrl(
GURL(kKeyboardShortcutHelpPageUrl),
/*from_user_interaction=*/true);
} else {

@ -30,8 +30,8 @@ void SuggestedContentInfoView::CloseButtonPressed() {
void SuggestedContentInfoView::LinkClicked() {
view_delegate_->MarkSuggestedContentInfoDismissed();
constexpr char url[] = "chrome://os-settings/osPrivacy";
NewWindowDelegate::GetInstance()->NewTabWithUrl(
GURL(url), /*from_user_interaction=*/true);
NewWindowDelegate::GetInstance()->OpenUrl(GURL(url),
/*from_user_interaction=*/true);
}
} // namespace ash

@ -171,8 +171,8 @@ void AssistantControllerImpl::OpenUrl(const GURL& url,
// such, the browser will always be instructed to open |url| in a new
// browser tab and Assistant UI state will be updated downstream to respect
// |in_background|.
NewWindowDelegate::GetInstance()->NewTabWithUrl(
url, /*from_user_interaction=*/true);
NewWindowDelegate::GetInstance()->OpenUrl(url,
/*from_user_interaction=*/true);
}
NotifyUrlOpened(url, from_server);
}

@ -78,7 +78,7 @@ class MockNewWindowDelegate : public testing::NiceMock<TestNewWindowDelegate> {
public:
// TestNewWindowDelegate:
MOCK_METHOD(void,
NewTabWithUrl,
OpenUrl,
(const GURL& url, bool from_user_interaction),
(override));
@ -164,7 +164,7 @@ TEST_F(AssistantControllerImplTest, NotifiesOpeningUrlAndUrlOpened) {
EXPECT_TRUE(from_server);
}));
EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
EXPECT_CALL(new_window_delegate(), OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL("https://g.co/"), url);
EXPECT_TRUE(from_user_interaction);

@ -80,8 +80,8 @@ void UrlHandlerServiceProvider::OpenUrl(
VLOG(1) << "Opening url now";
NewWindowDelegate::GetInstance()->NewTabWithUrl(
gurl, false /* from_user_interaction */);
NewWindowDelegate::GetInstance()->OpenUrl(gurl,
false /* from_user_interaction */);
std::move(response_sender).Run(dbus::Response::FromMethodCall(method_call));
}

@ -37,11 +37,6 @@ class ASH_PUBLIC_EXPORT NewWindowDelegate {
// Invoked when the user uses Ctrl+T to open a new tab.
virtual void NewTab() = 0;
// Opens a new tab with the specified URL. If the |from_user_interaction|
// is true then the page will load with a user activation. This means the
// page will be able to autoplay media without restriction.
virtual void NewTabWithUrl(const GURL& url, bool from_user_interaction) = 0;
// Invoked when the user uses Ctrl-N or Ctrl-Shift-N to open a new window. If
// the |should_trigger_session_restore| is true, a new window opening should
// be treated like the start of a session (with potential session restore,
@ -49,6 +44,11 @@ class ASH_PUBLIC_EXPORT NewWindowDelegate {
virtual void NewWindow(bool incognito,
bool should_trigger_session_restore) = 0;
// Opens the specified URL in a new tab. If the |from_user_interaction|
// is true then the page will load with a user activation. This means the
// page will be able to autoplay media without restriction.
virtual void OpenUrl(const GURL& url, bool from_user_interaction) = 0;
// Invoked when an accelerator (calculator key) is used to open calculator.
virtual void OpenCalculator() = 0;

@ -12,10 +12,10 @@ TestNewWindowDelegate::TestNewWindowDelegate() = default;
TestNewWindowDelegate::~TestNewWindowDelegate() = default;
void TestNewWindowDelegate::NewTab() {}
void TestNewWindowDelegate::NewTabWithUrl(const GURL& url,
bool from_user_interaction) {}
void TestNewWindowDelegate::NewWindow(bool incognito,
bool should_trigger_session_restore) {}
void TestNewWindowDelegate::OpenUrl(const GURL& url,
bool from_user_interaction) {}
void TestNewWindowDelegate::OpenCalculator() {}
void TestNewWindowDelegate::OpenFileManager() {}
void TestNewWindowDelegate::OpenDownloadsFolder() {}

@ -22,8 +22,8 @@ class ASH_PUBLIC_EXPORT TestNewWindowDelegate : public NewWindowDelegate {
private:
// NewWindowDelegate:
void NewTab() override;
void NewTabWithUrl(const GURL& url, bool from_user_interaction) override;
void NewWindow(bool incognito, bool should_trigger_session_restore) override;
void OpenUrl(const GURL& url, bool from_user_interaction) override;
void OpenCalculator() override;
void OpenFileManager() override;
void OpenDownloadsFolder() override;

@ -267,8 +267,8 @@ void QuickAnswersControllerImpl::OnNoticeSettingsRequestedByUser() {
quick_answers_ui_controller_->CloseUserNoticeView();
notice_controller_->AcceptNotice(
chromeos::quick_answers::NoticeInteractionType::kManageSettings);
NewWindowDelegate::GetInstance()->NewTabWithUrl(
GURL(kAssistantRelatedInfoUrl), /*from_user_interaction=*/true);
NewWindowDelegate::GetInstance()->OpenUrl(GURL(kAssistantRelatedInfoUrl),
/*from_user_interaction=*/true);
}
void QuickAnswersControllerImpl::OnUserConsentResult(bool consented) {
@ -285,13 +285,13 @@ void QuickAnswersControllerImpl::OnUserConsentResult(bool consented) {
}
void QuickAnswersControllerImpl::OpenQuickAnswersDogfoodLink() {
NewWindowDelegate::GetInstance()->NewTabWithUrl(
GURL(kDogfoodUrl), /*from_user_interaction=*/true);
NewWindowDelegate::GetInstance()->OpenUrl(GURL(kDogfoodUrl),
/*from_user_interaction=*/true);
}
void QuickAnswersControllerImpl::OpenQuickAnswersSettings() {
NewWindowDelegate::GetInstance()->NewTabWithUrl(
GURL(kQuickAnswersSettingsUrl), /*from_user_interaction=*/true);
NewWindowDelegate::GetInstance()->OpenUrl(GURL(kQuickAnswersSettingsUrl),
/*from_user_interaction=*/true);
}
void QuickAnswersControllerImpl::MaybeDismissQuickAnswersNotice() {

@ -71,7 +71,7 @@ void QuickAnswersUiController::OnQuickAnswersViewPressed() {
controller_->DismissQuickAnswers(QuickAnswersExitPoint::kQuickAnswersClick);
if (chromeos::features::IsQuickAnswersV2Enabled()) {
NewWindowDelegate::GetInstance()->NewTabWithUrl(
NewWindowDelegate::GetInstance()->OpenUrl(
GURL(kGoogleSearchUrlPrefix +
net::EscapeUrlEncodedData(query_, /*use_plus=*/true)),
/*from_user_interaction=*/true);

@ -101,16 +101,16 @@ void OnPeripheralLimitedNotificationClicked(absl::optional<int> button_index) {
UpdateNotificationPrefCount(/*clicked_settings=*/true);
break;
case ButtonIndex::kLearnMore:
NewWindowDelegate::GetInstance()->NewTabWithUrl(
GURL(kLearnMoreHelpUrl), /*from_user_interaction=*/true);
NewWindowDelegate::GetInstance()->OpenUrl(GURL(kLearnMoreHelpUrl),
/*from_user_interaction=*/true);
break;
}
RemoveNotification(kPciePeripheralLimitedPerformanceNotificationId);
}
void OnGuestNotificationClicked(bool is_thunderbolt_only) {
NewWindowDelegate::GetInstance()->NewTabWithUrl(
GURL(kLearnMoreHelpUrl), /*from_user_interaction=*/true);
NewWindowDelegate::GetInstance()->OpenUrl(GURL(kLearnMoreHelpUrl),
/*from_user_interaction=*/true);
if (is_thunderbolt_only) {
RemoveNotification(kPciePeripheralGuestModeNotSupportedNotificationId);
@ -121,14 +121,14 @@ void OnGuestNotificationClicked(bool is_thunderbolt_only) {
}
void OnPeripheralBlockedNotificationClicked() {
NewWindowDelegate::GetInstance()->NewTabWithUrl(
GURL(kLearnMoreHelpUrl), /*from_user_interaction=*/true);
NewWindowDelegate::GetInstance()->OpenUrl(GURL(kLearnMoreHelpUrl),
/*from_user_interaction=*/true);
RemoveNotification(kPciePeripheralDeviceBlockedNotificationId);
}
void OnBillboardNotificationClicked() {
NewWindowDelegate::GetInstance()->NewTabWithUrl(
GURL(kLearnMoreHelpUrl), /*from_user_interaction=*/true);
NewWindowDelegate::GetInstance()->OpenUrl(GURL(kLearnMoreHelpUrl),
/*from_user_interaction=*/true);
RemoveNotification(kPciePeripheralBillboardDeviceNotificationId);
}

@ -44,7 +44,7 @@ class MockNewWindowDelegate : public testing::NiceMock<TestNewWindowDelegate> {
public:
// TestNewWindowDelegate:
MOCK_METHOD(void,
NewTabWithUrl,
OpenUrl,
(const GURL& url, bool from_user_interaction),
(override));
};
@ -161,7 +161,7 @@ TEST_F(PciePeripheralNotificationControllerTest, GuestNotificationTbtOnly) {
EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount());
// Click on the notification and expect the Learn More page to appear.
EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
EXPECT_CALL(new_window_delegate(), OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL(kLearnMoreHelpUrl), url);
EXPECT_TRUE(from_user_interaction);
@ -187,7 +187,7 @@ TEST_F(PciePeripheralNotificationControllerTest, GuestNotificationTbtAltMode) {
EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount());
// Click on the notification and expect the Learn More page to appear.
EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
EXPECT_CALL(new_window_delegate(), OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL(kLearnMoreHelpUrl), url);
EXPECT_TRUE(from_user_interaction);
@ -211,7 +211,7 @@ TEST_F(PciePeripheralNotificationControllerTest,
EXPECT_EQ(0u, notification->buttons().size());
// Click on the notification and expect the Learn More page to appear.
EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
EXPECT_CALL(new_window_delegate(), OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL(kLearnMoreHelpUrl), url);
EXPECT_TRUE(from_user_interaction);
@ -238,7 +238,7 @@ TEST_F(PciePeripheralNotificationControllerTest, BillboardDeviceNotification) {
EXPECT_EQ(1u, MessageCenter::Get()->NotificationCount());
// Click on the notification and expect the Learn More page to appear.
EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
EXPECT_CALL(new_window_delegate(), OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL(kLearnMoreHelpUrl), url);
EXPECT_TRUE(from_user_interaction);
@ -264,7 +264,7 @@ TEST_F(PciePeripheralNotificationControllerTest,
// Ensure this notification has the two correct buttons.
EXPECT_EQ(2u, notification->buttons().size());
EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
EXPECT_CALL(new_window_delegate(), OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL(kLearnMoreHelpUrl), url);
EXPECT_TRUE(from_user_interaction);
@ -274,7 +274,7 @@ TEST_F(PciePeripheralNotificationControllerTest,
EXPECT_EQ(2, GetPrefNotificationCount());
EXPECT_EQ(0u, MessageCenter::Get()->NotificationCount());
EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
EXPECT_CALL(new_window_delegate(), OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL(kLearnMoreHelpUrl), url);
EXPECT_TRUE(from_user_interaction);
@ -284,7 +284,7 @@ TEST_F(PciePeripheralNotificationControllerTest,
EXPECT_EQ(1, GetPrefNotificationCount());
EXPECT_EQ(0u, MessageCenter::Get()->NotificationCount());
EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
EXPECT_CALL(new_window_delegate(), OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL(kLearnMoreHelpUrl), url);
EXPECT_TRUE(from_user_interaction);
@ -372,7 +372,7 @@ TEST_F(PciePeripheralNotificationControllerTest,
// We will always show guest notifications, expect that the pref did not
// decrement.
EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
EXPECT_CALL(new_window_delegate(), OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL(kLearnMoreHelpUrl), url);
EXPECT_TRUE(from_user_interaction);
@ -402,7 +402,7 @@ TEST_F(PciePeripheralNotificationControllerTest,
// We will always show guest notifications, expect that the pref did not
// decrement.
EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
EXPECT_CALL(new_window_delegate(), OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL(kLearnMoreHelpUrl), url);
EXPECT_TRUE(from_user_interaction);

@ -72,7 +72,7 @@ phone_hub_metrics::Screen BluetoothDisabledView::GetScreenForMetrics() const {
void BluetoothDisabledView::LearnMoreButtonPressed() {
LogInterstitialScreenEvent(InterstitialScreenEvent::kLearnMore);
NewWindowDelegate::GetInstance()->NewTabWithUrl(
NewWindowDelegate::GetInstance()->OpenUrl(
GURL(chromeos::phonehub::kPhoneHubLearnMoreLink),
/*from_user_interaction=*/true);
}

@ -141,8 +141,8 @@ void ContinueBrowsingChip::ButtonPressed() {
phone_hub_metrics::LogTabContinuationChipClicked(index_);
user_action_recorder_->RecordBrowserTabOpened();
NewWindowDelegate::GetInstance()->NewTabWithUrl(
url_, /*from_user_interaction=*/true);
NewWindowDelegate::GetInstance()->OpenUrl(url_,
/*from_user_interaction=*/true);
// Close Phone Hub bubble in current display.
views::Widget* const widget = GetWidget();

@ -73,8 +73,8 @@ NotificationOptInView::~NotificationOptInView() = default;
void NotificationOptInView::SetUpButtonPressed() {
// Opens the notification set up dialog in settings to start the opt in flow.
LogNotificationOptInEvent(InterstitialScreenEvent::kConfirm);
NewWindowDelegate::GetInstance()->NewTabWithUrl(
GURL(kMultideviceSettingsUrl), /*from_user_interaction=*/true);
NewWindowDelegate::GetInstance()->OpenUrl(GURL(kMultideviceSettingsUrl),
/*from_user_interaction=*/true);
}
void NotificationOptInView::DismissButtonPressed() {

@ -53,7 +53,7 @@ PhoneDisconnectedView::PhoneDisconnectedView(
&PhoneDisconnectedView::ButtonPressed, base::Unretained(this),
InterstitialScreenEvent::kLearnMore,
base::BindRepeating(
&NewWindowDelegate::NewTabWithUrl,
&NewWindowDelegate::OpenUrl,
base::Unretained(NewWindowDelegate::GetInstance()),
GURL(chromeos::phonehub::kPhoneHubLearnMoreLink),
/*from_user_interaction=*/true)),

@ -37,7 +37,7 @@ class MockNewWindowDelegate : public testing::NiceMock<TestNewWindowDelegate> {
public:
// TestNewWindowDelegate:
MOCK_METHOD(void,
NewTabWithUrl,
OpenUrl,
(const GURL& url, bool from_user_interaction),
(override));
};
@ -285,7 +285,7 @@ TEST_F(PhoneHubTrayTest, StartNotificationSetUpFlow) {
// Clicking on the set up button should open the corresponding settings page
// for the notification set up flow.
EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
EXPECT_CALL(new_window_delegate(), OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL("chrome://os-settings/multidevice/"
"features?showNotificationAccessSetupDialog"),
@ -442,7 +442,7 @@ TEST_F(PhoneHubTrayTest, ClickButtonsOnDisconnectedView) {
// Clicking "Learn More" button should open the corresponding help center
// article in a browser tab.
EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
EXPECT_CALL(new_window_delegate(), OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL("https://support.google.com/chromebook?p=phone_hub"),
url);
@ -463,7 +463,7 @@ TEST_F(PhoneHubTrayTest, ClickButtonOnBluetoothDisabledView) {
// Clicking "Learn more" button should open the corresponding help center
// article in a browser tab.
EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
EXPECT_CALL(new_window_delegate(), OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL("https://support.google.com/chromebook?p=phone_hub"),
url);

@ -25,7 +25,7 @@ class MockNewWindowDelegate : public testing::NiceMock<TestNewWindowDelegate> {
public:
// TestNewWindowDelegate:
MOCK_METHOD(void,
NewTabWithUrl,
OpenUrl,
(const GURL& url, bool from_user_interaction),
(override));
};
@ -120,8 +120,8 @@ TEST_F(TaskContinuationViewTest, TaskChipsView) {
for (auto* child : task_view()->chips_view_->children()) {
ContinueBrowsingChip* chip = static_cast<ContinueBrowsingChip*>(child);
// NewTabWithUrl is expected to call after button pressed simulation.
EXPECT_CALL(new_window_delegate(), NewTabWithUrl)
// OpenUrl is expected to call after button pressed simulation.
EXPECT_CALL(new_window_delegate(), OpenUrl)
.WillOnce([](const GURL& url, bool from_user_interaction) {
EXPECT_EQ(GURL("https://www.example.com/tab1"), url);
EXPECT_TRUE(from_user_interaction);

@ -108,7 +108,7 @@ class BorealisLifetimeObserver
void OnDelayComplete(GURL gurl, std::string app_id) {
app_delayers_.erase(app_id);
ash::NewWindowDelegate::GetInstance()->NewTabWithUrl(
ash::NewWindowDelegate::GetInstance()->OpenUrl(
gurl, /*from_user_interaction=*/true);
}

@ -320,11 +320,6 @@ void ChromeNewWindowClient::NewTab() {
browser->SetFocusToLocationBar();
}
void ChromeNewWindowClient::NewTabWithUrl(const GURL& url,
bool from_user_interaction) {
OpenUrlImpl(url, from_user_interaction);
}
void ChromeNewWindowClient::NewWindow(bool is_incognito,
bool should_trigger_session_restore) {
if (is_incognito && !IsIncognitoAllowed())
@ -340,6 +335,11 @@ void ChromeNewWindowClient::NewWindow(bool is_incognito,
should_trigger_session_restore);
}
void ChromeNewWindowClient::OpenUrl(const GURL& url,
bool from_user_interaction) {
OpenUrlImpl(url, from_user_interaction);
}
void ChromeNewWindowClient::OpenCalculator() {
Profile* const profile = ProfileManager::GetActiveUserProfile();
apps::AppServiceProxyChromeOs* proxy =

@ -38,8 +38,8 @@ class ChromeNewWindowClient : public ash::NewWindowDelegate,
// Overridden from ash::NewWindowDelegate:
void NewTab() override;
void NewTabWithUrl(const GURL& url, bool from_user_interaction) override;
void NewWindow(bool incognito, bool should_trigger_session_restore) override;
void OpenUrl(const GURL& url, bool from_user_interaction) override;
void OpenCalculator() override;
void OpenFileManager() override;
void OpenDownloadsFolder() override;

@ -18,16 +18,16 @@ void CrosapiNewWindowDelegate::NewTab() {
crosapi::BrowserManager::Get()->NewTab();
}
void CrosapiNewWindowDelegate::NewTabWithUrl(const GURL& url,
bool from_user_interaction) {
crosapi::BrowserManager::Get()->OpenUrl(url);
}
void CrosapiNewWindowDelegate::NewWindow(bool incognito,
bool should_trigger_session_restore) {
crosapi::BrowserManager::Get()->NewWindow(incognito);
}
void CrosapiNewWindowDelegate::OpenUrl(const GURL& url,
bool from_user_interaction) {
crosapi::BrowserManager::Get()->OpenUrl(url);
}
void CrosapiNewWindowDelegate::OpenCalculator() {
delegate_->OpenCalculator();
}

@ -22,8 +22,8 @@ class CrosapiNewWindowDelegate : public ash::NewWindowDelegate {
// Overridden from ash::NewWindowDelegate:
void NewTab() override;
void NewTabWithUrl(const GURL& url, bool from_user_interaction) override;
void NewWindow(bool incognito, bool should_trigger_session_restore) override;
void OpenUrl(const GURL& url, bool from_user_interaction) override;
void OpenCalculator() override;
void OpenFileManager() override;
void OpenDownloadsFolder() override;