;'use strict';(function(exports){var isManuallyPrivate=window.location.search.includes('private=1');var isManuallyRegular=window.location.search.includes('private=0');var isPrivateByDefault=false;SettingsListener.observe('browser.private.default',false,function(value){if(value){isPrivateByDefault=true;}else{isPrivateByDefault=false;} exports.newtab.togglePrivacyMode();});function Newtab(){var self=this;navigator.mozApps.getSelf().onsuccess=function(){var app=this.result;app.connect('search-results').then(function onConnAccepted(ports){ports.forEach(function(port){self._port=port;});self.init();},function onConnectionRejected(reason){console.log('Error connecting: '+reason+'\n');});};this.togglePrivacyMode();} Newtab.prototype={provider:null,init:function(){this.provider.init();this.provider.searchObj=this;},requestScreenshot:function(url){this._port.postMessage({'action':'request-screenshot','url':url});},requestPrivateWindow:function(){this._port.postMessage({'action':'private-window'});},togglePrivacyMode:function(){var themeMeta=document.querySelector('meta[name="theme-color"]');var themeColor=document.createElement('meta');if((isPrivateByDefault&&!isManuallyRegular)||(!isPrivateByDefault&&isManuallyPrivate)){if(themeMeta){document.head.removeChild(themeMeta);} themeColor.setAttribute('name','theme-color');themeColor.setAttribute('content','#392E54');document.head.appendChild(themeColor);document.body.classList.add('private');asyncStorage.getItem('shouldSuppressPrivateDialog',value=>{if(value){return;} this.privateBrowserDialog=document.getElementById('private-window-dialog');this.privateBrowserDialog.removeAttribute('hidden');this.privateBrowserDialogClose=document.getElementById('private-window-hide-dialog');this.privateBrowserDialogClose.addEventListener('click',this);this.privateBrowserLearnMore=document.getElementById('private-learn-more');this.privateBrowserLearnMore.addEventListener('click',this);});} if(isPrivateByDefault&&isManuallyRegular){if(themeMeta){document.head.removeChild(themeMeta);}}},handleEvent:function(e){switch(e.target){case this.privateBrowserDialogClose:this.hidePrivateBrowserDialog();break;case this.privateBrowserLearnMore:this.learnAboutPrivateBrowsing(e);break;}},hidePrivateBrowserDialog:function(){this.privateBrowserDialog.setAttribute('hidden',true);var checkbox=this.privateBrowserDialog.querySelector('gaia-checkbox');if(checkbox.checked){asyncStorage.setItem('shouldSuppressPrivateDialog',true);}},learnAboutPrivateBrowsing:function(e){e.preventDefault();new MozActivity({name:'view',data:{type:'url',url:e.target.href}});}};exports.newtab=new Newtab();exports.Search={provider:function(provider){exports.newtab.provider=provider;},navigate:function(url){new MozActivity({name:'view',data:{type:'url',url:url}});}};})(window);