Commit 4c7a6bca authored by Alexander Cooper's avatar Alexander Cooper Committed by Commit Bot

Convert components/captive_portal to base::RepeatingCallback

Converts the OpenLoginTabCallback from Callback to RepeatingCallback.
Converts base::Bind calls that were being passed to methods that take
RepeatingCallback's to BindRepeating.
Converts a few Callbacks being used as OpenLoginTabCallback in
chrome/browser as well, since that is how the initial need for changes
was discovered.

Bug: 1007635,714018
Change-Id: I3a514a2eff2d821e2a34d9537440407eab1619e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2297565
Commit-Queue: Eric Roman <eroman@chromium.org>
Reviewed-by: default avatarEric Roman <eroman@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Auto-Submit: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789666}
parent d96a11fa
......@@ -9,6 +9,7 @@
#include <memory>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/macros.h"
#include "base/metrics/field_trial.h"
......@@ -882,7 +883,7 @@ TEST_F(ChromeContentBrowserClientCaptivePortalBrowserTest,
true /* expected_disable_secure_dns */);
captive_portal::CaptivePortalTabHelper::CreateForWebContents(
web_contents(), CaptivePortalServiceFactory::GetForProfile(profile()),
base::Callback<void(void)>());
base::NullCallback());
captive_portal::CaptivePortalTabHelper::FromWebContents(web_contents())
->set_is_captive_portal_window();
NavigateAndCommit(GURL("https://www.google.com"), ui::PAGE_TRANSITION_LINK);
......
......@@ -396,8 +396,9 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
#if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
captive_portal::CaptivePortalTabHelper::CreateForWebContents(
web_contents, CaptivePortalServiceFactory::GetForProfile(profile),
base::Bind(&ChromeSecurityBlockingPageFactory::OpenLoginTabForWebContents,
web_contents, false));
base::BindRepeating(
&ChromeSecurityBlockingPageFactory::OpenLoginTabForWebContents,
web_contents, false));
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
......
......@@ -142,8 +142,8 @@ CaptivePortalService::CaptivePortalService(
// created before the call to UpdateEnabledState.
resolve_errors_with_web_service_.Init(
embedder_support::kAlternateErrorPagesEnabled, pref_service,
base::Bind(&CaptivePortalService::UpdateEnabledState,
base::Unretained(this)));
base::BindRepeating(&CaptivePortalService::UpdateEnabledState,
base::Unretained(this)));
ResetBackoffEntry(last_detection_result_);
UpdateEnabledState();
......
......@@ -33,8 +33,8 @@ class CaptivePortalObserver {
num_results_received_(0),
captive_portal_service_(captive_portal_service),
subscription_(captive_portal_service->RegisterCallback(
base::Bind(&CaptivePortalObserver::Observe,
base::Unretained(this)))) {}
base::BindRepeating(&CaptivePortalObserver::Observe,
base::Unretained(this)))) {}
CaptivePortalResult captive_portal_result() const {
return captive_portal_result_;
......
......@@ -47,8 +47,8 @@ CaptivePortalTabHelper::CaptivePortalTabHelper(
login_detector_(new CaptivePortalLoginDetector(captive_portal_service)),
is_captive_portal_window_(false),
subscription_(captive_portal_service->RegisterCallback(
base::Bind(&CaptivePortalTabHelper::Observe,
base::Unretained(this)))) {
base::BindRepeating(&CaptivePortalTabHelper::Observe,
base::Unretained(this)))) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
}
......
......@@ -44,7 +44,7 @@ const char* const kHttpsUrl2 = "https://cross_process.com/";
class MockCaptivePortalTabReloader : public CaptivePortalTabReloader {
public:
MockCaptivePortalTabReloader()
: CaptivePortalTabReloader(nullptr, nullptr, base::Callback<void()>()) {}
: CaptivePortalTabReloader(nullptr, nullptr, base::NullCallback()) {}
MOCK_METHOD1(OnLoadStart, void(bool));
MOCK_METHOD2(OnLoadCommitted, void(int, net::ResolveErrorInfo));
......
......@@ -71,7 +71,7 @@ class CaptivePortalTabReloader {
};
// Function to open a login tab, if there isn't one already.
typedef base::Callback<void()> OpenLoginTabCallback;
using OpenLoginTabCallback = base::RepeatingCallback<void()>;
// |captive_portal_service| and |web_contents| will only be dereferenced in
// ReloadTab, MaybeOpenCaptivePortalLoginTab, and CheckForCaptivePortal, so
......
......@@ -4,6 +4,7 @@
#include "components/captive_portal/content/captive_portal_tab_reloader.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/macros.h"
#include "base/run_loop.h"
......@@ -24,9 +25,7 @@ namespace captive_portal {
class TestCaptivePortalTabReloader : public CaptivePortalTabReloader {
public:
explicit TestCaptivePortalTabReloader(content::WebContents* web_contents)
: CaptivePortalTabReloader(NULL,
web_contents,
base::Callback<void(void)>()) {}
: CaptivePortalTabReloader(nullptr, web_contents, base::NullCallback()) {}
~TestCaptivePortalTabReloader() 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