| 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 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 ///////////////////////////////////////////////////////////////////////////// | 6 ///////////////////////////////////////////////////////////////////////////// |
| 7 // OptionsPage class: | 7 // OptionsPage class: |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Base class for options page. | 10 * Base class for options page. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 OptionsPage.registeredPages = {}; | 37 OptionsPage.registeredPages = {}; |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * Pages which are meant to behave like modal dialogs. Maps lower-case overlay | 40 * Pages which are meant to behave like modal dialogs. Maps lower-case overlay |
| 41 * names to the respective overlay object. | 41 * names to the respective overlay object. |
| 42 * @protected | 42 * @protected |
| 43 */ | 43 */ |
| 44 OptionsPage.registeredOverlayPages = {}; | 44 OptionsPage.registeredOverlayPages = {}; |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * Whether or not |initialize| has been called. | |
| 48 * @private | |
| 49 */ | |
| 50 OptionsPage.initialized_ = false; | |
| 51 | |
| 52 /** | |
| 53 * Gets the default page (to be shown on initial load). | 47 * Gets the default page (to be shown on initial load). |
| 54 */ | 48 */ |
| 55 OptionsPage.getDefaultPage = function() { | 49 OptionsPage.getDefaultPage = function() { |
| 56 return BrowserOptions.getInstance(); | 50 return BrowserOptions.getInstance(); |
| 57 }; | 51 }; |
| 58 | 52 |
| 59 /** | 53 /** |
| 60 * Shows the default page. | 54 * Shows the default page. |
| 61 */ | 55 */ |
| 62 OptionsPage.showDefaultPage = function() { | 56 OptionsPage.showDefaultPage = function() { |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 if (topPage) | 529 if (topPage) |
| 536 this.setRootPageFrozen_(topPage.isOverlay); | 530 this.setRootPageFrozen_(topPage.isOverlay); |
| 537 }; | 531 }; |
| 538 | 532 |
| 539 /** | 533 /** |
| 540 * Initializes the complete options page. This will cause all C++ handlers to | 534 * Initializes the complete options page. This will cause all C++ handlers to |
| 541 * be invoked to do final setup. | 535 * be invoked to do final setup. |
| 542 */ | 536 */ |
| 543 OptionsPage.initialize = function() { | 537 OptionsPage.initialize = function() { |
| 544 chrome.send('coreOptionsInitialize'); | 538 chrome.send('coreOptionsInitialize'); |
| 545 this.initialized_ = true; | |
| 546 uber.onContentFrameLoaded(); | 539 uber.onContentFrameLoaded(); |
| 547 | 540 |
| 548 document.addEventListener('scroll', this.handleScroll_.bind(this)); | 541 document.addEventListener('scroll', this.handleScroll_.bind(this)); |
| 549 | 542 |
| 550 // Trigger the scroll handler manually to set the initial state. | 543 // Trigger the scroll handler manually to set the initial state. |
| 551 this.handleScroll_(); | 544 this.handleScroll_(); |
| 552 | 545 |
| 553 // Shake the dialog if the user clicks outside the dialog bounds. | 546 // Shake the dialog if the user clicks outside the dialog bounds. |
| 554 var containers = [$('overlay-container-1'), $('overlay-container-2')]; | 547 var containers = [$('overlay-container-1'), $('overlay-container-2')]; |
| 555 for (var i = 0; i < containers.length; i++) { | 548 for (var i = 0; i < containers.length; i++) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 OptionsPage.setClearPluginLSODataEnabled = function(enabled) { | 601 OptionsPage.setClearPluginLSODataEnabled = function(enabled) { |
| 609 if (enabled) { | 602 if (enabled) { |
| 610 document.documentElement.setAttribute( | 603 document.documentElement.setAttribute( |
| 611 'flashPluginSupportsClearSiteData', ''); | 604 'flashPluginSupportsClearSiteData', ''); |
| 612 } else { | 605 } else { |
| 613 document.documentElement.removeAttribute( | 606 document.documentElement.removeAttribute( |
| 614 'flashPluginSupportsClearSiteData'); | 607 'flashPluginSupportsClearSiteData'); |
| 615 } | 608 } |
| 616 }; | 609 }; |
| 617 | 610 |
| 618 /** | |
| 619 * Re-initializes the C++ handlers if necessary. This is called if the | |
| 620 * handlers are torn down and recreated but the DOM may not have been (in | |
| 621 * which case |initialize| won't be called again). If |initialize| hasn't been | |
| 622 * called, this does nothing (since it will be later, once the DOM has | |
| 623 * finished loading). | |
| 624 */ | |
| 625 OptionsPage.reinitializeCore = function() { | |
| 626 if (this.initialized_) | |
| 627 chrome.send('coreOptionsInitialize'); | |
| 628 }; | |
| 629 | |
| 630 OptionsPage.prototype = { | 611 OptionsPage.prototype = { |
| 631 __proto__: cr.EventTarget.prototype, | 612 __proto__: cr.EventTarget.prototype, |
| 632 | 613 |
| 633 /** | 614 /** |
| 634 * The parent page of this option page, or null for top-level pages. | 615 * The parent page of this option page, or null for top-level pages. |
| 635 * @type {OptionsPage} | 616 * @type {OptionsPage} |
| 636 */ | 617 */ |
| 637 parentPage: null, | 618 parentPage: null, |
| 638 | 619 |
| 639 /** | 620 /** |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 canShowPage: function() { | 856 canShowPage: function() { |
| 876 return true; | 857 return true; |
| 877 }, | 858 }, |
| 878 }; | 859 }; |
| 879 | 860 |
| 880 // Export | 861 // Export |
| 881 return { | 862 return { |
| 882 OptionsPage: OptionsPage | 863 OptionsPage: OptionsPage |
| 883 }; | 864 }; |
| 884 }); | 865 }); |
| OLD | NEW |