OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 * Base class that Ribbon uses to display photos. | 6 * Base class that Ribbon uses to display photos. |
7 */ | 7 */ |
8 | 8 |
9 function RibbonClient() {} | 9 function RibbonClient() {} |
10 | 10 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 this.editor_.trackWindow(doc.defaultView); | 220 this.editor_.trackWindow(doc.defaultView); |
221 | 221 |
222 if (shareActions.length > 0) { | 222 if (shareActions.length > 0) { |
223 this.shareMode_ = new ShareMode( | 223 this.shareMode_ = new ShareMode( |
224 this.editor_, this.container_, this.toolbar_, shareActions, | 224 this.editor_, this.container_, this.toolbar_, shareActions, |
225 this.onShare_.bind(this), this.onActionExecute_.bind(this), | 225 this.onShare_.bind(this), this.onActionExecute_.bind(this), |
226 this.displayStringFunction_); | 226 this.displayStringFunction_); |
227 } else { | 227 } else { |
228 this.shareMode_ = null; | 228 this.shareMode_ = null; |
229 } | 229 } |
| 230 |
| 231 Gallery.getFileBrowserPrivate().isFullscreen(function(fullscreen) { |
| 232 this.originalFullscreen_ = fullscreen; |
| 233 }.bind(this)); |
230 }; | 234 }; |
231 | 235 |
232 Gallery.blobToURL_ = function(blob) { | 236 Gallery.blobToURL_ = function(blob) { |
233 // Append a file name after an anchor so that the Gallery | 237 // Append a file name after an anchor so that the Gallery |
234 // code can find the file extension at the end of the url. | 238 // code can find the file extension at the end of the url. |
235 // A File instance contains the real file name in the 'name' property. | 239 // A File instance contains the real file name in the 'name' property. |
236 // For a Blob instance we make up a fake file name out of the mime type | 240 // For a Blob instance we make up a fake file name out of the mime type |
237 // (image/jpeg -> image.jpg). | 241 // (image/jpeg -> image.jpg). |
238 return window.webkitURL.createObjectURL(blob) + | 242 return window.webkitURL.createObjectURL(blob) + |
239 '#' + (blob.name || (blob.type.replace('/', '.'))); | 243 '#' + (blob.name || (blob.type.replace('/', '.'))); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 } | 432 } |
429 | 433 |
430 dir.getFile(newName, {create: false, exclusive: false}, | 434 dir.getFile(newName, {create: false, exclusive: false}, |
431 onVictimFound, doRename); | 435 onVictimFound, doRename); |
432 }; | 436 }; |
433 | 437 |
434 Gallery.prototype.isRenaming_ = function() { | 438 Gallery.prototype.isRenaming_ = function() { |
435 return this.container_.hasAttribute('renaming'); | 439 return this.container_.hasAttribute('renaming'); |
436 }; | 440 }; |
437 | 441 |
438 Gallery.prototype.toggleFullscreen_ = function() { | 442 Gallery.getFileBrowserPrivate = function() { |
439 if (this.document_.webkitIsFullScreen) { | 443 return chrome.fileBrowserPrivate || window.top.chrome.fileBrowserPrivate; |
440 this.document_.webkitCancelFullScreen(); | |
441 } else { | |
442 this.document_.body.webkitRequestFullScreen(); | |
443 } | |
444 }; | 444 }; |
445 | 445 |
| 446 Gallery.prototype.toggleFullscreen_ = function() { |
| 447 Gallery.getFileBrowserPrivate().toggleFullscreen(); |
| 448 }; |
| 449 |
| 450 /** |
| 451 * Close the Gallery. |
| 452 */ |
| 453 Gallery.prototype.close_ = function() { |
| 454 Gallery.getFileBrowserPrivate().isFullscreen(function(fullscreen) { |
| 455 if (this.originalFullscreen_ != fullscreen) { |
| 456 Gallery.getFileBrowserPrivate().toggleFullscreen(); |
| 457 } |
| 458 this.closeCallback_(); |
| 459 }.bind(this)); |
| 460 }; |
| 461 |
| 462 /** |
| 463 * Handle user's 'Close' action (Escape or a click on the X icon). |
| 464 */ |
446 Gallery.prototype.onClose_ = function() { | 465 Gallery.prototype.onClose_ = function() { |
447 if (this.document_.webkitIsFullScreen) { | |
448 // Closing the Gallery iframe while in full screen will crash the tab. | |
449 this.document_.addEventListener( | |
450 'webkitfullscreenchange', this.onClose_.bind(this)); | |
451 this.document_.webkitCancelFullScreen(); | |
452 return; | |
453 } | |
454 // TODO: handle write errors gracefully (suggest retry or saving elsewhere). | 466 // TODO: handle write errors gracefully (suggest retry or saving elsewhere). |
455 this.saveChanges_(this.closeCallback_); | 467 this.saveChanges_(this.close_.bind(this)); |
456 }; | 468 }; |
457 | 469 |
458 Gallery.prototype.prefetchImage = function(id, content, metadata) { | 470 Gallery.prototype.prefetchImage = function(id, content, metadata) { |
459 this.editor_.prefetchImage(id, content, metadata); | 471 this.editor_.prefetchImage(id, content, metadata); |
460 }; | 472 }; |
461 | 473 |
462 Gallery.prototype.openImage = function(id, content, metadata, slide, callback) { | 474 Gallery.prototype.openImage = function(id, content, metadata, slide, callback) { |
463 // The first change is load, we should not count it. | 475 // The first change is load, we should not count it. |
464 this.imageChanges_ = -1; | 476 this.imageChanges_ = -1; |
465 | 477 |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 ShareMode.prototype.setUp = function() { | 1269 ShareMode.prototype.setUp = function() { |
1258 ImageEditor.Mode.prototype.setUp.apply(this, arguments); | 1270 ImageEditor.Mode.prototype.setUp.apply(this, arguments); |
1259 ImageUtil.setAttribute(this.menu_, 'hidden', false); | 1271 ImageUtil.setAttribute(this.menu_, 'hidden', false); |
1260 ImageUtil.setAttribute(this.button_, 'pressed', false); | 1272 ImageUtil.setAttribute(this.button_, 'pressed', false); |
1261 }; | 1273 }; |
1262 | 1274 |
1263 ShareMode.prototype.cleanUpUI = function() { | 1275 ShareMode.prototype.cleanUpUI = function() { |
1264 ImageEditor.Mode.prototype.cleanUpUI.apply(this, arguments); | 1276 ImageEditor.Mode.prototype.cleanUpUI.apply(this, arguments); |
1265 ImageUtil.setAttribute(this.menu_, 'hidden', true); | 1277 ImageUtil.setAttribute(this.menu_, 'hidden', true); |
1266 }; | 1278 }; |
OLD | NEW |