Convert chrome/browser/ui/ from base::Bind to Once/Repeating
Converting the remaining "base::Bind" and "base::Callback" after crrev.com/c/2600389 and crrev.com/c/2602358. Bug: 1152282 Change-Id: Ic61df1e0346acd6e9ad8c784e21fc436d12fd126 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2602378 Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Peter Kasting <pkasting@chromium.org> Commit-Queue: Ella Ge <eirage@chromium.org> Cr-Commit-Position: refs/heads/master@{#840534}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
54c17b7975
commit
4cd2538e77
PRESUBMIT.py
chrome/browser/ui
autofill
bluetooth
browser_command_controller.ccbrowser_instant_controller.ccbrowser_list.cccrypto_module_delegate_nss.cccrypto_module_password_dialog.hcrypto_module_password_dialog_nss.ccextensions
application_launch.ccextension_action_view_controller.ccextension_enable_flow.ccextension_enable_flow.hextension_installed_waiter.ccsettings_overridden_params_providers_unittest.cc
media_router
page_info
page_info_unittest.ccpermission_menu_model.ccpermission_menu_model.hpermission_menu_model_unittest.cc
passwords
prefs
search
search_engines
signin
views
@ -373,7 +373,6 @@ _NOT_CONVERTED_TO_MODERN_BIND_AND_CALLBACK = '|'.join((
|
||||
'^chrome/browser/supervised_user/',
|
||||
'^chrome/browser/sync_file_system/',
|
||||
'^chrome/browser/translate/',
|
||||
'^chrome/browser/ui/',
|
||||
'^chrome/browser/web_applications/',
|
||||
'^chrome/browser/win/',
|
||||
'^chrome/test/chromedriver/server/http_handler.cc',
|
||||
|
@ -715,7 +715,7 @@ ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents)
|
||||
log_manager_ =
|
||||
LogManager::Create(AutofillLogRouterFactory::GetForBrowserContext(
|
||||
web_contents->GetBrowserContext()),
|
||||
base::Closure());
|
||||
base::NullCallback());
|
||||
// Initialize StrikeDatabase so its cache will be loaded and ready to use when
|
||||
// when requested by other Autofill classes.
|
||||
GetStrikeDatabase();
|
||||
|
@ -19,8 +19,9 @@ class BluetoothChooserControllerTest : public testing::Test {
|
||||
BluetoothChooserControllerTest()
|
||||
: bluetooth_chooser_controller_(
|
||||
nullptr,
|
||||
base::Bind(&BluetoothChooserControllerTest::OnBluetoothChooserEvent,
|
||||
base::Unretained(this))) {
|
||||
base::BindRepeating(
|
||||
&BluetoothChooserControllerTest::OnBluetoothChooserEvent,
|
||||
base::Unretained(this))) {
|
||||
bluetooth_chooser_controller_.set_view(&mock_bluetooth_chooser_view_);
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ BrowserCommandController::BrowserCommandController(Browser* browser)
|
||||
local_pref_registrar_.Init(local_state);
|
||||
local_pref_registrar_.Add(
|
||||
prefs::kAllowFileSelectionDialogs,
|
||||
base::Bind(
|
||||
base::BindRepeating(
|
||||
&BrowserCommandController::UpdateCommandsForFileSelectionDialogs,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
@ -155,30 +155,33 @@ BrowserCommandController::BrowserCommandController(Browser* browser)
|
||||
profile_pref_registrar_.Init(profile()->GetPrefs());
|
||||
profile_pref_registrar_.Add(
|
||||
prefs::kDevToolsAvailability,
|
||||
base::Bind(&BrowserCommandController::UpdateCommandsForDevTools,
|
||||
base::Unretained(this)));
|
||||
base::BindRepeating(&BrowserCommandController::UpdateCommandsForDevTools,
|
||||
base::Unretained(this)));
|
||||
profile_pref_registrar_.Add(
|
||||
bookmarks::prefs::kEditBookmarksEnabled,
|
||||
base::Bind(&BrowserCommandController::UpdateCommandsForBookmarkEditing,
|
||||
base::Unretained(this)));
|
||||
base::BindRepeating(
|
||||
&BrowserCommandController::UpdateCommandsForBookmarkEditing,
|
||||
base::Unretained(this)));
|
||||
profile_pref_registrar_.Add(
|
||||
bookmarks::prefs::kShowBookmarkBar,
|
||||
base::Bind(&BrowserCommandController::UpdateCommandsForBookmarkBar,
|
||||
base::Unretained(this)));
|
||||
base::BindRepeating(
|
||||
&BrowserCommandController::UpdateCommandsForBookmarkBar,
|
||||
base::Unretained(this)));
|
||||
profile_pref_registrar_.Add(
|
||||
prefs::kIncognitoModeAvailability,
|
||||
base::Bind(
|
||||
base::BindRepeating(
|
||||
&BrowserCommandController::UpdateCommandsForIncognitoAvailability,
|
||||
base::Unretained(this)));
|
||||
profile_pref_registrar_.Add(
|
||||
prefs::kPrintingEnabled,
|
||||
base::Bind(&BrowserCommandController::UpdatePrintingState,
|
||||
base::Unretained(this)));
|
||||
base::BindRepeating(&BrowserCommandController::UpdatePrintingState,
|
||||
base::Unretained(this)));
|
||||
#if !defined(OS_MAC)
|
||||
profile_pref_registrar_.Add(
|
||||
prefs::kFullscreenAllowed,
|
||||
base::Bind(&BrowserCommandController::UpdateCommandsForFullscreenMode,
|
||||
base::Unretained(this)));
|
||||
base::BindRepeating(
|
||||
&BrowserCommandController::UpdateCommandsForFullscreenMode,
|
||||
base::Unretained(this)));
|
||||
#endif
|
||||
pref_signin_allowed_.Init(
|
||||
prefs::kSigninAllowed, profile()->GetOriginalProfile()->GetPrefs(),
|
||||
|
@ -82,8 +82,9 @@ BrowserInstantController::BrowserInstantController(Browser* browser)
|
||||
search_engine_base_url_tracker_ =
|
||||
std::make_unique<SearchEngineBaseURLTracker>(
|
||||
template_url_service, std::make_unique<UIThreadSearchTermsData>(),
|
||||
base::Bind(&BrowserInstantController::OnSearchEngineBaseURLChanged,
|
||||
base::Unretained(this)));
|
||||
base::BindRepeating(
|
||||
&BrowserInstantController::OnSearchEngineBaseURLChanged,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,9 +203,10 @@ void BrowserList::TryToCloseBrowserList(const BrowserVector& browsers_to_close,
|
||||
++it) {
|
||||
if ((*it)->TryToCloseWindow(
|
||||
skip_beforeunload,
|
||||
base::Bind(&BrowserList::PostTryToCloseBrowserWindow,
|
||||
browsers_to_close, on_close_success, on_close_aborted,
|
||||
profile_path, skip_beforeunload))) {
|
||||
base::BindRepeating(&BrowserList::PostTryToCloseBrowserWindow,
|
||||
browsers_to_close, on_close_success,
|
||||
on_close_aborted, profile_path,
|
||||
skip_beforeunload))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -51,11 +51,11 @@ void ChromeNSSCryptoModuleDelegate::ShowDialog(const std::string& slot_name,
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
ShowCryptoModulePasswordDialog(
|
||||
slot_name, retry, reason_, server_.host(),
|
||||
NULL, // TODO(mattm): Supply parent window.
|
||||
base::Bind(&ChromeNSSCryptoModuleDelegate::GotPassword,
|
||||
// RequestPassword is blocked on |event_| until GotPassword is
|
||||
// called, so there's no need to ref-count.
|
||||
base::Unretained(this)));
|
||||
nullptr, // TODO(mattm): Supply parent window.
|
||||
base::BindOnce(&ChromeNSSCryptoModuleDelegate::GotPassword,
|
||||
// RequestPassword is blocked on |event_| until GotPassword
|
||||
// is called, so there's no need to ref-count.
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
||||
void ChromeNSSCryptoModuleDelegate::GotPassword(const std::string& password) {
|
||||
|
@ -19,18 +19,18 @@ enum CryptoModulePasswordReason {
|
||||
kCryptoModulePasswordCertExport,
|
||||
};
|
||||
|
||||
typedef base::Callback<void(const std::string&)> CryptoModulePasswordCallback;
|
||||
typedef base::OnceCallback<void(const std::string&)>
|
||||
CryptoModulePasswordCallback;
|
||||
|
||||
// Display a dialog, prompting the user to authenticate to unlock
|
||||
// |module|. |reason| describes the purpose of the authentication and
|
||||
// affects the message displayed in the dialog. |hostname| is the hostname
|
||||
// of the server which requested the access.
|
||||
void ShowCryptoModulePasswordDialog(
|
||||
const std::string& module_name,
|
||||
bool retry,
|
||||
CryptoModulePasswordReason reason,
|
||||
const std::string& hostname,
|
||||
gfx::NativeWindow parent,
|
||||
const CryptoModulePasswordCallback& callback);
|
||||
void ShowCryptoModulePasswordDialog(const std::string& module_name,
|
||||
bool retry,
|
||||
CryptoModulePasswordReason reason,
|
||||
const std::string& hostname,
|
||||
gfx::NativeWindow parent,
|
||||
CryptoModulePasswordCallback callback);
|
||||
|
||||
#endif // CHROME_BROWSER_UI_CRYPTO_MODULE_PASSWORD_DIALOG_H_
|
||||
|
@ -69,7 +69,7 @@ void SlotUnlocker::Start() {
|
||||
ShowCryptoModulePasswordDialog(
|
||||
PK11_GetTokenName(modules_[current_].get()), retry_, reason_,
|
||||
server_.host(), parent_,
|
||||
base::Bind(&SlotUnlocker::GotPassword, base::Unretained(this)));
|
||||
base::BindOnce(&SlotUnlocker::GotPassword, base::Unretained(this)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -82,12 +82,12 @@ class EnableViaDialogFlow : public ExtensionEnableFlowDelegate {
|
||||
ExtensionRegistry* registry,
|
||||
Profile* profile,
|
||||
const std::string& extension_id,
|
||||
const base::Closure& callback)
|
||||
base::OnceClosure callback)
|
||||
: service_(service),
|
||||
registry_(registry),
|
||||
profile_(profile),
|
||||
extension_id_(extension_id),
|
||||
callback_(callback) {}
|
||||
callback_(std::move(callback)) {}
|
||||
|
||||
~EnableViaDialogFlow() override {}
|
||||
|
||||
@ -105,7 +105,7 @@ class EnableViaDialogFlow : public ExtensionEnableFlowDelegate {
|
||||
registry_->GetExtensionById(extension_id_, ExtensionRegistry::ENABLED);
|
||||
if (!extension)
|
||||
return;
|
||||
callback_.Run();
|
||||
std::move(callback_).Run();
|
||||
delete this;
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ class EnableViaDialogFlow : public ExtensionEnableFlowDelegate {
|
||||
ExtensionRegistry* registry_;
|
||||
Profile* profile_;
|
||||
std::string extension_id_;
|
||||
base::Closure callback_;
|
||||
base::OnceClosure callback_;
|
||||
std::unique_ptr<ExtensionEnableFlow> flow_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(EnableViaDialogFlow);
|
||||
@ -504,13 +504,12 @@ void OpenApplicationWithReenablePrompt(Profile* profile,
|
||||
if (!service->IsExtensionEnabled(extension->id()) ||
|
||||
registry->GetExtensionById(extension->id(),
|
||||
ExtensionRegistry::TERMINATED)) {
|
||||
base::Callback<gfx::NativeWindow(void)> dialog_parent_window_getter;
|
||||
// TODO(pkotwicz): Figure out which window should be used as the parent for
|
||||
// the "enable application" dialog in Athena.
|
||||
(new EnableViaDialogFlow(
|
||||
service, registry, profile, extension->id(),
|
||||
base::Bind(base::IgnoreResult(OpenEnabledApplication), profile,
|
||||
base::Passed(std::move(params)))))
|
||||
base::BindOnce(base::IgnoreResult(OpenEnabledApplication), profile,
|
||||
base::Passed(std::move(params)))))
|
||||
->Run();
|
||||
return;
|
||||
}
|
||||
|
@ -416,9 +416,10 @@ bool ExtensionActionViewController::TriggerPopupWithUrl(
|
||||
extensions_container_->CloseOverflowMenuIfOpen();
|
||||
extensions_container_->PopOutAction(
|
||||
this, show_action == SHOW_POPUP_AND_INSPECT,
|
||||
base::Bind(&ExtensionActionViewController::ShowPopup,
|
||||
weak_factory_.GetWeakPtr(), base::Passed(std::move(host)),
|
||||
grant_tab_permissions, show_action));
|
||||
base::BindOnce(&ExtensionActionViewController::ShowPopup,
|
||||
weak_factory_.GetWeakPtr(),
|
||||
base::Passed(std::move(host)), grant_tab_permissions,
|
||||
show_action));
|
||||
} else {
|
||||
ShowPopup(std::move(host), grant_tab_permissions, show_action);
|
||||
}
|
||||
|
@ -154,8 +154,8 @@ void ExtensionEnableFlow::CheckPermissionAndMaybePromptUser() {
|
||||
ExtensionInstallPrompt::PromptType type =
|
||||
ExtensionInstallPrompt::GetReEnablePromptTypeForExtension(profile_,
|
||||
extension);
|
||||
prompt_->ShowDialog(base::Bind(&ExtensionEnableFlow::InstallPromptDone,
|
||||
weak_ptr_factory_.GetWeakPtr()),
|
||||
prompt_->ShowDialog(base::BindOnce(&ExtensionEnableFlow::InstallPromptDone,
|
||||
weak_ptr_factory_.GetWeakPtr()),
|
||||
extension, nullptr,
|
||||
std::make_unique<ExtensionInstallPrompt::Prompt>(type),
|
||||
ExtensionInstallPrompt::GetDefaultShowDialogCallback());
|
||||
|
@ -117,10 +117,6 @@ class ExtensionEnableFlow : public content::NotificationObserver,
|
||||
// exclusive with |parent_contents_| above.
|
||||
gfx::NativeWindow parent_window_ = nullptr;
|
||||
|
||||
// Called to acquire a parent window for the prompt. This is used for clients
|
||||
// who only want to create a window if it is required.
|
||||
base::Callback<gfx::NativeWindow(void)> window_getter_;
|
||||
|
||||
std::unique_ptr<ExtensionInstallPrompt> prompt_;
|
||||
content::NotificationRegistrar registrar_;
|
||||
|
||||
|
@ -42,8 +42,8 @@ ExtensionInstalledWaiter::ExtensionInstalledWaiter(
|
||||
extensions::ExtensionRegistry::Get(browser->profile()));
|
||||
removal_watcher_ = std::make_unique<ExtensionRemovalWatcher>(
|
||||
browser, extension,
|
||||
base::Bind(&ExtensionInstalledWaiter::OnExtensionRemoved,
|
||||
weak_factory_.GetWeakPtr()));
|
||||
base::BindOnce(&ExtensionInstalledWaiter::OnExtensionRemoved,
|
||||
weak_factory_.GetWeakPtr()));
|
||||
}
|
||||
|
||||
ExtensionInstalledWaiter::~ExtensionInstalledWaiter() {
|
||||
|
@ -27,8 +27,9 @@ class SettingsOverriddenParamsProvidersUnitTest
|
||||
// exists.
|
||||
extensions::ExtensionWebUIOverrideRegistrar::GetFactoryInstance()
|
||||
->SetTestingFactoryAndUse(
|
||||
profile(), base::Bind([](content::BrowserContext* context)
|
||||
-> std::unique_ptr<KeyedService> {
|
||||
profile(),
|
||||
base::BindRepeating([](content::BrowserContext* context)
|
||||
-> std::unique_ptr<KeyedService> {
|
||||
return std::make_unique<
|
||||
extensions::ExtensionWebUIOverrideRegistrar>(context);
|
||||
}));
|
||||
|
@ -240,10 +240,10 @@ class MediaRouterViewsUITest : public ChromeRenderViewHostTestHarness {
|
||||
std::make_unique<PresentationRequestCallbacks>(expected_error);
|
||||
start_presentation_context_ = std::make_unique<StartPresentationContext>(
|
||||
presentation_request_,
|
||||
base::Bind(&PresentationRequestCallbacks::Success,
|
||||
base::Unretained(request_callbacks.get())),
|
||||
base::Bind(&PresentationRequestCallbacks::Error,
|
||||
base::Unretained(request_callbacks.get())));
|
||||
base::BindOnce(&PresentationRequestCallbacks::Success,
|
||||
base::Unretained(request_callbacks.get())),
|
||||
base::BindOnce(&PresentationRequestCallbacks::Error,
|
||||
base::Unretained(request_callbacks.get())));
|
||||
StartPresentationContext* context_ptr = start_presentation_context_.get();
|
||||
ui_->set_start_presentation_context_for_test(
|
||||
std::move(start_presentation_context_));
|
||||
|
@ -201,8 +201,8 @@ class PageInfoTest : public ChromeRenderViewHostTestHarness {
|
||||
mock_ui_ = std::make_unique<MockPageInfoUI>();
|
||||
// Use this rather than gmock's ON_CALL.WillByDefault(Invoke(... because
|
||||
// gmock doesn't handle move-only types well.
|
||||
mock_ui_->set_permission_info_callback_ =
|
||||
base::Bind(&PageInfoTest::SetPermissionInfo, base::Unretained(this));
|
||||
mock_ui_->set_permission_info_callback_ = base::BindRepeating(
|
||||
&PageInfoTest::SetPermissionInfo, base::Unretained(this));
|
||||
}
|
||||
|
||||
|
||||
@ -259,8 +259,8 @@ class PageInfoTest : public ChromeRenderViewHostTestHarness {
|
||||
incognito_web_contents_.get()));
|
||||
|
||||
incognito_mock_ui_ = std::make_unique<MockPageInfoUI>();
|
||||
incognito_mock_ui_->set_permission_info_callback_ =
|
||||
base::Bind(&PageInfoTest::SetPermissionInfo, base::Unretained(this));
|
||||
incognito_mock_ui_->set_permission_info_callback_ = base::BindRepeating(
|
||||
&PageInfoTest::SetPermissionInfo, base::Unretained(this));
|
||||
|
||||
auto delegate = std::make_unique<ChromePageInfoDelegate>(
|
||||
incognito_web_contents_.get());
|
||||
|
@ -41,12 +41,12 @@ std::tuple<ContentSetting, bool> DecodeCommandId(int encoded_command_id) {
|
||||
PermissionMenuModel::PermissionMenuModel(Profile* profile,
|
||||
const GURL& url,
|
||||
const PageInfo::PermissionInfo& info,
|
||||
const ChangeCallback& callback)
|
||||
ChangeCallback callback)
|
||||
: ui::SimpleMenuModel(this),
|
||||
host_content_settings_map_(
|
||||
HostContentSettingsMapFactory::GetForProfile(profile)),
|
||||
permission_(info),
|
||||
callback_(callback) {
|
||||
callback_(std::move(callback)) {
|
||||
DCHECK(!callback_.is_null());
|
||||
base::string16 label;
|
||||
|
||||
|
@ -18,13 +18,14 @@ class Profile;
|
||||
class PermissionMenuModel : public ui::SimpleMenuModel,
|
||||
public ui::SimpleMenuModel::Delegate {
|
||||
public:
|
||||
typedef base::Callback<void(const PageInfo::PermissionInfo&)> ChangeCallback;
|
||||
typedef base::RepeatingCallback<void(const PageInfo::PermissionInfo&)>
|
||||
ChangeCallback;
|
||||
|
||||
// Create a new menu model for permission settings.
|
||||
PermissionMenuModel(Profile* profile,
|
||||
const GURL& url,
|
||||
const PageInfo::PermissionInfo& info,
|
||||
const ChangeCallback& callback);
|
||||
ChangeCallback callback);
|
||||
~PermissionMenuModel() override;
|
||||
|
||||
// Overridden from ui::SimpleMenuModel::Delegate:
|
||||
|
@ -17,7 +17,8 @@ class TestCallback {
|
||||
TestCallback() : current_(-1) {}
|
||||
|
||||
PermissionMenuModel::ChangeCallback callback() {
|
||||
return base::Bind(&TestCallback::PermissionChanged, base::Unretained(this));
|
||||
return base::BindRepeating(&TestCallback::PermissionChanged,
|
||||
base::Unretained(this));
|
||||
}
|
||||
void PermissionChanged(const PageInfo::PermissionInfo& permission) {
|
||||
current_ = permission.setting;
|
||||
|
@ -530,7 +530,7 @@ void ManagePasswordsUIController::SavePassword(const base::string16& username,
|
||||
passwords_data_.client()->GetAccountPasswordStore(),
|
||||
Profile::FromBrowserContext(web_contents()->GetBrowserContext())
|
||||
->GetPrefs(),
|
||||
base::Bind(
|
||||
base::BindOnce(
|
||||
&ManagePasswordsUIController::OnTriggerPostSaveCompromisedBubble,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
|
||||
|
@ -298,18 +298,19 @@ PrefsTabHelper::PrefsTabHelper(WebContents* contents)
|
||||
ChromeZoomLevelPrefs* zoom_level_prefs =
|
||||
profile_to_track->GetZoomLevelPrefs();
|
||||
|
||||
base::Closure renderer_callback = base::Bind(
|
||||
&PrefsTabHelper::UpdateRendererPreferences, base::Unretained(this));
|
||||
// Tests should not need to create a ZoomLevelPrefs.
|
||||
if (zoom_level_prefs) {
|
||||
default_zoom_level_subscription_ =
|
||||
zoom_level_prefs->RegisterDefaultZoomLevelCallback(renderer_callback);
|
||||
zoom_level_prefs->RegisterDefaultZoomLevelCallback(
|
||||
base::BindRepeating(&PrefsTabHelper::UpdateRendererPreferences,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
||||
// Unretained is safe because the registrar will be scoped to this class.
|
||||
font_change_registrar_.Register(
|
||||
FontPrefChangeNotifierFactory::GetForProfile(profile_),
|
||||
base::Bind(&PrefsTabHelper::OnWebPrefChanged, base::Unretained(this)));
|
||||
base::BindRepeating(&PrefsTabHelper::OnWebPrefChanged,
|
||||
base::Unretained(this)));
|
||||
#endif // !defined(OS_ANDROID)
|
||||
|
||||
PrefWatcher::Get(profile_)->RegisterHelper(this);
|
||||
|
@ -21,8 +21,10 @@
|
||||
|
||||
class InstantController::TabObserver : public content::WebContentsObserver {
|
||||
public:
|
||||
TabObserver(content::WebContents* web_contents, const base::Closure& callback)
|
||||
: content::WebContentsObserver(web_contents), callback_(callback) {}
|
||||
TabObserver(content::WebContents* web_contents,
|
||||
base::RepeatingClosure callback)
|
||||
: content::WebContentsObserver(web_contents),
|
||||
callback_(std::move(callback)) {}
|
||||
~TabObserver() override = default;
|
||||
|
||||
private:
|
||||
@ -34,7 +36,7 @@ class InstantController::TabObserver : public content::WebContentsObserver {
|
||||
}
|
||||
}
|
||||
|
||||
base::Closure callback_;
|
||||
base::RepeatingClosure callback_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TabObserver);
|
||||
};
|
||||
@ -64,8 +66,9 @@ void InstantController::OnTabStripModelChanged(
|
||||
void InstantController::StartWatchingTab(content::WebContents* web_contents) {
|
||||
if (!tab_observer_ || tab_observer_->web_contents() != web_contents) {
|
||||
tab_observer_ = std::make_unique<TabObserver>(
|
||||
web_contents, base::Bind(&InstantController::UpdateInfoForInstantTab,
|
||||
base::Unretained(this)));
|
||||
web_contents,
|
||||
base::BindRepeating(&InstantController::UpdateInfoForInstantTab,
|
||||
base::Unretained(this)));
|
||||
// If this tab is an NTP, immediately send it the required info.
|
||||
if (search::IsInstantNTP(web_contents)) {
|
||||
UpdateInfoForInstantTab();
|
||||
|
@ -69,9 +69,9 @@ class LocalNTPOneGoogleBarSmokeTest : public InProcessBrowserTest {
|
||||
create_services_subscription_ =
|
||||
BrowserContextDependencyManager::GetInstance()
|
||||
->RegisterCreateServicesCallbackForTesting(
|
||||
base::Bind(&LocalNTPOneGoogleBarSmokeTest::
|
||||
OnWillCreateBrowserContextServices,
|
||||
base::Unretained(this)));
|
||||
base::BindRepeating(&LocalNTPOneGoogleBarSmokeTest::
|
||||
OnWillCreateBrowserContextServices,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
||||
static std::unique_ptr<KeyedService> CreateOneGoogleBarService(
|
||||
|
@ -94,8 +94,8 @@ class SearchEngineTabHelperBrowserTest : public InProcessBrowserTest {
|
||||
base::FilePath(),
|
||||
base::FilePath().AppendASCII("simple_open_search.xml"));
|
||||
embedded_test_server()->RegisterRequestHandler(
|
||||
base::Bind(&SearchEngineTabHelperBrowserTest::HandleRequest,
|
||||
base::Unretained(this), file_url));
|
||||
base::BindRepeating(&SearchEngineTabHelperBrowserTest::HandleRequest,
|
||||
base::Unretained(this), file_url));
|
||||
return embedded_test_server()->Start();
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ class ProfileColorsUtilTest : public testing::Test {
|
||||
// Instead of providing a random number generator, return an arbitrary value
|
||||
// and capture the count of options.
|
||||
GenerateNewProfileColorWithGenerator(
|
||||
*storage(), base::Bind(&CaptureCountAndReturnZero, &count), entry);
|
||||
*storage(), base::BindOnce(&CaptureCountAndReturnZero, &count), entry);
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ class ProfileColorsUtilTest : public testing::Test {
|
||||
// Instead of providing a random number generator, return the nth option
|
||||
// deterministically.
|
||||
return GenerateNewProfileColorWithGenerator(
|
||||
*storage(), base::Bind(&ReturnNth, n), entry)
|
||||
*storage(), base::BindOnce(&ReturnNth, n), entry)
|
||||
.id;
|
||||
}
|
||||
|
||||
|
@ -23,18 +23,22 @@ CryptoModulePasswordDialogView::CryptoModulePasswordDialogView(
|
||||
const std::string& slot_name,
|
||||
CryptoModulePasswordReason reason,
|
||||
const std::string& hostname,
|
||||
const CryptoModulePasswordCallback& callback)
|
||||
: callback_(callback) {
|
||||
CryptoModulePasswordCallback callback)
|
||||
: callback_(std::move(callback)) {
|
||||
SetButtonLabel(
|
||||
ui::DIALOG_BUTTON_OK,
|
||||
l10n_util::GetStringUTF16(IDS_CRYPTO_MODULE_AUTH_DIALOG_OK_BUTTON_LABEL));
|
||||
SetAcceptCallback(base::BindOnce(
|
||||
[](CryptoModulePasswordDialogView* dialog) {
|
||||
dialog->callback_.Run(
|
||||
base::UTF16ToUTF8(dialog->password_entry_->GetText()));
|
||||
std::move(dialog->callback_)
|
||||
.Run(base::UTF16ToUTF8(dialog->password_entry_->GetText()));
|
||||
},
|
||||
base::Unretained(this)));
|
||||
SetCancelCallback(base::BindOnce(
|
||||
[](CryptoModulePasswordDialogView* dialog) {
|
||||
std::move(dialog->callback_).Run(std::string());
|
||||
},
|
||||
base::Unretained(this)));
|
||||
SetCancelCallback(base::BindOnce(callback_, std::string()));
|
||||
set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType(
|
||||
views::TEXT, views::CONTROL));
|
||||
Init(hostname, slot_name, reason);
|
||||
@ -144,14 +148,13 @@ void CryptoModulePasswordDialogView::Init(const std::string& hostname,
|
||||
password_entry_ = layout->AddView(std::move(password_entry));
|
||||
}
|
||||
|
||||
void ShowCryptoModulePasswordDialog(
|
||||
const std::string& slot_name,
|
||||
bool retry,
|
||||
CryptoModulePasswordReason reason,
|
||||
const std::string& hostname,
|
||||
gfx::NativeWindow parent,
|
||||
const CryptoModulePasswordCallback& callback) {
|
||||
CryptoModulePasswordDialogView* dialog =
|
||||
new CryptoModulePasswordDialogView(slot_name, reason, hostname, callback);
|
||||
views::DialogDelegate::CreateDialogWidget(dialog, NULL, parent)->Show();
|
||||
void ShowCryptoModulePasswordDialog(const std::string& slot_name,
|
||||
bool retry,
|
||||
CryptoModulePasswordReason reason,
|
||||
const std::string& hostname,
|
||||
gfx::NativeWindow parent,
|
||||
CryptoModulePasswordCallback callback) {
|
||||
CryptoModulePasswordDialogView* dialog = new CryptoModulePasswordDialogView(
|
||||
slot_name, reason, hostname, std::move(callback));
|
||||
views::DialogDelegate::CreateDialogWidget(dialog, nullptr, parent)->Show();
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class CryptoModulePasswordDialogView : public views::DialogDelegateView,
|
||||
CryptoModulePasswordDialogView(const std::string& slot_name,
|
||||
CryptoModulePasswordReason reason,
|
||||
const std::string& server,
|
||||
const CryptoModulePasswordCallback& callback);
|
||||
CryptoModulePasswordCallback callback);
|
||||
|
||||
~CryptoModulePasswordDialogView() override;
|
||||
|
||||
@ -54,7 +54,7 @@ class CryptoModulePasswordDialogView : public views::DialogDelegateView,
|
||||
views::Label* password_label_;
|
||||
views::Textfield* password_entry_;
|
||||
|
||||
const CryptoModulePasswordCallback callback_;
|
||||
CryptoModulePasswordCallback callback_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CryptoModulePasswordDialogView);
|
||||
};
|
||||
|
@ -17,9 +17,10 @@
|
||||
using CryptoModulePasswordDialogViewTest = ChromeViewsTestBase;
|
||||
|
||||
std::unique_ptr<CryptoModulePasswordDialogView> CreateCryptoDialog(
|
||||
const CryptoModulePasswordCallback& callback) {
|
||||
CryptoModulePasswordCallback callback) {
|
||||
return std::make_unique<CryptoModulePasswordDialogView>(
|
||||
"slot", kCryptoModulePasswordCertEnrollment, "server", callback);
|
||||
"slot", kCryptoModulePasswordCertEnrollment, "server",
|
||||
std::move(callback));
|
||||
}
|
||||
|
||||
TEST_F(CryptoModulePasswordDialogViewTest, AcceptUsesPassword) {
|
||||
|
Reference in New Issue
Block a user