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 @@ ...@@ -369,7 +369,7 @@
</div> </div>
<div class="section block"> <div class="section block">
<div class="section-title">$i18n{itemSource}</div> <div class="section-title">$i18n{itemSource}</div>
<div class="section-content"> <div id="source" class="section-content">
[[computeSourceString_(data.*)]] [[computeSourceString_(data.*)]]
</div> </div>
<div id="load-path" class="section-content" <div id="load-path" class="section-content"
......
...@@ -214,8 +214,8 @@ cr.define('extensions', function() { ...@@ -214,8 +214,8 @@ cr.define('extensions', function() {
/** @private */ /** @private */
computeSourceString_: function() { computeSourceString_: function() {
return extensions.getItemSourceString( return this.data.locationText ||
extensions.getItemSource(this.data)); extensions.getItemSourceString(extensions.getItemSource(this.data));
}, },
/** /**
......
...@@ -223,6 +223,9 @@ cr.define('extensions', function() { ...@@ -223,6 +223,9 @@ cr.define('extensions', function() {
return 'communication:business'; return 'communication:business';
case SourceType.SIDELOADED: case SourceType.SIDELOADED:
return 'input'; return 'input';
case SourceType.UNKNOWN:
// TODO(dpapad): Ask UX for a better icon for this case.
return 'input';
case SourceType.UNPACKED: case SourceType.UNPACKED:
return 'extensions-icons:unpacked'; return 'extensions-icons:unpacked';
case SourceType.WEBSTORE: case SourceType.WEBSTORE:
...@@ -236,6 +239,9 @@ cr.define('extensions', function() { ...@@ -236,6 +239,9 @@ cr.define('extensions', function() {
* @private * @private
*/ */
computeSourceIndicatorText_: function() { computeSourceIndicatorText_: function() {
if (this.data.locationText)
return this.data.locationText;
const sourceType = extensions.getItemSource(this.data); const sourceType = extensions.getItemSource(this.data);
return sourceType == SourceType.WEBSTORE ? return sourceType == SourceType.WEBSTORE ?
'' : '' :
......
...@@ -9,6 +9,7 @@ const SourceType = { ...@@ -9,6 +9,7 @@ const SourceType = {
POLICY: 'policy', POLICY: 'policy',
SIDELOADED: 'sideloaded', SIDELOADED: 'sideloaded',
UNPACKED: 'unpacked', UNPACKED: 'unpacked',
UNKNOWN: 'unknown',
}; };
cr.define('extensions', function() { cr.define('extensions', function() {
...@@ -74,11 +75,19 @@ cr.define('extensions', function() { ...@@ -74,11 +75,19 @@ cr.define('extensions', function() {
chrome.developerPrivate.ControllerType.POLICY) { chrome.developerPrivate.ControllerType.POLICY) {
return SourceType.POLICY; return SourceType.POLICY;
} }
if (item.location == chrome.developerPrivate.Location.THIRD_PARTY)
return SourceType.SIDELOADED; switch (item.location) {
if (item.location == chrome.developerPrivate.Location.UNPACKED) case chrome.developerPrivate.Location.THIRD_PARTY:
return SourceType.UNPACKED; return SourceType.SIDELOADED;
return SourceType.WEBSTORE; 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);
} }
/** /**
...@@ -95,6 +104,10 @@ cr.define('extensions', function() { ...@@ -95,6 +104,10 @@ cr.define('extensions', function() {
return loadTimeData.getString('itemSourceUnpacked'); return loadTimeData.getString('itemSourceUnpacked');
case SourceType.WEBSTORE: case SourceType.WEBSTORE:
return loadTimeData.getString('itemSourceWebstore'); return loadTimeData.getString('itemSourceWebstore');
case SourceType.UNKNOWN:
// Nothing to return. Calling code should use
// chrome.developerPrivate.ExtensionInfo's |locationText| instead.
return '';
} }
assertNotReached(); assertNotReached();
} }
......
...@@ -203,6 +203,10 @@ TEST_F('CrExtensionsDetailViewTest', 'Layout', function() { ...@@ -203,6 +203,10 @@ TEST_F('CrExtensionsDetailViewTest', 'Layout', function() {
this.runMochaTest(extension_detail_view_tests.TestNames.Layout); this.runMochaTest(extension_detail_view_tests.TestNames.Layout);
}); });
TEST_F('CrExtensionsDetailViewTest', 'LayoutSource', function() {
this.runMochaTest(extension_detail_view_tests.TestNames.LayoutSource);
});
TEST_F( TEST_F(
'CrExtensionsDetailViewTest', 'ClickableElements', function() { 'CrExtensionsDetailViewTest', 'ClickableElements', function() {
this.runMochaTest( this.runMochaTest(
......
...@@ -7,6 +7,7 @@ cr.define('extension_detail_view_tests', function() { ...@@ -7,6 +7,7 @@ cr.define('extension_detail_view_tests', function() {
/** @enum {string} */ /** @enum {string} */
var TestNames = { var TestNames = {
Layout: 'layout', Layout: 'layout',
LayoutSource: 'layout of source section',
ClickableElements: 'clickable elements', ClickableElements: 'clickable elements',
Indicator: 'indicator', Indicator: 'indicator',
Warnings: 'warnings', Warnings: 'warnings',
...@@ -115,12 +116,33 @@ cr.define('extension_detail_view_tests', function() { ...@@ -115,12 +116,33 @@ cr.define('extension_detail_view_tests', function() {
Polymer.dom.flush(); Polymer.dom.flush();
expectTrue(testIsVisible('#id-section')); expectTrue(testIsVisible('#id-section'));
expectTrue(testIsVisible('#inspectable-views')); expectTrue(testIsVisible('#inspectable-views'));
});
// Test whether the load path is displayed for unpacked extensions. test(assert(TestNames.LayoutSource), function() {
expectFalse(testIsVisible('#load-path')); 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/'); item.set('data.prettifiedPath', 'foo/bar/baz/');
Polymer.dom.flush(); 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() { test(assert(TestNames.ClickableElements), function() {
......
...@@ -239,6 +239,12 @@ cr.define('extension_item_tests', function() { ...@@ -239,6 +239,12 @@ cr.define('extension_item_tests', function() {
expectEquals('input', icon.icon); expectEquals('input', icon.icon);
extension_test_util.testIcons(item); 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.location', 'FROM_STORE');
item.set('data.controlledInfo', {type: 'POLICY', text: 'policy'}); item.set('data.controlledInfo', {type: 'POLICY', text: 'policy'});
Polymer.dom.flush(); 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