| Index: chrome/common/extensions/extension.cc
|
| diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
|
| index d99dd013e5283244d471899696d3daf95401a8a5..109cd87758a60e4c089e3e0c72a113b7e2041edb 100644
|
| --- a/chrome/common/extensions/extension.cc
|
| +++ b/chrome/common/extensions/extension.cc
|
| @@ -27,7 +27,6 @@
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/chrome_version_info.h"
|
| #include "chrome/common/extensions/csp_validator.h"
|
| -#include "chrome/common/extensions/extension_action.h"
|
| #include "chrome/common/extensions/extension_error_utils.h"
|
| #include "chrome/common/extensions/extension_manifest_constants.h"
|
| #include "chrome/common/extensions/extension_resource.h"
|
| @@ -288,6 +287,10 @@ Extension::TtsVoice::~TtsVoice() {}
|
| Extension::OAuth2Info::OAuth2Info() {}
|
| Extension::OAuth2Info::~OAuth2Info() {}
|
|
|
| +Extension::ActionInfo::ActionInfo(Type action_type)
|
| + : action_type(action_type) {}
|
| +Extension::ActionInfo::~ActionInfo() {}
|
| +
|
| //
|
| // Extension
|
| //
|
| @@ -797,17 +800,11 @@ bool Extension::LoadGlobsHelper(
|
| return true;
|
| }
|
|
|
| -scoped_ptr<ExtensionAction> Extension::LoadExtensionActionHelper(
|
| +scoped_ptr<Extension::ActionInfo> Extension::LoadExtensionActionHelper(
|
| const DictionaryValue* extension_action,
|
| - ExtensionAction::Type action_type,
|
| + ActionInfo::Type action_type,
|
| string16* error) {
|
| - scoped_ptr<ExtensionAction> result(new ExtensionAction(id(), action_type));
|
| -
|
| - // Page/script actions are hidden/disabled by default, and browser actions are
|
| - // visible/enabled by default.
|
| - result->SetAppearance(ExtensionAction::kDefaultTabId,
|
| - action_type == ExtensionAction::TYPE_BROWSER ?
|
| - ExtensionAction::ACTIVE : ExtensionAction::INVISIBLE);
|
| + scoped_ptr<ActionInfo> result(new ActionInfo(action_type));
|
|
|
| if (manifest_version_ == 1) {
|
| const ListValue* icons = NULL;
|
| @@ -818,10 +815,11 @@ scoped_ptr<ExtensionAction> Extension::LoadExtensionActionHelper(
|
| std::string path;
|
| if (!(*iter)->GetAsString(&path) || path.empty()) {
|
| *error = ASCIIToUTF16(errors::kInvalidPageActionIconPath);
|
| - return scoped_ptr<ExtensionAction>();
|
| + return scoped_ptr<ActionInfo>();
|
| }
|
|
|
| - result->icon_paths()->push_back(path);
|
| + result->default_icon_path = path;
|
| + break;
|
| }
|
| }
|
|
|
| @@ -829,9 +827,9 @@ scoped_ptr<ExtensionAction> Extension::LoadExtensionActionHelper(
|
| if (extension_action->HasKey(keys::kPageActionId)) {
|
| if (!extension_action->GetString(keys::kPageActionId, &id)) {
|
| *error = ASCIIToUTF16(errors::kInvalidPageActionId);
|
| - return scoped_ptr<ExtensionAction>();
|
| + return scoped_ptr<ActionInfo>();
|
| }
|
| - result->set_id(id);
|
| + result->id = id;
|
| }
|
| }
|
|
|
| @@ -842,9 +840,9 @@ scoped_ptr<ExtensionAction> Extension::LoadExtensionActionHelper(
|
| &default_icon) ||
|
| default_icon.empty()) {
|
| *error = ASCIIToUTF16(errors::kInvalidPageActionIconPath);
|
| - return scoped_ptr<ExtensionAction>();
|
| + return scoped_ptr<ActionInfo>();
|
| }
|
| - result->set_default_icon_path(default_icon);
|
| + result->default_icon_path = default_icon;
|
| }
|
|
|
| // Read the page action title from |default_title| if present, |name| if not
|
| @@ -853,15 +851,15 @@ scoped_ptr<ExtensionAction> Extension::LoadExtensionActionHelper(
|
| if (extension_action->HasKey(keys::kPageActionDefaultTitle)) {
|
| if (!extension_action->GetString(keys::kPageActionDefaultTitle, &title)) {
|
| *error = ASCIIToUTF16(errors::kInvalidPageActionDefaultTitle);
|
| - return scoped_ptr<ExtensionAction>();
|
| + return scoped_ptr<ActionInfo>();
|
| }
|
| } else if (manifest_version_ == 1 && extension_action->HasKey(keys::kName)) {
|
| if (!extension_action->GetString(keys::kName, &title)) {
|
| *error = ASCIIToUTF16(errors::kInvalidPageActionName);
|
| - return scoped_ptr<ExtensionAction>();
|
| + return scoped_ptr<ActionInfo>();
|
| }
|
| }
|
| - result->SetTitle(ExtensionAction::kDefaultTabId, title);
|
| + result->default_title = title;
|
|
|
| // Read the action's |popup| (optional).
|
| const char* popup_key = NULL;
|
| @@ -875,7 +873,7 @@ scoped_ptr<ExtensionAction> Extension::LoadExtensionActionHelper(
|
| errors::kInvalidPageActionOldAndNewKeys,
|
| keys::kPageActionDefaultPopup,
|
| keys::kPageActionPopup);
|
| - return scoped_ptr<ExtensionAction>();
|
| + return scoped_ptr<ActionInfo>();
|
| }
|
| popup_key = keys::kPageActionPopup;
|
| }
|
| @@ -891,11 +889,11 @@ scoped_ptr<ExtensionAction> Extension::LoadExtensionActionHelper(
|
| if (!popup->GetString(keys::kPageActionPopupPath, &url_str)) {
|
| *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
| errors::kInvalidPageActionPopupPath, "<missing>");
|
| - return scoped_ptr<ExtensionAction>();
|
| + return scoped_ptr<ActionInfo>();
|
| }
|
| } else {
|
| *error = ASCIIToUTF16(errors::kInvalidPageActionPopup);
|
| - return scoped_ptr<ExtensionAction>();
|
| + return scoped_ptr<ActionInfo>();
|
| }
|
|
|
| if (!url_str.empty()) {
|
| @@ -904,11 +902,11 @@ scoped_ptr<ExtensionAction> Extension::LoadExtensionActionHelper(
|
| if (!url.is_valid()) {
|
| *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
|
| errors::kInvalidPageActionPopupPath, url_str);
|
| - return scoped_ptr<ExtensionAction>();
|
| + return scoped_ptr<ActionInfo>();
|
| }
|
| - result->SetPopupUrl(ExtensionAction::kDefaultTabId, url);
|
| + result->default_popup_url = url;
|
| } else {
|
| - DCHECK(!result->HasPopup(ExtensionAction::kDefaultTabId))
|
| + DCHECK(result->default_popup_url.is_empty())
|
| << "Shouldn't be possible for the popup to be set.";
|
| }
|
| }
|
| @@ -2298,7 +2296,7 @@ bool Extension::LoadPageAction(string16* error) {
|
| // If page_action_value is not NULL, then there was a valid page action.
|
| if (page_action_value) {
|
| page_action_ = LoadExtensionActionHelper(
|
| - page_action_value, ExtensionAction::TYPE_PAGE, error);
|
| + page_action_value, ActionInfo::TYPE_PAGE, error);
|
| if (!page_action_.get())
|
| return false; // Failed to parse page action definition.
|
|
|
| @@ -2321,7 +2319,7 @@ bool Extension::LoadBrowserAction(string16* error) {
|
| }
|
|
|
| browser_action_ = LoadExtensionActionHelper(
|
| - browser_action_value, ExtensionAction::TYPE_BROWSER, error);
|
| + browser_action_value, ActionInfo::TYPE_BROWSER, error);
|
| if (!browser_action_.get())
|
| return false; // Failed to parse browser action definition.
|
| return true;
|
| @@ -2345,12 +2343,11 @@ bool Extension::LoadScriptBadge(string16* error) {
|
| }
|
|
|
| script_badge_ = LoadExtensionActionHelper(
|
| - script_badge_value, ExtensionAction::TYPE_SCRIPT_BADGE, error);
|
| + script_badge_value, ActionInfo::TYPE_SCRIPT_BADGE, error);
|
| if (!script_badge_.get())
|
| return false; // Failed to parse script badge definition.
|
| } else {
|
| - script_badge_.reset(
|
| - new ExtensionAction(id(), ExtensionAction::TYPE_SCRIPT_BADGE));
|
| + script_badge_.reset(new ActionInfo(ActionInfo::TYPE_SCRIPT_BADGE));
|
| }
|
|
|
| // Script badges always use their extension's title and icon so users can rely
|
| @@ -2359,28 +2356,22 @@ bool Extension::LoadScriptBadge(string16* error) {
|
| // that matches the icon of a trusted extension, and users wouldn't be warned
|
| // during installation.
|
|
|
| - if (!script_badge_->GetTitle(ExtensionAction::kDefaultTabId).empty()) {
|
| + if (!script_badge_->default_title.empty()) {
|
| install_warnings_.push_back(
|
| InstallWarning(InstallWarning::FORMAT_TEXT,
|
| errors::kScriptBadgeTitleIgnored));
|
| }
|
| - script_badge_->SetTitle(ExtensionAction::kDefaultTabId, name());
|
| + script_badge_->default_title = name();
|
|
|
| - if (!script_badge_->default_icon_path().empty()) {
|
| + if (!script_badge_->default_icon_path.empty()) {
|
| install_warnings_.push_back(
|
| InstallWarning(InstallWarning::FORMAT_TEXT,
|
| errors::kScriptBadgeIconIgnored));
|
| }
|
| - std::string icon16_path = icons().Get(extension_misc::EXTENSION_ICON_BITTY,
|
| - ExtensionIconSet::MATCH_EXACTLY);
|
| - if (!icon16_path.empty()) {
|
| - script_badge_->set_default_icon_path(icon16_path);
|
| - } else {
|
| - script_badge_->SetIcon(
|
| - ExtensionAction::kDefaultTabId,
|
| - ui::ResourceBundle::GetSharedInstance().GetImageNamed(
|
| - IDR_EXTENSIONS_FAVICON));
|
| - }
|
| +
|
| + script_badge_->default_icon_path =
|
| + icons().Get(extension_misc::EXTENSION_ICON_BITTY,
|
| + ExtensionIconSet::MATCH_EXACTLY);
|
|
|
| return true;
|
| }
|
| @@ -3199,20 +3190,14 @@ std::set<FilePath> Extension::GetBrowserImages() const {
|
|
|
| // Page action icons.
|
| if (page_action()) {
|
| - std::vector<std::string>* icon_paths = page_action()->icon_paths();
|
| - for (std::vector<std::string>::iterator iter = icon_paths->begin();
|
| - iter != icon_paths->end(); ++iter) {
|
| - image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(*iter)));
|
| - }
|
| + image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(
|
| + page_action()->default_icon_path)));
|
| }
|
|
|
| // Browser action icons.
|
| if (browser_action()) {
|
| - std::vector<std::string>* icon_paths = browser_action()->icon_paths();
|
| - for (std::vector<std::string>::iterator iter = icon_paths->begin();
|
| - iter != icon_paths->end(); ++iter) {
|
| - image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(*iter)));
|
| - }
|
| + image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(
|
| + browser_action()->default_icon_path)));
|
| }
|
|
|
| return image_paths;
|
|
|