Skip to content

Commit

Permalink
Rename CancelActiveAndPendingDialogs to CancelDialogs.
Browse files Browse the repository at this point in the history
Update name to use the same naming scheme as //content.

BUG=none

Review-Url: https://codereview.chromium.org/2454333003
Cr-Commit-Position: refs/heads/master@{#428418}
  • Loading branch information
michaeldo1 authored and Commit bot committed Oct 28, 2016
1 parent a88d285 commit 853b405
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions ios/web/public/java_script_dialog_presenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class JavaScriptDialogPresenter {
// |callback| even if they choose not to present the dialog.
virtual void RunJavaScriptDialog(WebState* web_state,
const GURL& origin_url,
JavaScriptDialogType java_script_dialog_type,
JavaScriptDialogType dialog_type,
NSString* message_text,
NSString* default_prompt_text,
const DialogClosedCallback& callback) = 0;
// Informs clients that all requested dialogs associated with |web_state|
// should be dismissed.
virtual void CancelActiveAndPendingDialogs(WebState* web_state) = 0;
virtual void CancelDialogs(WebState* web_state) = 0;
};

} // namespace web
Expand Down
6 changes: 3 additions & 3 deletions ios/web/web_state/ui/crw_web_controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ - (void)dismissModals {

// Caller must reset the delegate before calling.
- (void)close {
_webStateImpl->CancelActiveAndPendingDialogs();
_webStateImpl->CancelDialogs();

_SSLStatusUpdater.reset();

Expand Down Expand Up @@ -4771,7 +4771,7 @@ - (void)removeWebViewAllowingCachedReconstruction:(BOOL)allowCache {
SEL cancelDialogsSelector = @selector(cancelDialogsForWebController:);
if ([self.UIDelegate respondsToSelector:cancelDialogsSelector])
[self.UIDelegate cancelDialogsForWebController:self];
_webStateImpl->CancelActiveAndPendingDialogs();
_webStateImpl->CancelDialogs();

if (allowCache)
_expectedReconstructionURL = [self currentNavigationURL];
Expand All @@ -4790,7 +4790,7 @@ - (void)webViewWebProcessDidCrash {
SEL cancelDialogsSelector = @selector(cancelDialogsForWebController:);
if ([self.UIDelegate respondsToSelector:cancelDialogsSelector])
[self.UIDelegate cancelDialogsForWebController:self];
_webStateImpl->CancelActiveAndPendingDialogs();
_webStateImpl->CancelDialogs();

SEL rendererCrashSelector = @selector(webControllerWebProcessDidCrash:);
if ([self.delegate respondsToSelector:rendererCrashSelector])
Expand Down
2 changes: 1 addition & 1 deletion ios/web/web_state/web_state_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class WebStateImpl : public WebState, public NavigationManagerDelegate {
const DialogClosedCallback& callback);

// Cancels all dialogs associated with this web_state.
void CancelActiveAndPendingDialogs();
void CancelDialogs();

// NavigationManagerDelegate:
void NavigateToPendingEntry() override;
Expand Down
4 changes: 2 additions & 2 deletions ios/web/web_state/web_state_impl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,12 @@
message_text, default_prompt_text, callback);
}

void WebStateImpl::CancelActiveAndPendingDialogs() {
void WebStateImpl::CancelDialogs() {
if (delegate_) {
JavaScriptDialogPresenter* presenter =
delegate_->GetJavaScriptDialogPresenter(this);
if (presenter) {
presenter->CancelActiveAndPendingDialogs(this);
presenter->CancelDialogs(this);
}
}
}
Expand Down
24 changes: 10 additions & 14 deletions ios/web/web_state/web_state_impl_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,10 @@ bool HandleContextMenu(WebState* source,
class TestJavaScriptDialogPresenter : public JavaScriptDialogPresenter {
public:
TestJavaScriptDialogPresenter()
: cancel_active_and_pending_dialogs_called_(false),
run_java_script_dialog_called_(false) {}
: cancel_dialogs_called_(false), run_java_script_dialog_called_(false) {}

// True if the JavaScriptDialogPresenter CancelActiveAndPendingDialogs method
// has been called.
bool cancel_active_and_pending_dialogs_called() const {
return cancel_active_and_pending_dialogs_called_;
}
// True if the JavaScriptDialogPresenter CancelDialogs method has been called.
bool cancel_dialogs_called() const { return cancel_dialogs_called_; }

// True if the JavaScriptDialogPresenter RunJavaScriptDialog method has been
// called.
Expand All @@ -199,11 +195,11 @@ void RunJavaScriptDialog(WebState* web_state,
callback.Run(false, nil);
}

void CancelActiveAndPendingDialogs(WebState* web_state) override {
cancel_active_and_pending_dialogs_called_ = true;
void CancelDialogs(WebState* web_state) override {
cancel_dialogs_called_ = true;
}

bool cancel_active_and_pending_dialogs_called_;
bool cancel_dialogs_called_;
bool run_java_script_dialog_called_;
};

Expand Down Expand Up @@ -515,7 +511,7 @@ void LoadHtml(std::string html) {

EXPECT_FALSE(delegate.get_java_script_dialog_presenter_called());
EXPECT_FALSE(presenter.run_java_script_dialog_called());
EXPECT_FALSE(presenter.cancel_active_and_pending_dialogs_called());
EXPECT_FALSE(presenter.cancel_dialogs_called());

__block bool callback_called = false;
web_state_->RunJavaScriptDialog(GURL(), JAVASCRIPT_DIALOG_TYPE_ALERT, @"",
Expand All @@ -527,9 +523,9 @@ void LoadHtml(std::string html) {
EXPECT_TRUE(presenter.run_java_script_dialog_called());
EXPECT_TRUE(callback_called);

EXPECT_FALSE(presenter.cancel_active_and_pending_dialogs_called());
web_state_->CancelActiveAndPendingDialogs();
EXPECT_TRUE(presenter.cancel_active_and_pending_dialogs_called());
EXPECT_FALSE(presenter.cancel_dialogs_called());
web_state_->CancelDialogs();
EXPECT_TRUE(presenter.cancel_dialogs_called());
}

// Verifies that GlobalWebStateObservers are called when expected.
Expand Down

0 comments on commit 853b405

Please sign in to comment.