Index: chrome/browser/resources/pdf/toolbar_manager.js |
diff --git a/chrome/browser/resources/pdf/toolbar_manager.js b/chrome/browser/resources/pdf/toolbar_manager.js |
index a8b6519d3ecdc7fdcc22b3b10235565ec683974f..eaa3ac5dd519deec4f511093692c65bc3aa468f8 100644 |
--- a/chrome/browser/resources/pdf/toolbar_manager.js |
+++ b/chrome/browser/resources/pdf/toolbar_manager.js |
@@ -71,13 +71,14 @@ ToolbarManager.prototype = { |
* loaded and we are ready to show a document. |
*/ |
enableToolbars: function() { |
- this.toolbar_.hidden = false; |
+ if (this.toolbar_) |
+ this.toolbar_.hidden = false; |
this.zoomToolbar_.hidden = false; |
this.resizeDropdowns_(); |
}, |
showToolbarsForMouseMove: function(e) { |
- this.isMouseNearTopToolbar_ = isMouseNearTopToolbar(e); |
+ this.isMouseNearTopToolbar_ = this.toolbar_ && isMouseNearTopToolbar(e); |
this.isMouseNearSideToolbar_ = isMouseNearSideToolbar(e); |
// Allow the top toolbar to be shown if the mouse moves away from the side |
@@ -105,7 +106,8 @@ ToolbarManager.prototype = { |
* Display both UI toolbars. |
*/ |
showToolbars: function() { |
- this.toolbar_.show(); |
+ if (this.toolbar_) |
+ this.toolbar_.show(); |
this.zoomToolbar_.show(); |
}, |
@@ -115,11 +117,15 @@ ToolbarManager.prototype = { |
* elements. |
*/ |
hideToolbarsIfAllowed: function() { |
- if (!(this.isMouseNearTopToolbar_ || this.isMouseNearSideToolbar_ || |
- this.toolbar_.shouldKeepOpen())) { |
+ if (this.isMouseNearSideToolbar_ || this.isMouseNearTopToolbar_) |
+ return; |
+ |
+ if (this.toolbar_ && this.toolbar_.shouldKeepOpen()) |
+ return; |
+ |
+ if (this.toolbar_) |
this.toolbar_.hide(); |
- this.zoomToolbar_.hide(); |
- } |
+ this.zoomToolbar_.hide(); |
}, |
/** |
@@ -137,7 +143,7 @@ ToolbarManager.prototype = { |
* hides the basic toolbars otherwise. |
*/ |
hideSingleToolbarLayer: function() { |
- if (!this.toolbar_.hideDropdowns()) |
+ if (!this.toolbar_ || !this.toolbar_.hideDropdowns()) |
this.hideToolbarsIfAllowed(); |
}, |
@@ -150,6 +156,8 @@ ToolbarManager.prototype = { |
* of the screen. |
*/ |
forceHideTopToolbar: function() { |
+ if (!this.toolbar_) |
+ return; |
this.toolbar_.hide(); |
this.sideToolbarAllowedOnly_ = true; |
this.sideToolbarAllowedOnlyTimer_ = this.window_.setTimeout(function() { |
@@ -163,6 +171,8 @@ ToolbarManager.prototype = { |
* @private |
*/ |
resizeDropdowns_: function() { |
+ if (!this.toolbar_) |
+ return; |
var lowerBound = this.window_.innerHeight - this.zoomToolbar_.clientHeight; |
this.toolbar_.setDropdownLowerBound(lowerBound); |
} |