Commit b361969a authored by dpapad's avatar dpapad Committed by Commit Bot

MD Extensions: Stop displaying CWS as the source of unknown extensions.

Bug: 789215
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I5b2ab2c062490c21d2b72e2518ff93f8f2f7a801
Reviewed-on: https://chromium-review.googlesource.com/795353
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520232}
parent 4e722f4e
......@@ -369,7 +369,7 @@
</div>
<div class="section block">
<div class="section-title">$i18n{itemSource}</div>
<div class="section-content">
<div id="source" class="section-content">
[[computeSourceString_(data.*)]]
</div>
<div id="load-path" class="section-content"
......
......@@ -214,8 +214,8 @@ cr.define('extensions', function() {
/** @private */
computeSourceString_: function() {
return extensions.getItemSourceString(
extensions.getItemSource(this.data));
return this.data.locationText ||
extensions.getItemSourceString(extensions.getItemSource(this.data));
},
/**
......
......@@ -223,6 +223,9 @@ cr.define('extensions', function() {
return 'communication:business';
case SourceType.SIDELOADED:
return 'input';
case SourceType.UNKNOWN:
// TODO(dpapad): Ask UX for a better icon for this case.
return 'input';
case SourceType.UNPACKED:
return 'extensions-icons:unpacked';
case SourceType.WEBSTORE:
......@@ -236,6 +239,9 @@ cr.define('extensions', function() {
* @private
*/
computeSourceIndicatorText_: function() {
if (this.data.locationText)
return this.data.locationText;
const sourceType = extensions.getItemSource(this.data);
return sourceType == SourceType.WEBSTORE ?
'' :
......
......@@ -9,6 +9,7 @@ const SourceType = {
POLICY: 'policy',
SIDELOADED: 'sideloaded',
UNPACKED: 'unpacked',
UNKNOWN: 'unknown',
};
cr.define('extensions', function() {
......@@ -74,13 +75,21 @@ cr.define('extensions', function() {
chrome.developerPrivate.ControllerType.POLICY) {
return SourceType.POLICY;
}
if (item.location == chrome.developerPrivate.Location.THIRD_PARTY)
switch (item.location) {
case chrome.developerPrivate.Location.THIRD_PARTY:
return SourceType.SIDELOADED;
if (item.location == chrome.developerPrivate.Location.UNPACKED)
case chrome.developerPrivate.Location.UNPACKED:
return SourceType.UNPACKED;
case chrome.developerPrivate.Location.UNKNOWN:
return SourceType.UNKNOWN;
case chrome.developerPrivate.Location.FROM_STORE:
return SourceType.WEBSTORE;
}
assertNotReached(item.location);
}
/**
* @param {SourceType} source
* @return {string}
......@@ -95,6 +104,10 @@ cr.define('extensions', function() {
return loadTimeData.getString('itemSourceUnpacked');
case SourceType.WEBSTORE:
return loadTimeData.getString('itemSourceWebstore');
case SourceType.UNKNOWN:
// Nothing to return. Calling code should use
// chrome.developerPrivate.ExtensionInfo's |locationText| instead.
return '';
}
assertNotReached();
}
......
......@@ -203,6 +203,10 @@ TEST_F('CrExtensionsDetailViewTest', 'Layout', function() {
this.runMochaTest(extension_detail_view_tests.TestNames.Layout);
});
TEST_F('CrExtensionsDetailViewTest', 'LayoutSource', function() {
this.runMochaTest(extension_detail_view_tests.TestNames.LayoutSource);
});
TEST_F(
'CrExtensionsDetailViewTest', 'ClickableElements', function() {
this.runMochaTest(
......
......@@ -7,6 +7,7 @@ cr.define('extension_detail_view_tests', function() {
/** @enum {string} */
var TestNames = {
Layout: 'layout',
LayoutSource: 'layout of source section',
ClickableElements: 'clickable elements',
Indicator: 'indicator',
Warnings: 'warnings',
......@@ -115,12 +116,33 @@ cr.define('extension_detail_view_tests', function() {
Polymer.dom.flush();
expectTrue(testIsVisible('#id-section'));
expectTrue(testIsVisible('#inspectable-views'));
});
// Test whether the load path is displayed for unpacked extensions.
expectFalse(testIsVisible('#load-path'));
test(assert(TestNames.LayoutSource), function() {
item.set('data.location', 'FROM_STORE');
Polymer.dom.flush();
assertEquals('Chrome Web Store', item.$.source.textContent.trim());
assertFalse(extension_test_util.isVisible(item, '#load-path'));
item.set('data.location', 'THIRD_PARTY');
Polymer.dom.flush();
assertEquals('Added by a third-party', item.$.source.textContent.trim());
assertFalse(extension_test_util.isVisible(item, '#load-path'));
item.set('data.location', 'UNPACKED');
item.set('data.prettifiedPath', 'foo/bar/baz/');
Polymer.dom.flush();
expectTrue(testIsVisible('#load-path'));
assertEquals('Unpacked extension', item.$.source.textContent.trim());
// Test whether the load path is displayed for unpacked extensions.
assertTrue(extension_test_util.isVisible(item, '#load-path'));
item.set('data.location', 'UNKNOWN');
item.set('data.prettifiedPath', '');
// |locationText| is expected to always be set if location is UNKNOWN.
item.set('data.locationText', 'Foo');
Polymer.dom.flush();
assertEquals('Foo', item.$.source.textContent.trim());
assertFalse(extension_test_util.isVisible(item, '#load-path'));
});
test(assert(TestNames.ClickableElements), function() {
......
......@@ -239,6 +239,12 @@ cr.define('extension_item_tests', function() {
expectEquals('input', icon.icon);
extension_test_util.testIcons(item);
item.set('data.location', 'UNKNOWN');
Polymer.dom.flush();
expectTrue(extension_test_util.isVisible(item, '#source-indicator'));
expectEquals('input', icon.icon);
extension_test_util.testIcons(item);
item.set('data.location', 'FROM_STORE');
item.set('data.controlledInfo', {type: 'POLICY', text: 'policy'});
Polymer.dom.flush();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment