| Index: chrome/browser/ui/extensions/extension_installed_bubble.cc
|
| diff --git a/chrome/browser/ui/extensions/extension_installed_bubble.cc b/chrome/browser/ui/extensions/extension_installed_bubble.cc
|
| index ea6a68499a631b318c4e12844940f5d656f3b256..9e260ea2c2790fcbe4f004c40cf2c882c056fe2f 100644
|
| --- a/chrome/browser/ui/extensions/extension_installed_bubble.cc
|
| +++ b/chrome/browser/ui/extensions/extension_installed_bubble.cc
|
| @@ -8,18 +8,22 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/message_loop/message_loop.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| #include "base/time/time.h"
|
| #include "chrome/browser/chrome_notification_types.h"
|
| +#include "chrome/browser/extensions/api/commands/command_service.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/common/extensions/api/extension_action/action_info.h"
|
| #include "chrome/common/extensions/api/omnibox/omnibox_handler.h"
|
| +#include "chrome/common/extensions/command.h"
|
| +#include "chrome/grit/generated_resources.h"
|
| #include "content/public/browser/notification_details.h"
|
| #include "content/public/browser/notification_source.h"
|
| #include "extensions/browser/extension_registry.h"
|
| #include "extensions/common/extension.h"
|
| +#include "ui/base/l10n/l10n_util.h"
|
|
|
| -using content::Details;
|
| using extensions::Extension;
|
|
|
| namespace {
|
| @@ -29,6 +33,28 @@ const int kAnimationWaitMs = 50;
|
| // How often we retry when waiting for browser action animation to end.
|
| const int kAnimationWaitRetries = 10;
|
|
|
| +// Returns the keybinding for an extension command, or a null if none exists.
|
| +scoped_ptr<extensions::Command> GetCommand(
|
| + const std::string& extension_id,
|
| + Profile* profile,
|
| + ExtensionInstalledBubble::BubbleType type) {
|
| + scoped_ptr<extensions::Command> result;
|
| + extensions::Command command;
|
| + extensions::CommandService* command_service =
|
| + extensions::CommandService::Get(profile);
|
| + bool has_command = false;
|
| + if (type == ExtensionInstalledBubble::BROWSER_ACTION) {
|
| + has_command = command_service->GetBrowserActionCommand(
|
| + extension_id, extensions::CommandService::ACTIVE, &command, nullptr);
|
| + } else if (type == ExtensionInstalledBubble::PAGE_ACTION) {
|
| + has_command = command_service->GetPageActionCommand(
|
| + extension_id, extensions::CommandService::ACTIVE, &command, nullptr);
|
| + }
|
| + if (has_command)
|
| + result.reset(new extensions::Command(command));
|
| + return result.Pass();
|
| +}
|
| +
|
| } // namespace
|
|
|
| ExtensionInstalledBubble::ExtensionInstalledBubble(Delegate* delegate,
|
| @@ -71,6 +97,36 @@ void ExtensionInstalledBubble::IgnoreBrowserClosing() {
|
| content::Source<Browser>(browser_));
|
| }
|
|
|
| +base::string16 ExtensionInstalledBubble::GetHowToUseDescription() const {
|
| + int message_id = 0;
|
| + base::string16 extra;
|
| + if (action_command_)
|
| + extra = action_command_->accelerator().GetShortcutText();
|
| +
|
| + switch (type_) {
|
| + case BROWSER_ACTION:
|
| + message_id = extra.empty() ? IDS_EXTENSION_INSTALLED_BROWSER_ACTION_INFO :
|
| + IDS_EXTENSION_INSTALLED_BROWSER_ACTION_INFO_WITH_SHORTCUT;
|
| + break;
|
| + case PAGE_ACTION:
|
| + message_id = extra.empty() ? IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO :
|
| + IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO_WITH_SHORTCUT;
|
| + break;
|
| + case OMNIBOX_KEYWORD:
|
| + extra =
|
| + base::UTF8ToUTF16(extensions::OmniboxInfo::GetKeyword(extension_));
|
| + message_id = IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO;
|
| + break;
|
| + case GENERIC:
|
| + break;
|
| + }
|
| +
|
| + if (message_id == 0)
|
| + return base::string16();
|
| + return extra.empty() ? l10n_util::GetStringUTF16(message_id) :
|
| + l10n_util::GetStringFUTF16(message_id, extra);
|
| +}
|
| +
|
| void ExtensionInstalledBubble::ShowInternal() {
|
| if (delegate_->MaybeShowNow())
|
| return;
|
| @@ -87,6 +143,9 @@ void ExtensionInstalledBubble::OnExtensionLoaded(
|
| content::BrowserContext* browser_context,
|
| const extensions::Extension* extension) {
|
| if (extension == extension_) {
|
| + // Parse the extension command, if one exists.
|
| + action_command_ = GetCommand(extension_->id(), browser_->profile(), type_);
|
| +
|
| animation_wait_retries_ = 0;
|
| // PostTask to ourself to allow all EXTENSION_LOADED Observers to run.
|
| base::MessageLoopForUI::current()->PostTask(
|
|
|