diff options
author | paulmeyer <paulmeyer@chromium.org> | 2014-10-09 07:37:16 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-09 14:37:33 +0000 |
commit | 82e31991f1597daae41b8fc54edcddedac83aacb (patch) | |
tree | ad8c320ee3f64ffefc6dc27409d182bf65fb930e /extensions/browser/guest_view | |
parent | 8012df46f572e5a7bc2f33ff41e5d470e0da8a69 (diff) | |
download | chromium_src-82e31991f1597daae41b8fc54edcddedac83aacb.zip chromium_src-82e31991f1597daae41b8fc54edcddedac83aacb.tar.gz chromium_src-82e31991f1597daae41b8fc54edcddedac83aacb.tar.bz2 |
Added optional callbacks to webview.go(), webview.back(), and webview.forward().
The callback have a single parameter, "success", that indicates whether the navigation was successful. Previously, there was no way to check if these API functions actually resulted in navigation when called (for instance, when calling webview.back() when there is no page to go back to).
Review URL: https://codereview.chromium.org/638193002
Cr-Commit-Position: refs/heads/master@{#298877}
Diffstat (limited to 'extensions/browser/guest_view')
-rw-r--r-- | extensions/browser/guest_view/web_view/web_view_guest.cc | 9 | ||||
-rw-r--r-- | extensions/browser/guest_view/web_view/web_view_guest.h | 4 |
2 files changed, 9 insertions, 4 deletions
diff --git a/extensions/browser/guest_view/web_view/web_view_guest.cc b/extensions/browser/guest_view/web_view/web_view_guest.cc index eb1bd4e..0d9a161 100644 --- a/extensions/browser/guest_view/web_view/web_view_guest.cc +++ b/extensions/browser/guest_view/web_view/web_view_guest.cc @@ -600,8 +600,13 @@ void WebViewGuest::StopFinding(content::StopFindAction action) { web_contents()->StopFinding(action); } -void WebViewGuest::Go(int relative_index) { - web_contents()->GetController().GoToOffset(relative_index); +bool WebViewGuest::Go(int relative_index) { + content::NavigationController& controller = web_contents()->GetController(); + if (!controller.CanGoToOffset(relative_index)) + return false; + + controller.GoToOffset(relative_index); + return true; } void WebViewGuest::Reload() { diff --git a/extensions/browser/guest_view/web_view/web_view_guest.h b/extensions/browser/guest_view/web_view/web_view_guest.h index 63cf750..8b3c8e7 100644 --- a/extensions/browser/guest_view/web_view/web_view_guest.h +++ b/extensions/browser/guest_view/web_view/web_view_guest.h @@ -185,8 +185,8 @@ class WebViewGuest : public GuestView<WebViewGuest>, void StopFinding(content::StopFindAction); // If possible, navigate the guest to |relative_index| entries away from the - // current navigation entry. - void Go(int relative_index); + // current navigation entry. Returns true on success. + bool Go(int relative_index); // Reload the guest. void Reload(); |