Commit 4ace5d8e authored by eugenebut's avatar eugenebut Committed by Commit bot

[ios] Made IDC_BACK and IDC_FORWARD safe.

NavigationManager's GoBack() and GoForward() crash if navigation is not
possible. This mirrors NavigationController's behavior so
NavigationManager should only be changed along with
NavigationController.

KeyCommandsProvider sends IDC_FORWARD and IDC_BACK commands without
checking that navigation is possible and app crashes.

There are 2 fully correct options to fix this bug:
1.) Change NavigationManager and NavigationController, so they don't
    crash (which has both pros and cons).
2.) Change KeyCommandsProvider, so it does not send IDC_FORWARD,
    IDC_BACK commands if navigation is not possible.

Correct fix will be tracked in a separate bug (crbug.com/677160), and
this CL simply fixes a crash in the most simplest way w/o touching
Tab class (which will be removed).

BUG=676727

Review-Url: https://codereview.chromium.org/2605713002
Cr-Commit-Position: refs/heads/master@{#440773}
parent 5eb9ee95
......@@ -3872,7 +3872,10 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver {
switch (command) {
case IDC_BACK:
[[_model currentTab] goBack];
// TODO(crbug.com.677160): Remove |canGoBack| check.
if ([_model currentTab].canGoBack) {
[[_model currentTab] goBack];
}
break;
case IDC_BOOKMARK_PAGE:
[self initializeBookmarkInteractionController];
......@@ -3913,7 +3916,10 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver {
[self searchFindInPage];
break;
case IDC_FORWARD:
[[_model currentTab] goForward];
// TODO(crbug.com.677160): Remove |canGoForward| check.
if ([_model currentTab].canGoForward) {
[[_model currentTab] goForward];
}
break;
case IDC_FULLSCREEN:
NOTIMPLEMENTED();
......
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