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 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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) {} |
OLD | NEW |