Bug 787054 - Make the UA string OS agnostic again, use UserAgentOverrides.jsm to white-list sites that need "Android" [r=dao,gerv]
authorFabrice Desré <fabrice@mozilla.com>
Wed, 03 Oct 2012 13:27:46 -0700
changeset 109229 14fe82a53d68c7be9e6042e8971fddd6ebbf5e76
parent 109225 9a71c92af5a43c44baf8975e8163b5c170f505d8
child 109230 2545d8e6f3becb1146cf08e7df60659826b19811
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersdao, gerv
bugs787054
milestone18.0a1
Bug 787054 - Make the UA string OS agnostic again, use UserAgentOverrides.jsm to white-list sites that need "Android" [r=dao,gerv]
b2g/app/b2g.js
b2g/chrome/content/shell.js
b2g/confvars.sh
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -571,8 +571,12 @@ pref("ui.mouse.radius.bottommm", 2);
 // Disable native prompt
 pref("browser.prompt.allowNative", false);
 
 // Minimum delay in milliseconds between network activity notifications (0 means
 // no notifications). The delay is the same for both download and upload, though
 // they are handled separately. This pref is only read once at startup:
 // a restart is required to enable a new value.
 pref("network.activity.blipIntervalMilliseconds", 250);
+
+// Send some sites a custom user-agent.
+pref("general.useragent.override.facebook.com", "\(Mobile#(Android; Mobile");
+pref("general.useragent.override.youtube.com", "\(Mobile#(Android; Mobile");
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -19,16 +19,17 @@ Cu.import('resource://gre/modules/DOMFMR
 Cu.import('resource://gre/modules/AlarmService.jsm');
 Cu.import('resource://gre/modules/ActivitiesService.jsm');
 Cu.import('resource://gre/modules/PermissionPromptHelper.jsm');
 Cu.import('resource://gre/modules/PermissionSettings.jsm');
 Cu.import('resource://gre/modules/ObjectWrapper.jsm');
 Cu.import('resource://gre/modules/accessibility/AccessFu.jsm');
 Cu.import('resource://gre/modules/Payment.jsm');
 Cu.import("resource://gre/modules/AppsUtils.jsm");
+Cu.import('resource://gre/modules/UserAgentOverrides.jsm');
 
 XPCOMUtils.defineLazyServiceGetter(Services, 'env',
                                    '@mozilla.org/process/environment;1',
                                    'nsIEnvironment');
 
 XPCOMUtils.defineLazyServiceGetter(Services, 'ss',
                                    '@mozilla.org/content/style-sheet-service;1',
                                    'nsIStyleSheetService');
@@ -173,16 +174,17 @@ var shell = {
       Services.audioManager.masterVolume = 0.5;
     } catch(e) {
       dump('Error setting master volume: ' + e + '\n');
     }
 
     CustomEventManager.init();
     WebappsHelper.init();
     AccessFu.attach(window);
+    UserAgentOverrides.init();
 
     // XXX could factor out into a settings->pref map.  Not worth it yet.
     SettingsListener.observe("debug.fps.enabled", false, function(value) {
       Services.prefs.setBoolPref("layers.acceleration.draw-fps", value);
     });
     SettingsListener.observe("debug.paint-flashing.enabled", false, function(value) {
       Services.prefs.setBoolPref("nglayout.debug.paint_flashing", value);
     });
@@ -208,16 +210,17 @@ var shell = {
     if (this.timer) {
       this.timer.cancel();
       this.timer = null;
     }
 
 #ifndef MOZ_WIDGET_GONK
     delete Services.audioManager;
 #endif
+    UserAgentOverrides.uninit();
   },
 
   // If this key event actually represents a hardware button, filter it here
   // and send a mozChromeEvent with detail.type set to xxx-button-press or
   // xxx-button-release instead.
   filterHardwareKeys: function shell_filterHardwareKeys(evt) {
     var type;
     switch (evt.keyCode) {
--- a/b2g/confvars.sh
+++ b/b2g/confvars.sh
@@ -3,16 +3,18 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 MOZ_APP_BASENAME=B2G
 MOZ_APP_VENDOR=Mozilla
 
 MOZ_APP_VERSION=18.0a1
 MOZ_APP_UA_NAME=Firefox
 
+MOZ_UA_OS_AGNOSTIC=1
+
 MOZ_B2G_VERSION=1.0.0
 
 MOZ_BRANDING_DIRECTORY=b2g/branding/unofficial
 MOZ_OFFICIAL_BRANDING_DIRECTORY=b2g/branding/official
 # MOZ_APP_DISPLAYNAME is set by branding/configure.sh
 
 MOZ_SAFE_BROWSING=
 MOZ_SERVICES_SYNC=1