Commit 105f30bb authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

chromeos: use WidgetDelegate setters in CaptivePortalView

This change makes it clearer that the window title can never change once
this dialog is shown, and removes a bunch of now-unneeded overrides of
WidgetDelegate methods.

Bug: 1075649
Change-Id: I3f720f92e9e4ca4a6cdd1cade48bd53c861d2252
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2453189Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814710}
parent da78cb6c
......@@ -21,13 +21,30 @@ const char* CaptivePortalStartURL() {
return captive_portal::CaptivePortalDetector::kDefaultURL;
}
base::string16 WindowTitleForNetwork(const chromeos::NetworkState* network) {
if (!network->name().empty()) {
return l10n_util::GetStringFUTF16(IDS_LOGIN_CAPTIVE_PORTAL_WINDOW_TITLE,
base::ASCIIToUTF16(network->name()));
} else {
NOTREACHED() << "Captive portal with no active network?";
return l10n_util::GetStringFUTF16(IDS_LOGIN_CAPTIVE_PORTAL_WINDOW_TITLE,
{});
}
}
} // namespace
namespace chromeos {
CaptivePortalView::CaptivePortalView(Profile* profile,
CaptivePortalWindowProxy* proxy)
: SimpleWebViewDialog(profile), proxy_(proxy), redirected_(false) {}
: SimpleWebViewDialog(profile), proxy_(proxy), redirected_(false) {
SetCanResize(false);
SetModalType(ui::MODAL_TYPE_SYSTEM);
SetShowTitle(true);
SetTitle(WindowTitleForNetwork(
NetworkHandler::Get()->network_state_handler()->DefaultNetwork()));
}
CaptivePortalView::~CaptivePortalView() {}
......@@ -35,35 +52,6 @@ void CaptivePortalView::StartLoad() {
SimpleWebViewDialog::StartLoad(GURL(CaptivePortalStartURL()));
}
bool CaptivePortalView::CanResize() const {
return false;
}
ui::ModalType CaptivePortalView::GetModalType() const {
return ui::MODAL_TYPE_SYSTEM;
}
base::string16 CaptivePortalView::GetWindowTitle() const {
base::string16 network_name;
const NetworkState* default_network =
NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
std::string default_network_name =
default_network ? default_network->name() : std::string();
if (!default_network_name.empty()) {
network_name = base::ASCIIToUTF16(default_network_name);
} else {
DLOG(ERROR)
<< "No active/default network, but captive portal window is shown.";
}
return l10n_util::GetStringFUTF16(IDS_LOGIN_CAPTIVE_PORTAL_WINDOW_TITLE,
network_name);
}
bool CaptivePortalView::ShouldShowWindowTitle() const {
return true;
}
void CaptivePortalView::NavigationStateChanged(
content::WebContents* source,
content::InvalidateTypes changed_flags) {
......
......@@ -21,12 +21,6 @@ class CaptivePortalView : public SimpleWebViewDialog {
// Starts loading.
void StartLoad();
// Overridden from views::WidgetDelegate:
bool CanResize() const override;
ui::ModalType GetModalType() const override;
base::string16 GetWindowTitle() const override;
bool ShouldShowWindowTitle() const override;
// Overridden from content::WebContentsDelegate:
void NavigationStateChanged(content::WebContents* source,
content::InvalidateTypes changed_flags) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment