Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1684)

Unified Diff: chrome/common/extensions/extension.cc

Issue 12042096: Move page action manifest parsing out of Extension; the first multi-key manifest handler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_file_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension.cc
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 4e9d2225d42d360b1e7bc33224d0c5ae2e01fee0..73c2d524faed6fde21c75e510c223050629e0ac2 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -27,6 +27,7 @@
// TODO(rdevlin.cronin): Remove this once PageAction, BrowserAction, and
// SystemIndicator have been moved out of Extension.
#include "chrome/common/extensions/api/extension_action/action_info.h"
+#include "chrome/common/extensions/api/extension_action/page_action_handler.h"
#include "chrome/common/extensions/api/themes/theme_handler.h"
#include "chrome/common/extensions/csp_validator.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
@@ -825,10 +826,11 @@ std::set<base::FilePath> Extension::GetBrowserImages() const {
}
}
- if (page_action_info() && !page_action_info()->default_icon.empty()) {
+ const ActionInfo* page_action_info = ActionInfo::GetPageActionInfo(this);
+ if (page_action_info && !page_action_info->default_icon.empty()) {
for (ExtensionIconSet::IconMap::const_iterator iter =
- page_action_info()->default_icon.map().begin();
- iter != page_action_info()->default_icon.map().end();
+ page_action_info->default_icon.map().begin();
+ iter != page_action_info->default_icon.map().end();
++iter) {
image_paths.insert(
base::FilePath::FromWStringHack(UTF8ToWide(iter->second)));
@@ -2258,7 +2260,6 @@ bool Extension::LoadExtensionFeatures(APIPermissionSet* api_permissions,
&converted_from_user_script_);
if (!LoadContentScripts(error) ||
- !LoadPageAction(error) ||
!LoadSystemIndicator(api_permissions, error) ||
!LoadIncognitoMode(error) ||
!LoadContentSecurityPolicy(error))
@@ -2297,48 +2298,6 @@ bool Extension::LoadContentScripts(string16* error) {
return true;
}
-bool Extension::LoadPageAction(string16* error) {
- DictionaryValue* page_action_value = NULL;
-
- if (manifest_->HasKey(keys::kPageActions)) {
- ListValue* list_value = NULL;
- if (!manifest_->GetList(keys::kPageActions, &list_value)) {
- *error = ASCIIToUTF16(errors::kInvalidPageActionsList);
- return false;
- }
-
- size_t list_value_length = list_value->GetSize();
-
- if (list_value_length == 0u) {
- // A list with zero items is allowed, and is equivalent to not having
- // a page_actions key in the manifest. Don't set |page_action_value|.
- } else if (list_value_length == 1u) {
- if (!list_value->GetDictionary(0, &page_action_value)) {
- *error = ASCIIToUTF16(errors::kInvalidPageAction);
- return false;
- }
- } else { // list_value_length > 1u.
- *error = ASCIIToUTF16(errors::kInvalidPageActionsListSize);
- return false;
- }
- } else if (manifest_->HasKey(keys::kPageAction)) {
- if (!manifest_->GetDictionary(keys::kPageAction, &page_action_value)) {
- *error = ASCIIToUTF16(errors::kInvalidPageAction);
- return false;
- }
- }
-
- // If page_action_value is not NULL, then there was a valid page action.
- if (page_action_value) {
- page_action_info_ = LoadExtensionActionInfoHelper(
- this, page_action_value, error);
- if (!page_action_info_.get())
- return false; // Failed to parse page action definition.
- }
-
- return true;
-}
-
bool Extension::LoadSystemIndicator(APIPermissionSet* api_permissions,
string16* error) {
if (!manifest_->HasKey(keys::kSystemIndicator)) {
@@ -2669,7 +2628,7 @@ bool Extension::LoadGlobsHelper(
bool Extension::HasMultipleUISurfaces() const {
int num_surfaces = 0;
- if (page_action_info())
+ if (ActionInfo::GetPageActionInfo(this))
++num_surfaces;
if (ActionInfo::GetBrowserActionInfo(this))
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698