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

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 6901084: Use new APIs in base/values.h: Value::GetAsNumber and DictionaryValue::GetNumber. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, 2010->2011 Created 9 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/themes/browser_theme_pack.cc ('k') | chrome/common/json_schema_validator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/extensions/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 theme_images_.reset(images_value->DeepCopy()); 1875 theme_images_.reset(images_value->DeepCopy());
1876 } 1876 }
1877 1877
1878 DictionaryValue* colors_value = NULL; 1878 DictionaryValue* colors_value = NULL;
1879 if (theme_value->GetDictionary(keys::kThemeColors, &colors_value)) { 1879 if (theme_value->GetDictionary(keys::kThemeColors, &colors_value)) {
1880 // Validate that the colors are RGB or RGBA lists 1880 // Validate that the colors are RGB or RGBA lists
1881 for (DictionaryValue::key_iterator iter = colors_value->begin_keys(); 1881 for (DictionaryValue::key_iterator iter = colors_value->begin_keys();
1882 iter != colors_value->end_keys(); ++iter) { 1882 iter != colors_value->end_keys(); ++iter) {
1883 ListValue* color_list = NULL; 1883 ListValue* color_list = NULL;
1884 double alpha = 0.0; 1884 double alpha = 0.0;
1885 int alpha_int = 0;
1886 int color = 0; 1885 int color = 0;
1887 // The color must be a list 1886 // The color must be a list
1888 if (!colors_value->GetListWithoutPathExpansion(*iter, &color_list) || 1887 if (!colors_value->GetListWithoutPathExpansion(*iter, &color_list) ||
1889 // And either 3 items (RGB) or 4 (RGBA) 1888 // And either 3 items (RGB) or 4 (RGBA)
1890 ((color_list->GetSize() != 3) && 1889 ((color_list->GetSize() != 3) &&
1891 ((color_list->GetSize() != 4) || 1890 ((color_list->GetSize() != 4) ||
1892 // For RGBA, the fourth item must be a real or int alpha value 1891 // For RGBA, the fourth item must be a real or int alpha value.
1893 (!color_list->GetDouble(3, &alpha) && 1892 // Note that GetDouble() can get an integer value.
1894 !color_list->GetInteger(3, &alpha_int)))) || 1893 !color_list->GetDouble(3, &alpha))) ||
1895 // For both RGB and RGBA, the first three items must be ints (R,G,B) 1894 // For both RGB and RGBA, the first three items must be ints (R,G,B)
1896 !color_list->GetInteger(0, &color) || 1895 !color_list->GetInteger(0, &color) ||
1897 !color_list->GetInteger(1, &color) || 1896 !color_list->GetInteger(1, &color) ||
1898 !color_list->GetInteger(2, &color)) { 1897 !color_list->GetInteger(2, &color)) {
1899 *error = errors::kInvalidThemeColors; 1898 *error = errors::kInvalidThemeColors;
1900 return false; 1899 return false;
1901 } 1900 }
1902 } 1901 }
1903 theme_colors_.reset(colors_value->DeepCopy()); 1902 theme_colors_.reset(colors_value->DeepCopy());
1904 } 1903 }
1905 1904
1906 DictionaryValue* tints_value = NULL; 1905 DictionaryValue* tints_value = NULL;
1907 if (theme_value->GetDictionary(keys::kThemeTints, &tints_value)) { 1906 if (theme_value->GetDictionary(keys::kThemeTints, &tints_value)) {
1908 // Validate that the tints are all reals. 1907 // Validate that the tints are all reals.
1909 for (DictionaryValue::key_iterator iter = tints_value->begin_keys(); 1908 for (DictionaryValue::key_iterator iter = tints_value->begin_keys();
1910 iter != tints_value->end_keys(); ++iter) { 1909 iter != tints_value->end_keys(); ++iter) {
1911 ListValue* tint_list = NULL; 1910 ListValue* tint_list = NULL;
1912 double v = 0.0; 1911 double v = 0.0;
1913 int vi = 0;
1914 if (!tints_value->GetListWithoutPathExpansion(*iter, &tint_list) || 1912 if (!tints_value->GetListWithoutPathExpansion(*iter, &tint_list) ||
1915 tint_list->GetSize() != 3 || 1913 tint_list->GetSize() != 3 ||
1916 !(tint_list->GetDouble(0, &v) || tint_list->GetInteger(0, &vi)) || 1914 !tint_list->GetDouble(0, &v) ||
1917 !(tint_list->GetDouble(1, &v) || tint_list->GetInteger(1, &vi)) || 1915 !tint_list->GetDouble(1, &v) ||
1918 !(tint_list->GetDouble(2, &v) || tint_list->GetInteger(2, &vi))) { 1916 !tint_list->GetDouble(2, &v)) {
1919 *error = errors::kInvalidThemeTints; 1917 *error = errors::kInvalidThemeTints;
1920 return false; 1918 return false;
1921 } 1919 }
1922 } 1920 }
1923 theme_tints_.reset(tints_value->DeepCopy()); 1921 theme_tints_.reset(tints_value->DeepCopy());
1924 } 1922 }
1925 1923
1926 DictionaryValue* display_properties_value = NULL; 1924 DictionaryValue* display_properties_value = NULL;
1927 if (theme_value->GetDictionary(keys::kThemeDisplayProperties, 1925 if (theme_value->GetDictionary(keys::kThemeDisplayProperties,
1928 &display_properties_value)) { 1926 &display_properties_value)) {
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
2952 2950
2953 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} 2951 UninstalledExtensionInfo::~UninstalledExtensionInfo() {}
2954 2952
2955 2953
2956 UnloadedExtensionInfo::UnloadedExtensionInfo( 2954 UnloadedExtensionInfo::UnloadedExtensionInfo(
2957 const Extension* extension, 2955 const Extension* extension,
2958 Reason reason) 2956 Reason reason)
2959 : reason(reason), 2957 : reason(reason),
2960 already_disabled(false), 2958 already_disabled(false),
2961 extension(extension) {} 2959 extension(extension) {}
OLDNEW
« no previous file with comments | « chrome/browser/themes/browser_theme_pack.cc ('k') | chrome/common/json_schema_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698