| OLD | NEW |
| 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 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 theme_images_.reset(images_value->DeepCopy()); | 1870 theme_images_.reset(images_value->DeepCopy()); |
| 1871 } | 1871 } |
| 1872 | 1872 |
| 1873 DictionaryValue* colors_value = NULL; | 1873 DictionaryValue* colors_value = NULL; |
| 1874 if (theme_value->GetDictionary(keys::kThemeColors, &colors_value)) { | 1874 if (theme_value->GetDictionary(keys::kThemeColors, &colors_value)) { |
| 1875 // Validate that the colors are RGB or RGBA lists | 1875 // Validate that the colors are RGB or RGBA lists |
| 1876 for (DictionaryValue::key_iterator iter = colors_value->begin_keys(); | 1876 for (DictionaryValue::key_iterator iter = colors_value->begin_keys(); |
| 1877 iter != colors_value->end_keys(); ++iter) { | 1877 iter != colors_value->end_keys(); ++iter) { |
| 1878 ListValue* color_list = NULL; | 1878 ListValue* color_list = NULL; |
| 1879 double alpha = 0.0; | 1879 double alpha = 0.0; |
| 1880 int alpha_int = 0; | |
| 1881 int color = 0; | 1880 int color = 0; |
| 1882 // The color must be a list | 1881 // The color must be a list |
| 1883 if (!colors_value->GetListWithoutPathExpansion(*iter, &color_list) || | 1882 if (!colors_value->GetListWithoutPathExpansion(*iter, &color_list) || |
| 1884 // And either 3 items (RGB) or 4 (RGBA) | 1883 // And either 3 items (RGB) or 4 (RGBA) |
| 1885 ((color_list->GetSize() != 3) && | 1884 ((color_list->GetSize() != 3) && |
| 1886 ((color_list->GetSize() != 4) || | 1885 ((color_list->GetSize() != 4) || |
| 1887 // For RGBA, the fourth item must be a real or int alpha value | 1886 // For RGBA, the fourth item must be a real or int alpha value. |
| 1888 (!color_list->GetDouble(3, &alpha) && | 1887 // Note that GetDouble() can get an integer value. |
| 1889 !color_list->GetInteger(3, &alpha_int)))) || | 1888 !color_list->GetDouble(3, &alpha))) || |
| 1890 // For both RGB and RGBA, the first three items must be ints (R,G,B) | 1889 // For both RGB and RGBA, the first three items must be ints (R,G,B) |
| 1891 !color_list->GetInteger(0, &color) || | 1890 !color_list->GetInteger(0, &color) || |
| 1892 !color_list->GetInteger(1, &color) || | 1891 !color_list->GetInteger(1, &color) || |
| 1893 !color_list->GetInteger(2, &color)) { | 1892 !color_list->GetInteger(2, &color)) { |
| 1894 *error = errors::kInvalidThemeColors; | 1893 *error = errors::kInvalidThemeColors; |
| 1895 return false; | 1894 return false; |
| 1896 } | 1895 } |
| 1897 } | 1896 } |
| 1898 theme_colors_.reset(colors_value->DeepCopy()); | 1897 theme_colors_.reset(colors_value->DeepCopy()); |
| 1899 } | 1898 } |
| 1900 | 1899 |
| 1901 DictionaryValue* tints_value = NULL; | 1900 DictionaryValue* tints_value = NULL; |
| 1902 if (theme_value->GetDictionary(keys::kThemeTints, &tints_value)) { | 1901 if (theme_value->GetDictionary(keys::kThemeTints, &tints_value)) { |
| 1903 // Validate that the tints are all reals. | 1902 // Validate that the tints are all reals. |
| 1904 for (DictionaryValue::key_iterator iter = tints_value->begin_keys(); | 1903 for (DictionaryValue::key_iterator iter = tints_value->begin_keys(); |
| 1905 iter != tints_value->end_keys(); ++iter) { | 1904 iter != tints_value->end_keys(); ++iter) { |
| 1906 ListValue* tint_list = NULL; | 1905 ListValue* tint_list = NULL; |
| 1907 double v = 0.0; | 1906 double v = 0.0; |
| 1908 int vi = 0; | |
| 1909 if (!tints_value->GetListWithoutPathExpansion(*iter, &tint_list) || | 1907 if (!tints_value->GetListWithoutPathExpansion(*iter, &tint_list) || |
| 1910 tint_list->GetSize() != 3 || | 1908 tint_list->GetSize() != 3 || |
| 1911 !(tint_list->GetDouble(0, &v) || tint_list->GetInteger(0, &vi)) || | 1909 !tint_list->GetDouble(0, &v) || |
| 1912 !(tint_list->GetDouble(1, &v) || tint_list->GetInteger(1, &vi)) || | 1910 !tint_list->GetDouble(1, &v) || |
| 1913 !(tint_list->GetDouble(2, &v) || tint_list->GetInteger(2, &vi))) { | 1911 !tint_list->GetDouble(2, &v)) { |
| 1914 *error = errors::kInvalidThemeTints; | 1912 *error = errors::kInvalidThemeTints; |
| 1915 return false; | 1913 return false; |
| 1916 } | 1914 } |
| 1917 } | 1915 } |
| 1918 theme_tints_.reset(tints_value->DeepCopy()); | 1916 theme_tints_.reset(tints_value->DeepCopy()); |
| 1919 } | 1917 } |
| 1920 | 1918 |
| 1921 DictionaryValue* display_properties_value = NULL; | 1919 DictionaryValue* display_properties_value = NULL; |
| 1922 if (theme_value->GetDictionary(keys::kThemeDisplayProperties, | 1920 if (theme_value->GetDictionary(keys::kThemeDisplayProperties, |
| 1923 &display_properties_value)) { | 1921 &display_properties_value)) { |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2947 | 2945 |
| 2948 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} | 2946 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} |
| 2949 | 2947 |
| 2950 | 2948 |
| 2951 UnloadedExtensionInfo::UnloadedExtensionInfo( | 2949 UnloadedExtensionInfo::UnloadedExtensionInfo( |
| 2952 const Extension* extension, | 2950 const Extension* extension, |
| 2953 Reason reason) | 2951 Reason reason) |
| 2954 : reason(reason), | 2952 : reason(reason), |
| 2955 already_disabled(false), | 2953 already_disabled(false), |
| 2956 extension(extension) {} | 2954 extension(extension) {} |
| OLD | NEW |