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

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: ugh just no 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 /** @override */ 28 /** @override */
28 initializePage: function() { 29 initializePage: function() {
29 OptionsPage.prototype.initializePage.call(this); 30 Page.prototype.initializePage.call(this);
30 31
31 var exceptionsButtons = 32 var exceptionsButtons =
32 this.pageDiv.querySelectorAll('.exceptions-list-button'); 33 this.pageDiv.querySelectorAll('.exceptions-list-button');
33 for (var i = 0; i < exceptionsButtons.length; i++) { 34 for (var i = 0; i < exceptionsButtons.length; i++) {
34 exceptionsButtons[i].onclick = function(event) { 35 exceptionsButtons[i].onclick = function(event) {
35 var page = ContentSettingsExceptionsArea.getInstance(); 36 var page = ContentSettingsExceptionsArea.getInstance();
36 37
37 // Add on the proper hash for the content type, and store that in the 38 // Add on the proper hash for the content type, and store that in the
38 // history so back/forward and tab restore works. 39 // history so back/forward and tab restore works.
39 var hash = event.currentTarget.getAttribute('contentType'); 40 var hash = event.currentTarget.getAttribute('contentType');
40 var url = page.name + '#' + hash; 41 var url = page.name + '#' + hash;
41 uber.pushState({pageName: page.name}, url); 42 uber.pushState({pageName: page.name}, url);
42 43
43 // Navigate after the local history has been replaced in order to have 44 // Navigate after the local history has been replaced in order to have
44 // the correct hash loaded. 45 // the correct hash loaded.
45 OptionsPage.showPageByName('contentExceptions', false); 46 PageManager.showPageByName('contentExceptions', false);
46 }; 47 };
47 } 48 }
48 49
49 var manageHandlersButton = $('manage-handlers-button'); 50 var manageHandlersButton = $('manage-handlers-button');
50 if (manageHandlersButton) { 51 if (manageHandlersButton) {
51 manageHandlersButton.onclick = function(event) { 52 manageHandlersButton.onclick = function(event) {
52 OptionsPage.navigateToPage('handlers'); 53 PageManager.showPageByName('handlers');
53 }; 54 };
54 } 55 }
55 56
56 if (cr.isChromeOS) { 57 if (cr.isChromeOS) {
57 // Disable some controls for Guest in Chrome OS. 58 // Disable some controls for Guest in Chrome OS.
58 UIAccountTweaks.applyGuestSessionVisibility(document); 59 UIAccountTweaks.applyGuestSessionVisibility(document);
59 60
60 // Disable some controls for Public session in Chrome OS. 61 // Disable some controls for Public session in Chrome OS.
61 UIAccountTweaks.applyPublicSessionVisibility(document); 62 UIAccountTweaks.applyPublicSessionVisibility(document);
62 } 63 }
63 64
64 // Cookies filter page --------------------------------------------------- 65 // Cookies filter page ---------------------------------------------------
65 $('show-cookies-button').onclick = function(event) { 66 $('show-cookies-button').onclick = function(event) {
66 chrome.send('coreOptionsUserMetricsAction', ['Options_ShowCookies']); 67 chrome.send('coreOptionsUserMetricsAction', ['Options_ShowCookies']);
67 OptionsPage.navigateToPage('cookies'); 68 PageManager.showPageByName('cookies');
68 }; 69 };
69 70
70 $('content-settings-overlay-confirm').onclick = 71 $('content-settings-overlay-confirm').onclick =
71 OptionsPage.closeOverlay.bind(OptionsPage); 72 PageManager.closeOverlay.bind(PageManager);
72 73
73 $('media-pepper-flash-default').hidden = true; 74 $('media-pepper-flash-default').hidden = true;
74 $('media-pepper-flash-exceptions').hidden = true; 75 $('media-pepper-flash-exceptions').hidden = true;
75 76
76 $('media-select-mic').addEventListener('change', 77 $('media-select-mic').addEventListener('change',
77 ContentSettings.setDefaultMicrophone_); 78 ContentSettings.setDefaultMicrophone_);
78 $('media-select-camera').addEventListener('change', 79 $('media-select-camera').addEventListener('change',
79 ContentSettings.setDefaultCamera_); 80 ContentSettings.setDefaultCamera_);
80 }, 81 },
81 }; 82 };
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 $('media-stream-ask-label').innerHTML = 139 $('media-stream-ask-label').innerHTML =
139 loadTimeData.getString(mediaSettings.askText); 140 loadTimeData.getString(mediaSettings.askText);
140 $('media-stream-block-label').innerHTML = 141 $('media-stream-block-label').innerHTML =
141 loadTimeData.getString(mediaSettings.blockText); 142 loadTimeData.getString(mediaSettings.blockText);
142 143
143 if (mediaSettings.micDisabled) 144 if (mediaSettings.micDisabled)
144 $('media-select-mic').disabled = true; 145 $('media-select-mic').disabled = true;
145 if (mediaSettings.cameraDisabled) 146 if (mediaSettings.cameraDisabled)
146 $('media-select-camera').disabled = true; 147 $('media-select-camera').disabled = true;
147 148
148 OptionsPage.hideBubble(); 149 PageManager.hideBubble();
149 // Create a synthetic pref change event decorated as 150 // Create a synthetic pref change event decorated as
150 // CoreOptionsHandler::CreateValueForPref() does. 151 // CoreOptionsHandler::CreateValueForPref() does.
151 // TODO(arv): It was not clear what event type this should use? 152 // TODO(arv): It was not clear what event type this should use?
152 var event = new Event('undefined'); 153 var event = new Event('undefined');
153 event.value = {}; 154 event.value = {};
154 155
155 if (mediaSettings.showBubble) { 156 if (mediaSettings.showBubble) {
156 event.value = { controlledBy: 'policy' }; 157 event.value = { controlledBy: 'policy' };
157 $('media-indicator').setAttribute( 158 $('media-indicator').setAttribute(
158 'textpolicy', loadTimeData.getString(mediaSettings.bubbleText)); 159 'textpolicy', loadTimeData.getString(mediaSettings.bubbleText));
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 var deviceSelect = $('media-select-camera'); 301 var deviceSelect = $('media-select-camera');
301 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]); 302 chrome.send('setDefaultCaptureDevice', ['camera', deviceSelect.value]);
302 }; 303 };
303 304
304 // Export 305 // Export
305 return { 306 return {
306 ContentSettings: ContentSettings 307 ContentSettings: ContentSettings
307 }; 308 };
308 309
309 }); 310 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698