| OLD | NEW |
| 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 <include src="../uber/uber_utils.js"> | 5 <include src="../uber/uber_utils.js"> |
| 6 <include src="extension_code.js"> | 6 <include src="extension_code.js"> |
| 7 <include src="extension_commands_overlay.js"> | 7 <include src="extension_commands_overlay.js"> |
| 8 <include src="extension_focus_manager.js"> | 8 <include src="extension_focus_manager.js"> |
| 9 <include src="extension_list.js"> | 9 <include src="extension_list.js"> |
| 10 <include src="pack_extension_overlay.js"> | 10 <include src="pack_extension_overlay.js"> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // its item entry. | 59 // its item entry. |
| 60 for (var i = 0; i < e.dataTransfer.items.length; ++i) { | 60 for (var i = 0; i < e.dataTransfer.items.length; ++i) { |
| 61 if (e.dataTransfer.items[i].kind == 'file' && | 61 if (e.dataTransfer.items[i].kind == 'file' && |
| 62 e.dataTransfer.items[i].webkitGetAsEntry().isDirectory) { | 62 e.dataTransfer.items[i].webkitGetAsEntry().isDirectory) { |
| 63 toSend = 'installDroppedDirectory'; | 63 toSend = 'installDroppedDirectory'; |
| 64 break; | 64 break; |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 // Only process files that look like extensions. Other files should | 67 // Only process files that look like extensions. Other files should |
| 68 // navigate the browser normally. | 68 // navigate the browser normally. |
| 69 if (!toSend && /\.(crx|user\.js)$/i.test(e.dataTransfer.files[0].name)) | 69 if (!toSend && |
| 70 /\.(crx|user\.js|zip)$/i.test(e.dataTransfer.files[0].name)) { |
| 70 toSend = 'installDroppedFile'; | 71 toSend = 'installDroppedFile'; |
| 72 } |
| 71 | 73 |
| 72 if (toSend) { | 74 if (toSend) { |
| 73 e.preventDefault(); | 75 e.preventDefault(); |
| 74 chrome.send(toSend); | 76 chrome.send(toSend); |
| 75 } | 77 } |
| 76 } | 78 } |
| 77 }; | 79 }; |
| 78 | 80 |
| 79 /** | 81 /** |
| 80 * ExtensionSettings class | 82 * ExtensionSettings class |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 332 |
| 331 ExtensionSettings.getInstance().displayPromo_ = | 333 ExtensionSettings.getInstance().displayPromo_ = |
| 332 extensionsData.promoteAppsDevTools; | 334 extensionsData.promoteAppsDevTools; |
| 333 ExtensionSettings.getInstance().updatePromoVisibility_(); | 335 ExtensionSettings.getInstance().updatePromoVisibility_(); |
| 334 | 336 |
| 335 $('load-unpacked').disabled = extensionsData.loadUnpackedDisabled; | 337 $('load-unpacked').disabled = extensionsData.loadUnpackedDisabled; |
| 336 | 338 |
| 337 ExtensionsList.prototype.data_ = extensionsData; | 339 ExtensionsList.prototype.data_ = extensionsData; |
| 338 var extensionList = $('extension-settings-list'); | 340 var extensionList = $('extension-settings-list'); |
| 339 ExtensionsList.decorate(extensionList); | 341 ExtensionsList.decorate(extensionList); |
| 340 } | 342 }; |
| 341 | 343 |
| 342 // Indicate that warning |message| has occured for pack of |crx_path| and | 344 // Indicate that warning |message| has occured for pack of |crx_path| and |
| 343 // |pem_path| files. Ask if user wants override the warning. Send | 345 // |pem_path| files. Ask if user wants override the warning. Send |
| 344 // |overrideFlags| to repeated 'pack' call to accomplish the override. | 346 // |overrideFlags| to repeated 'pack' call to accomplish the override. |
| 345 ExtensionSettings.askToOverrideWarning = | 347 ExtensionSettings.askToOverrideWarning = |
| 346 function(message, crx_path, pem_path, overrideFlags) { | 348 function(message, crx_path, pem_path, overrideFlags) { |
| 347 var closeAlert = function() { | 349 var closeAlert = function() { |
| 348 ExtensionSettings.showOverlay(null); | 350 ExtensionSettings.showOverlay(null); |
| 349 }; | 351 }; |
| 350 | 352 |
| 351 alertOverlay.setValues( | 353 alertOverlay.setValues( |
| 352 loadTimeData.getString('packExtensionWarningTitle'), | 354 loadTimeData.getString('packExtensionWarningTitle'), |
| 353 message, | 355 message, |
| 354 loadTimeData.getString('packExtensionProceedAnyway'), | 356 loadTimeData.getString('packExtensionProceedAnyway'), |
| 355 loadTimeData.getString('cancel'), | 357 loadTimeData.getString('cancel'), |
| 356 function() { | 358 function() { |
| 357 chrome.send('pack', [crx_path, pem_path, overrideFlags]); | 359 chrome.send('pack', [crx_path, pem_path, overrideFlags]); |
| 358 closeAlert(); | 360 closeAlert(); |
| 359 }, | 361 }, |
| 360 closeAlert); | 362 closeAlert); |
| 361 ExtensionSettings.showOverlay($('alertOverlay')); | 363 ExtensionSettings.showOverlay($('alertOverlay')); |
| 362 } | 364 }; |
| 363 | 365 |
| 364 /** | 366 /** |
| 365 * Returns the current overlay or null if one does not exist. | 367 * Returns the current overlay or null if one does not exist. |
| 366 * @return {Element} The overlay element. | 368 * @return {Element} The overlay element. |
| 367 */ | 369 */ |
| 368 ExtensionSettings.getCurrentOverlay = function() { | 370 ExtensionSettings.getCurrentOverlay = function() { |
| 369 return document.querySelector('#overlay .page.showing'); | 371 return document.querySelector('#overlay .page.showing'); |
| 370 } | 372 }; |
| 371 | 373 |
| 372 /** | 374 /** |
| 373 * Sets the given overlay to show. This hides whatever overlay is currently | 375 * Sets the given overlay to show. This hides whatever overlay is currently |
| 374 * showing, if any. | 376 * showing, if any. |
| 375 * @param {HTMLElement} node The overlay page to show. If falsey, all overlays | 377 * @param {HTMLElement} node The overlay page to show. If falsey, all overlays |
| 376 * are hidden. | 378 * are hidden. |
| 377 */ | 379 */ |
| 378 ExtensionSettings.showOverlay = function(node) { | 380 ExtensionSettings.showOverlay = function(node) { |
| 379 var pageDiv = $('extension-settings'); | 381 var pageDiv = $('extension-settings'); |
| 380 if (node) { | 382 if (node) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 393 node.classList.add('showing'); | 395 node.classList.add('showing'); |
| 394 | 396 |
| 395 var pages = document.querySelectorAll('.page'); | 397 var pages = document.querySelectorAll('.page'); |
| 396 for (var i = 0; i < pages.length; i++) { | 398 for (var i = 0; i < pages.length; i++) { |
| 397 pages[i].setAttribute('aria-hidden', node ? 'true' : 'false'); | 399 pages[i].setAttribute('aria-hidden', node ? 'true' : 'false'); |
| 398 } | 400 } |
| 399 | 401 |
| 400 overlay.hidden = !node; | 402 overlay.hidden = !node; |
| 401 uber.invokeMethodOnParent(node ? 'beginInterceptingEvents' : | 403 uber.invokeMethodOnParent(node ? 'beginInterceptingEvents' : |
| 402 'stopInterceptingEvents'); | 404 'stopInterceptingEvents'); |
| 403 } | 405 }; |
| 404 | 406 |
| 405 /** | 407 /** |
| 406 * Utility function to find the width of various UI strings and synchronize | 408 * Utility function to find the width of various UI strings and synchronize |
| 407 * the width of relevant spans. This is crucial for making sure the | 409 * the width of relevant spans. This is crucial for making sure the |
| 408 * Enable/Enabled checkboxes align, as well as the Developer Mode checkbox. | 410 * Enable/Enabled checkboxes align, as well as the Developer Mode checkbox. |
| 409 */ | 411 */ |
| 410 function measureCheckboxStrings() { | 412 function measureCheckboxStrings() { |
| 411 var trashWidth = 30; | 413 var trashWidth = 30; |
| 412 var measuringDiv = $('font-measuring-div'); | 414 var measuringDiv = $('font-measuring-div'); |
| 413 measuringDiv.textContent = | 415 measuringDiv.textContent = |
| 414 loadTimeData.getString('extensionSettingsEnabled'); | 416 loadTimeData.getString('extensionSettingsEnabled'); |
| 415 var pxWidth = measuringDiv.clientWidth + trashWidth; | 417 var pxWidth = measuringDiv.clientWidth + trashWidth; |
| 416 measuringDiv.textContent = | 418 measuringDiv.textContent = |
| 417 loadTimeData.getString('extensionSettingsEnable'); | 419 loadTimeData.getString('extensionSettingsEnable'); |
| 418 pxWidth = Math.max(measuringDiv.clientWidth + trashWidth, pxWidth); | 420 pxWidth = Math.max(measuringDiv.clientWidth + trashWidth, pxWidth); |
| 419 measuringDiv.textContent = | 421 measuringDiv.textContent = |
| 420 loadTimeData.getString('extensionSettingsDeveloperMode'); | 422 loadTimeData.getString('extensionSettingsDeveloperMode'); |
| 421 pxWidth = Math.max(measuringDiv.clientWidth, pxWidth); | 423 pxWidth = Math.max(measuringDiv.clientWidth, pxWidth); |
| 422 | 424 |
| 423 var style = document.createElement('style'); | 425 var style = document.createElement('style'); |
| 424 style.type = 'text/css'; | 426 style.type = 'text/css'; |
| 425 style.textContent = | 427 style.textContent = |
| 426 '.enable-checkbox-text {' + | 428 '.enable-checkbox-text {' + |
| 427 ' min-width: ' + (pxWidth - trashWidth) + 'px;' + | 429 ' min-width: ' + (pxWidth - trashWidth) + 'px;' + |
| 428 '}' + | 430 '}' + |
| 429 '#dev-toggle span {' + | 431 '#dev-toggle span {' + |
| 430 ' min-width: ' + pxWidth + 'px;' + | 432 ' min-width: ' + pxWidth + 'px;' + |
| 431 '}'; | 433 '}'; |
| 432 document.querySelector('head').appendChild(style); | 434 document.querySelector('head').appendChild(style); |
| 433 } | 435 }; |
| 434 | 436 |
| 435 // Export | 437 // Export |
| 436 return { | 438 return { |
| 437 ExtensionSettings: ExtensionSettings | 439 ExtensionSettings: ExtensionSettings |
| 438 }; | 440 }; |
| 439 }); | 441 }); |
| 440 | 442 |
| 441 window.addEventListener('load', function(e) { | 443 window.addEventListener('load', function(e) { |
| 442 extensions.ExtensionSettings.getInstance().initialize(); | 444 extensions.ExtensionSettings.getInstance().initialize(); |
| 443 }); | 445 }); |
| OLD | NEW |