 Chromium Code Reviews
 Chromium Code Reviews Issue 1388353003:
  [MD settings] adding DefaultBrowser settings page  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1388353003:
  [MD settings] adding DefaultBrowser settings page  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview | |
| 7 * 'settings-default-browser-page' is the settings page that contains | |
| 8 * settings to change the default browser (i.e. which the OS will open). | |
| 9 * | |
| 10 * Example: | |
| 11 * | |
| 12 * <iron-animated-pages> | |
| 13 * <settings-default-browser-page prefs="{{prefs}}"> | |
| 14 * </settings-default-browser-page> | |
| 15 * ... other pages ... | |
| 16 * </iron-animated-pages> | |
| 17 * | |
| 18 * @group Chrome Settings Elements | |
| 19 * @element settings-default-browser-page | |
| 20 */ | |
| 21 Polymer({ | |
| 22 is: 'settings-default-browser-page', | |
| 23 | |
| 24 properties: { | |
| 25 /** | |
| 26 * Preferences state. | |
| 27 * @type {Object|undefined} | |
| 
stevenjb
2015/10/08 18:15:39
nit: @type not needed since it's just an Object
 
dschuyler
2015/10/08 18:26:23
Done.
 | |
| 28 */ | |
| 29 prefs: { | |
| 30 type: Object, | |
| 31 notify: true, | |
| 32 }, | |
| 33 | |
| 34 /** | |
| 35 * The current active route. | |
| 36 * @type {Object|undefined} | |
| 
stevenjb
2015/10/08 18:15:39
nit: @type not needed
 
dschuyler
2015/10/08 18:26:23
Done.
 | |
| 37 */ | |
| 38 currentRoute: { | |
| 39 type: Object, | |
| 40 notify: true, | |
| 41 }, | |
| 42 | |
| 43 /** | |
| 44 * Translated strings used in data binding. | |
| 45 * @type {!Object} | |
| 46 */ | |
| 47 i18n_: { | |
| 
Dan Beam
2015/10/08 18:42:42
would you mind extracting this into a behavior?
i
 
stevenjb
2015/10/08 19:50:36
I'm actually working on that right now if you want
 
dschuyler
2015/10/09 01:08:45
Acknowledged.
 
dschuyler
2015/10/09 01:08:45
Done.
 | |
| 48 type: Object, | |
| 49 value: function() { | |
| 50 return { | |
| 51 defaultBroswerMakeDefault: loadTimeData.getString( | |
| 52 'defaultBroswerMakeDefault'), | |
| 53 }; | |
| 54 }, | |
| 55 }, | |
| 56 | |
| 57 /** | |
| 58 * A message about whether Chrome is the default browser. | |
| 59 * @type {string} | |
| 
stevenjb
2015/10/08 18:15:39
nit: @type not needed
 
dschuyler
2015/10/08 18:26:23
Done.
 | |
| 60 */ | |
| 61 message_: { | |
| 62 type: String, | |
| 63 }, | |
| 64 | |
| 65 /** | |
| 66 * Show or hide an error indicator showing whether SetAsDefault succeeded. | |
| 67 * @type {boolean} | |
| 
stevenjb
2015/10/08 18:15:39
nit: @type not needed
 
dschuyler
2015/10/08 18:26:23
Done.
 | |
| 68 */ | |
| 69 showError_: { | |
| 70 type: Boolean, | |
| 71 value: false, | |
| 72 }, | |
| 73 | |
| 74 /** | |
| 75 * Only show the SetAsDefault button if we have permission to set it. | |
| 76 * @type {boolean} | |
| 
stevenjb
2015/10/08 18:15:39
nit: @type not needed
 
dschuyler
2015/10/08 18:26:23
Done.
 | |
| 77 */ | |
| 78 showButton_: { | |
| 79 type: Boolean, | |
| 80 value: true, | |
| 
Dan Beam
2015/10/08 18:42:42
do you know that showButton_ = true is likely to h
 
dschuyler
2015/10/09 01:08:45
Done.
 | |
| 81 }, | |
| 82 }, | |
| 83 | |
| 84 attached: function() { | |
| 85 var self = this; | |
| 86 cr.define('Settings', function() { | |
| 87 return { | |
| 88 setAsDefaultConcluded: function() { | |
| 89 return self.setAsDefaultConcluded_.apply(self, arguments); | |
| 90 }, | |
| 91 updateDefaultBrowserState: function() { | |
| 92 return self.updateDefaultBrowserState_.apply(self, arguments); | |
| 93 }, | |
| 94 }; | |
| 95 }); | |
| 96 chrome.send('SettingsDefaultBrowser.requestDefaultBrowserState'); | |
| 
Dan Beam
2015/10/08 18:42:42
shouldn't this all be done from ready?
 
dschuyler
2015/10/09 01:08:45
Done.
 | |
| 97 }, | |
| 98 | |
| 99 /** | |
| 100 * @param {boolean} succeeded | |
| 101 * @private | |
| 102 */ | |
| 103 setAsDefaultConcluded_: function(succeeded) { | |
| 104 this.showError_ = !succeeded; | |
| 105 }, | |
| 106 | |
| 107 /** | |
| 108 * @param {boolean} isDefault | |
| 
Dan Beam
2015/10/08 18:42:42
Whether Chrome is currently the user's default bro
 
dschuyler
2015/10/09 01:08:45
Done.
 | |
| 109 * @param {boolean} canBeDefault | |
| 
Dan Beam
2015/10/08 18:42:42
Whether Chrome can be the default browser on this
 
dschuyler
2015/10/09 01:08:45
Done.
 | |
| 110 * @private | |
| 111 */ | |
| 112 updateDefaultBrowserState_: function(isDefault, canBeDefault) { | |
| 113 this.showButton_ = !isDefault && canBeDefault; | |
| 114 if (canBeDefault) { | |
| 115 if (isDefault) { | |
| 116 this.message_ = loadTimeData.getString('defaultBroswerDefault'); | |
| 117 } else { | |
| 118 this.message_ = loadTimeData.getString('defaultBroswerNotDefault'); | |
| 119 } | |
| 
Dan Beam
2015/10/08 18:42:42
no curlies
 
Dan Beam
2015/10/08 18:42:42
nit: ternary
 
dschuyler
2015/10/09 01:08:45
Done.
 
dschuyler
2015/10/09 01:08:45
Acknowledged.
 | |
| 120 } else { | |
| 121 this.message_ = loadTimeData.getString('defaultBroswerUnknown'); | |
| 122 } | |
| 123 }, | |
| 124 | |
| 125 /** @private */ | |
| 126 onSetDefaultBrowserTap_: function() { | |
| 127 chrome.send('SettingsDefaultBrowser.setAsDefaultBrowser'); | |
| 128 }, | |
| 129 }); | |
| OLD | NEW |