We want a Chrome extension with this policy: http://www.chromium.org/administrators/configuring-policy-for-extensions So we can hide the 'welcome' page on our intern Network. And regular users (from Chrome web store) see the 'welcome' page when they installed this Chrome extension.
The first Background.js code work OK, here it shows the 'welcome page' when the user install this extension for the first time. I upgrade the code to 'new background', but the code doesn't do the task of hiding the 'welcome page' with the network 'policy' registry. Any idea on how to fix this issue? Or what JavaScript code is missing?
This is our code: Background.js
chrome.storage.local.get(['firstRun'], function(chromeset){
if ((chromeset["firstRun"]!="false") && (chromeset["firstRun"]!=false)){
chrome.tabs.create({url: "http://www.google.com", selected:true})
chrome.storage.local.set({"firstRun": "false"});
}
});
manifest.js
...
"permissions": [
"bookmarks"
],
"storage": {
"managed_schema": "schema.json"
}
}
schema.json
{
"type": "object",
"properties": {
"HideFirstRunPage": {
"title": "Hide the first welcome page",
"description": "Configures App to show not the first welcome page when you install this extension.",
"type": "boolean"
}
}
}
New background.js
var HideFirstRunPage = false;
if (require("info").platform == "chromium" && "managed" in chrome.storage)
{
chrome.storage.managed.get('HideFirstRunPage', function (data) {
var thenewvalue = data.HideFirstRunPage;
if(thenewvalue == true){
chrome.storage.local.set({"firstRun": "false"});
} else{
initwelcome()
}
});
} else{
initwelcome()
}
function initwelcome(){
// new user? Then open this google.com page
chrome.storage.local.get(['firstRun'], function(chromeset){
if ((chromeset["firstRun"]!="false") && (chromeset["firstRun"]!=false)){
chrome.tabs.create({url: "https://www.google.com", selected:true})
chrome.storage.local.set({"firstRun": "false"});
});
}
document.addEventListener('DOMContentLoaded', function () {initwelcome()}