Commit f4ba2ef4 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

extensions: fix how-to-use logic in installed bubble

Before r723559 the logic was basically:

  if (action && (action->is_browser || action->is_page))
    return !action->synthesized;
  if (HasOmniboxKeyword())
    return true;
  return false;

But the new logic was:

  if (!action)
    return false;
  if (action->is_browser || action->is_page)
    return !action->synthesized;
  return HasOmniboxKeyword();

which behaves differently when HasOmniboxKeyword() && !action: in the
pre-r723559 logic that would return true but in the post-r723559 logic it
returned false.

This is repaired here by rewriting this function.

Bug: 1047819
Change-Id: I86551a2c89ff39eedc0b9c29dcad7db50c006f2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2033988Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738246}
parent 2cddca8a
...@@ -170,16 +170,18 @@ gfx::ImageSkia MakeIconFromBitmap(const SkBitmap& bitmap) { ...@@ -170,16 +170,18 @@ gfx::ImageSkia MakeIconFromBitmap(const SkBitmap& bitmap) {
bool ShouldShowHowToUse(const extensions::Extension* extension) { bool ShouldShowHowToUse(const extensions::Extension* extension) {
const auto* info = GetActionInfoForExtension(extension); const auto* info = GetActionInfoForExtension(extension);
if (HasOmniboxKeyword(extension))
return true;
if (!info) if (!info)
return false; return false;
switch (info->type) { if (info->type == extensions::ActionInfo::TYPE_BROWSER ||
case extensions::ActionInfo::TYPE_BROWSER: info->type == extensions::ActionInfo::TYPE_PAGE) {
case extensions::ActionInfo::TYPE_PAGE: return !info->synthesized;
return !info->synthesized;
case extensions::ActionInfo::TYPE_ACTION:
return HasOmniboxKeyword(extension);
} }
return false;
} }
bool HasCommandKeybinding(const extensions::Extension* extension, bool HasCommandKeybinding(const extensions::Extension* extension,
...@@ -261,11 +263,14 @@ base::string16 GetHowToUseDescription(const Extension* extension, ...@@ -261,11 +263,14 @@ base::string16 GetHowToUseDescription(const Extension* extension,
: IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO_WITH_SHORTCUT; : IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO_WITH_SHORTCUT;
break; break;
case extensions::ActionInfo::TYPE_ACTION: case extensions::ActionInfo::TYPE_ACTION:
extra = base::UTF8ToUTF16(extensions::OmniboxInfo::GetKeyword(extension));
message_id = IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO;
break; break;
} }
if (message_id == 0 && HasOmniboxKeyword(extension)) {
extra = base::UTF8ToUTF16(extensions::OmniboxInfo::GetKeyword(extension));
message_id = IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO;
}
if (message_id == 0) if (message_id == 0)
return base::string16(); return base::string16();
return extra.empty() ? l10n_util::GetStringUTF16(message_id) return extra.empty() ? l10n_util::GetStringUTF16(message_id)
......
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