Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: chrome/browser/resources/options/content_settings.js

Issue 410293004: Split OptionsPage into Page and PageManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed feedback Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 /** @const */ var OptionsPage = options.OptionsPage; 6 /** @const */ var Page = cr.ui.pageManager.Page;
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager;
7 8
8 ////////////////////////////////////////////////////////////////////////////// 9 //////////////////////////////////////////////////////////////////////////////
9 // ContentSettings class: 10 // ContentSettings class:
10 11
11 /** 12 /**
12 * Encapsulated handling of content settings page. 13 * Encapsulated handling of content settings page.
13 * @constructor 14 * @constructor
14 */ 15 */
15 function ContentSettings() { 16 function ContentSettings() {
16 this.activeNavTab = null; 17 this.activeNavTab = null;
17 OptionsPage.call(this, 'content', 18 Page.call(this, 'content',
18 loadTimeData.getString('contentSettingsPageTabTitle'), 19 loadTimeData.getString('contentSettingsPageTabTitle'),
19 'content-settings-page'); 20 'content-settings-page');
20 } 21 }
21 22
22 cr.addSingletonGetter(ContentSettings); 23 cr.addSingletonGetter(ContentSettings);
23 24
24 ContentSettings.prototype = { 25 ContentSettings.prototype = {
25 __proto__: OptionsPage.prototype, 26 __proto__: Page.prototype,
26 27
27 initializePage: function() { 28 initializePage: function() {
28 OptionsPage.prototype.initializePage.call(this); 29 Page.prototype.initializePage.call(this);
29 30
30 var exceptionsButtons = 31 var exceptionsButtons =
31 this.pageDiv.querySelectorAll('.exceptions-list-button'); 32 this.pageDiv.querySelectorAll('.exceptions-list-button');
32 for (var i = 0; i < exceptionsButtons.length; i++) { 33 for (var i = 0; i < exceptionsButtons.length; i++) {
33 exceptionsButtons[i].onclick = function(event) { 34 exceptionsButtons[i].onclick = function(event) {
34 var page = ContentSettingsExceptionsArea.getInstance(); 35 var page = ContentSettingsExceptionsArea.getInstance();
35 36
36 // Add on the proper hash for the content type, and store that in the 37 // Add on the proper hash for the content type, and store that in the
37 // history so back/forward and tab restore works. 38 // history so back/forward and tab restore works.
38 var hash = event.currentTarget.getAttribute('contentType'); 39 var hash = event.currentTarget.getAttribute('contentType');
39 var url = page.name + '#' + hash; 40 var url = page.name + '#' + hash;
40 uber.pushState({pageName: page.name}, url); 41 uber.pushState({pageName: page.name}, url);
41 42
42 // Navigate after the local history has been replaced in order to have 43 // Navigate after the local history has been replaced in order to have
43 // the correct hash loaded. 44 // the correct hash loaded.
44 OptionsPage.showPageByName('contentExceptions', false); 45 PageManager.showPageByName('contentExceptions', false);
45 }; 46 };
46 } 47 }
47 48
48 var manageHandlersButton = $('manage-handlers-button'); 49 var manageHandlersButton = $('manage-handlers-button');
49 if (manageHandlersButton) { 50 if (manageHandlersButton) {
50 manageHandlersButton.onclick = function(event) { 51 manageHandlersButton.onclick = function(event) {
51 OptionsPage.navigateToPage('handlers'); 52 PageManager.showPageByName('handlers');
52 }; 53 };
53 } 54 }
54 55
55 if (cr.isChromeOS) { 56 if (cr.isChromeOS) {
56 // Disable some controls for Guest in Chrome OS. 57 // Disable some controls for Guest in Chrome OS.
57 UIAccountTweaks.applyGuestSessionVisibility(document); 58 UIAccountTweaks.applyGuestSessionVisibility(document);
58 59
59 // Disable some controls for Public session in Chrome OS. 60 // Disable some controls for Public session in Chrome OS.
60 UIAccountTweaks.applyPublicSessionVisibility(document); 61 UIAccountTweaks.applyPublicSessionVisibility(document);
61 } 62 }
62 63
63 // Cookies filter page --------------------------------------------------- 64 // Cookies filter page ---------------------------------------------------
64 $('show-cookies-button').onclick = function(event) { 65 $('show-cookies-button').onclick = function(event) {
65 chrome.send('coreOptionsUserMetricsAction', ['Options_ShowCookies']); 66 chrome.send('coreOptionsUserMetricsAction', ['Options_ShowCookies']);
66 OptionsPage.navigateToPage('cookies'); 67 PageManager.showPageByName('cookies');
67 }; 68 };
68 69
69 $('content-settings-overlay-confirm').onclick = 70 $('content-settings-overlay-confirm').onclick =
70 OptionsPage.closeOverlay.bind(OptionsPage); 71 PageManager.closeOverlay.bind(PageManager);
71 72
72 $('media-pepper-flash-default').hidden = true; 73 $('media-pepper-flash-default').hidden = true;
73 $('media-pepper-flash-exceptions').hidden = true; 74 $('media-pepper-flash-exceptions').hidden = true;
74 75
75 $('media-select-mic').addEventListener('change', 76 $('media-select-mic').addEventListener('change',
76 ContentSettings.setDefaultMicrophone_); 77 ContentSettings.setDefaultMicrophone_);
77 $('media-select-camera').addEventListener('change', 78 $('media-select-camera').addEventListener('change',
78 ContentSettings.setDefaultCamera_); 79 ContentSettings.setDefaultCamera_);
79 }, 80 },
80 }; 81 };
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 $('media-stream-ask-label').innerHTML = 138 $('media-stream-ask-label').innerHTML =
138 loadTimeData.getString(mediaSettings.askText); 139 loadTimeData.getString(mediaSettings.askText);
139 $('media-stream-block-label').innerHTML = 140 $('media-stream-block-label').innerHTML =
140 loadTimeData.getString(mediaSettings.blockText); 141 loadTimeData.getString(mediaSettings.blockText);
141 142
142 if (mediaSettings.micDisabled) 143 if (mediaSettings.micDisabled)
143 $('media-select-mic').disabled = true; 144 $('media-select-mic').disabled = true;
144 if (mediaSettings.cameraDisabled) 145 if (mediaSettings.cameraDisabled)
145 $('media-select-camera').disabled = true; 146 $('media-select-camera').disabled = true;
146 147
147 OptionsPage.hideBubble(); 148 PageManager.hideBubble();
148 // Create a synthetic pref change event decorated as 149 // Create a synthetic pref change event decorated as
149 // CoreOptionsHandler::CreateValueForPref() does. 150 // CoreOptionsHandler::CreateValueForPref() does.
150 // TODO(arv): It was not clear what event type this should use? 151 // TODO(arv): It was not clear what event type this should use?
151 var event = new Event('undefined'); 152 var event = new Event('undefined');
152 event.value = {}; 153 event.value = {};
153 154
154 if (mediaSettings.showBubble) { 155 if (mediaSettings.showBubble) {
155 event.value = { controlledBy: 'policy' }; 156 event.value = { controlledBy: 'policy' };
156 $('media-indicator').setAttribute( 157 $('media-indicator').setAttribute(
157 'textpolicy', loadTimeData.getString(mediaSettings.bubbleText)); 158 'textpolicy', loadTimeData.getString(mediaSettings.bubbleText));
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 var deviceSelect = $('media-select-camera'); 300 var deviceSelect = $('media-select-camera');
300 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]); 301 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]);
301 }; 302 };
302 303
303 // Export 304 // Export
304 return { 305 return {
305 ContentSettings: ContentSettings 306 ContentSettings: ContentSettings
306 }; 307 };
307 308
308 }); 309 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698