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

Unified Diff: chrome/common/extensions/manifest_handlers/theme_handler.cc

Issue 13473013: Move ThemeHandler from c/c/e/api; move GetBrowserImages() out of Extension class (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master (+blink) Created 7 years, 8 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
Index: chrome/common/extensions/manifest_handlers/theme_handler.cc
diff --git a/chrome/common/extensions/api/themes/theme_handler.cc b/chrome/common/extensions/manifest_handlers/theme_handler.cc
similarity index 69%
rename from chrome/common/extensions/api/themes/theme_handler.cc
rename to chrome/common/extensions/manifest_handlers/theme_handler.cc
index 1c161fa39ed0d75a6460e0a520dffe35ce3531a5..5121cb1656e9832a0b72aa55077769d751b31e98 100644
--- a/chrome/common/extensions/api/themes/theme_handler.cc
+++ b/chrome/common/extensions/manifest_handlers/theme_handler.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/common/extensions/api/themes/theme_handler.h"
+#include "chrome/common/extensions/manifest_handlers/theme_handler.h"
#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
@@ -20,13 +20,13 @@ namespace errors = extension_manifest_errors;
namespace {
-bool LoadThemeImages(const DictionaryValue* theme_value,
- string16* error,
- ThemeInfo* theme_info) {
- const DictionaryValue* images_value = NULL;
+bool LoadImages(const base::DictionaryValue* theme_value,
+ string16* error,
+ ThemeInfo* theme_info) {
+ const base::DictionaryValue* images_value = NULL;
Yoyo Zhou 2013/04/10 21:44:58 It's ok to use using base::DictionaryValue; in a .
Devlin 2013/04/12 02:17:06 Yeah; I just wanted to not be using base::Dictiona
if (theme_value->GetDictionary(keys::kThemeImages, &images_value)) {
// Validate that the images are all strings.
- for (DictionaryValue::Iterator iter(*images_value); !iter.IsAtEnd();
+ for (base::DictionaryValue::Iterator iter(*images_value); !iter.IsAtEnd();
iter.Advance()) {
if (!iter.value().IsType(Value::TYPE_STRING)) {
*error = ASCIIToUTF16(errors::kInvalidThemeImages);
@@ -38,13 +38,13 @@ bool LoadThemeImages(const DictionaryValue* theme_value,
return true;
}
-bool LoadThemeColors(const DictionaryValue* theme_value,
- string16* error,
- ThemeInfo* theme_info) {
- const DictionaryValue* colors_value = NULL;
+bool LoadColors(const base::DictionaryValue* theme_value,
+ string16* error,
+ ThemeInfo* theme_info) {
+ const base::DictionaryValue* colors_value = NULL;
if (theme_value->GetDictionary(keys::kThemeColors, &colors_value)) {
// Validate that the colors are RGB or RGBA lists.
- for (DictionaryValue::Iterator iter(*colors_value); !iter.IsAtEnd();
+ for (base::DictionaryValue::Iterator iter(*colors_value); !iter.IsAtEnd();
iter.Advance()) {
const ListValue* color_list = NULL;
double alpha = 0.0;
@@ -70,15 +70,15 @@ bool LoadThemeColors(const DictionaryValue* theme_value,
return true;
}
-bool LoadThemeTints(const DictionaryValue* theme_value,
- string16* error,
- ThemeInfo* theme_info) {
- const DictionaryValue* tints_value = NULL;
+bool LoadTints(const base::DictionaryValue* theme_value,
+ string16* error,
+ ThemeInfo* theme_info) {
+ const base::DictionaryValue* tints_value = NULL;
if (!theme_value->GetDictionary(keys::kThemeTints, &tints_value))
return true;
// Validate that the tints are all reals.
- for (DictionaryValue::Iterator iter(*tints_value); !iter.IsAtEnd();
+ for (base::DictionaryValue::Iterator iter(*tints_value); !iter.IsAtEnd();
iter.Advance()) {
const ListValue* tint_list = NULL;
double v = 0.0;
@@ -95,10 +95,10 @@ bool LoadThemeTints(const DictionaryValue* theme_value,
return true;
}
-bool LoadThemeDisplayProperties(const DictionaryValue* theme_value,
- string16* error,
- ThemeInfo* theme_info) {
- const DictionaryValue* display_properties_value = NULL;
+bool LoadDisplayProperties(const base::DictionaryValue* theme_value,
+ string16* error,
+ ThemeInfo* theme_info) {
+ const base::DictionaryValue* display_properties_value = NULL;
if (theme_value->GetDictionary(keys::kThemeDisplayProperties,
&display_properties_value)) {
theme_info->theme_display_properties_.reset(
@@ -107,7 +107,7 @@ bool LoadThemeDisplayProperties(const DictionaryValue* theme_value,
return true;
}
-const ThemeInfo* GetThemeInfo(const Extension* extension) {
+const ThemeInfo* GetInfo(const Extension* extension) {
return static_cast<ThemeInfo*>(extension->GetManifestData(keys::kTheme));
}
@@ -120,27 +120,27 @@ ThemeInfo::~ThemeInfo() {
}
// static
-DictionaryValue* ThemeInfo::GetThemeImages(const Extension* extension) {
- const ThemeInfo* theme_info = GetThemeInfo(extension);
+const base::DictionaryValue* ThemeInfo::GetImages(const Extension* extension) {
+ const ThemeInfo* theme_info = GetInfo(extension);
return theme_info ? theme_info->theme_images_.get() : NULL;
}
// static
-DictionaryValue* ThemeInfo::GetThemeColors(const Extension* extension) {
- const ThemeInfo* theme_info = GetThemeInfo(extension);
+const base::DictionaryValue* ThemeInfo::GetColors(const Extension* extension) {
+ const ThemeInfo* theme_info = GetInfo(extension);
return theme_info ? theme_info->theme_colors_.get() : NULL;
}
// static
-DictionaryValue* ThemeInfo::GetThemeTints(const Extension* extension) {
- const ThemeInfo* theme_info = GetThemeInfo(extension);
+const base::DictionaryValue* ThemeInfo::GetTints(const Extension* extension) {
+ const ThemeInfo* theme_info = GetInfo(extension);
return theme_info ? theme_info->theme_tints_.get() : NULL;
}
// static
-DictionaryValue* ThemeInfo::GetThemeDisplayProperties(
+const base::DictionaryValue* ThemeInfo::GetDisplayProperties(
const Extension* extension) {
- const ThemeInfo* theme_info = GetThemeInfo(extension);
+ const ThemeInfo* theme_info = GetInfo(extension);
return theme_info ? theme_info->theme_display_properties_.get() : NULL;
}
@@ -151,20 +151,20 @@ ThemeHandler::~ThemeHandler() {
}
bool ThemeHandler::Parse(Extension* extension, string16* error) {
- const DictionaryValue* theme_value = NULL;
+ const base::DictionaryValue* theme_value = NULL;
if (!extension->manifest()->GetDictionary(keys::kTheme, &theme_value)) {
*error = ASCIIToUTF16(errors::kInvalidTheme);
return false;
}
scoped_ptr<ThemeInfo> theme_info(new ThemeInfo);
- if (!LoadThemeImages(theme_value, error, theme_info.get()))
+ if (!LoadImages(theme_value, error, theme_info.get()))
return false;
- if (!LoadThemeColors(theme_value, error, theme_info.get()))
+ if (!LoadColors(theme_value, error, theme_info.get()))
return false;
- if (!LoadThemeTints(theme_value, error, theme_info.get()))
+ if (!LoadTints(theme_value, error, theme_info.get()))
return false;
- if (!LoadThemeDisplayProperties(theme_value, error, theme_info.get()))
+ if (!LoadDisplayProperties(theme_value, error, theme_info.get()))
return false;
extension->SetManifestData(keys::kTheme, theme_info.release());
@@ -176,10 +176,10 @@ bool ThemeHandler::Validate(const Extension* extension,
std::vector<InstallWarning>* warnings) const {
// Validate that theme images exist.
if (extension->is_theme()) {
- DictionaryValue* images_value =
- extensions::ThemeInfo::GetThemeImages(extension);
+ const base::DictionaryValue* images_value =
+ extensions::ThemeInfo::GetImages(extension);
if (images_value) {
- for (DictionaryValue::Iterator iter(*images_value); !iter.IsAtEnd();
+ for (base::DictionaryValue::Iterator iter(*images_value); !iter.IsAtEnd();
iter.Advance()) {
std::string val;
if (iter.value().GetAsString(&val)) {

Powered by Google App Engine
This is Rietveld 408576698