| 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 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 | 1611 |
| 1612 // Initialize themes (if present). | 1612 // Initialize themes (if present). |
| 1613 is_theme_ = false; | 1613 is_theme_ = false; |
| 1614 if (source.HasKey(keys::kTheme)) { | 1614 if (source.HasKey(keys::kTheme)) { |
| 1615 // Themes cannot contain extension keys. | 1615 // Themes cannot contain extension keys. |
| 1616 if (ContainsNonThemeKeys(source)) { | 1616 if (ContainsNonThemeKeys(source)) { |
| 1617 *error = errors::kThemesCannotContainExtensions; | 1617 *error = errors::kThemesCannotContainExtensions; |
| 1618 return false; | 1618 return false; |
| 1619 } | 1619 } |
| 1620 | 1620 |
| 1621 DictionaryValue* theme_value; | 1621 DictionaryValue* theme_value = NULL; |
| 1622 if (!source.GetDictionary(keys::kTheme, &theme_value)) { | 1622 if (!source.GetDictionary(keys::kTheme, &theme_value)) { |
| 1623 *error = errors::kInvalidTheme; | 1623 *error = errors::kInvalidTheme; |
| 1624 return false; | 1624 return false; |
| 1625 } | 1625 } |
| 1626 is_theme_ = true; | 1626 is_theme_ = true; |
| 1627 | 1627 |
| 1628 DictionaryValue* images_value; | 1628 DictionaryValue* images_value = NULL; |
| 1629 if (theme_value->GetDictionary(keys::kThemeImages, &images_value)) { | 1629 if (theme_value->GetDictionary(keys::kThemeImages, &images_value)) { |
| 1630 // Validate that the images are all strings | 1630 // Validate that the images are all strings |
| 1631 for (DictionaryValue::key_iterator iter = images_value->begin_keys(); | 1631 for (DictionaryValue::key_iterator iter = images_value->begin_keys(); |
| 1632 iter != images_value->end_keys(); ++iter) { | 1632 iter != images_value->end_keys(); ++iter) { |
| 1633 std::string val; | 1633 std::string val; |
| 1634 if (!images_value->GetString(*iter, &val)) { | 1634 if (!images_value->GetString(*iter, &val)) { |
| 1635 *error = errors::kInvalidThemeImages; | 1635 *error = errors::kInvalidThemeImages; |
| 1636 return false; | 1636 return false; |
| 1637 } | 1637 } |
| 1638 } | 1638 } |
| 1639 theme_images_.reset(images_value->DeepCopy()); | 1639 theme_images_.reset(images_value->DeepCopy()); |
| 1640 } | 1640 } |
| 1641 | 1641 |
| 1642 DictionaryValue* colors_value; | 1642 DictionaryValue* colors_value = NULL; |
| 1643 if (theme_value->GetDictionary(keys::kThemeColors, &colors_value)) { | 1643 if (theme_value->GetDictionary(keys::kThemeColors, &colors_value)) { |
| 1644 // Validate that the colors are RGB or RGBA lists | 1644 // Validate that the colors are RGB or RGBA lists |
| 1645 for (DictionaryValue::key_iterator iter = colors_value->begin_keys(); | 1645 for (DictionaryValue::key_iterator iter = colors_value->begin_keys(); |
| 1646 iter != colors_value->end_keys(); ++iter) { | 1646 iter != colors_value->end_keys(); ++iter) { |
| 1647 ListValue* color_list; | 1647 ListValue* color_list = NULL; |
| 1648 double alpha; | 1648 double alpha = 0.0; |
| 1649 int alpha_int; | 1649 int alpha_int = 0; |
| 1650 int color; | 1650 int color = 0; |
| 1651 // The color must be a list | 1651 // The color must be a list |
| 1652 if (!colors_value->GetListWithoutPathExpansion(*iter, &color_list) || | 1652 if (!colors_value->GetListWithoutPathExpansion(*iter, &color_list) || |
| 1653 // And either 3 items (RGB) or 4 (RGBA) | 1653 // And either 3 items (RGB) or 4 (RGBA) |
| 1654 ((color_list->GetSize() != 3) && | 1654 ((color_list->GetSize() != 3) && |
| 1655 ((color_list->GetSize() != 4) || | 1655 ((color_list->GetSize() != 4) || |
| 1656 // For RGBA, the fourth item must be a real or int alpha value | 1656 // For RGBA, the fourth item must be a real or int alpha value |
| 1657 (!color_list->GetDouble(3, &alpha) && | 1657 (!color_list->GetDouble(3, &alpha) && |
| 1658 !color_list->GetInteger(3, &alpha_int)))) || | 1658 !color_list->GetInteger(3, &alpha_int)))) || |
| 1659 // For both RGB and RGBA, the first three items must be ints (R,G,B) | 1659 // For both RGB and RGBA, the first three items must be ints (R,G,B) |
| 1660 !color_list->GetInteger(0, &color) || | 1660 !color_list->GetInteger(0, &color) || |
| 1661 !color_list->GetInteger(1, &color) || | 1661 !color_list->GetInteger(1, &color) || |
| 1662 !color_list->GetInteger(2, &color)) { | 1662 !color_list->GetInteger(2, &color)) { |
| 1663 *error = errors::kInvalidThemeColors; | 1663 *error = errors::kInvalidThemeColors; |
| 1664 return false; | 1664 return false; |
| 1665 } | 1665 } |
| 1666 } | 1666 } |
| 1667 theme_colors_.reset(colors_value->DeepCopy()); | 1667 theme_colors_.reset(colors_value->DeepCopy()); |
| 1668 } | 1668 } |
| 1669 | 1669 |
| 1670 DictionaryValue* tints_value; | 1670 DictionaryValue* tints_value = NULL; |
| 1671 if (theme_value->GetDictionary(keys::kThemeTints, &tints_value)) { | 1671 if (theme_value->GetDictionary(keys::kThemeTints, &tints_value)) { |
| 1672 // Validate that the tints are all reals. | 1672 // Validate that the tints are all reals. |
| 1673 for (DictionaryValue::key_iterator iter = tints_value->begin_keys(); | 1673 for (DictionaryValue::key_iterator iter = tints_value->begin_keys(); |
| 1674 iter != tints_value->end_keys(); ++iter) { | 1674 iter != tints_value->end_keys(); ++iter) { |
| 1675 ListValue* tint_list; | 1675 ListValue* tint_list = NULL; |
| 1676 double v; | 1676 double v = 0.0; |
| 1677 int vi; | 1677 int vi = 0; |
| 1678 if (!tints_value->GetListWithoutPathExpansion(*iter, &tint_list) || | 1678 if (!tints_value->GetListWithoutPathExpansion(*iter, &tint_list) || |
| 1679 tint_list->GetSize() != 3 || | 1679 tint_list->GetSize() != 3 || |
| 1680 !(tint_list->GetDouble(0, &v) || tint_list->GetInteger(0, &vi)) || | 1680 !(tint_list->GetDouble(0, &v) || tint_list->GetInteger(0, &vi)) || |
| 1681 !(tint_list->GetDouble(1, &v) || tint_list->GetInteger(1, &vi)) || | 1681 !(tint_list->GetDouble(1, &v) || tint_list->GetInteger(1, &vi)) || |
| 1682 !(tint_list->GetDouble(2, &v) || tint_list->GetInteger(2, &vi))) { | 1682 !(tint_list->GetDouble(2, &v) || tint_list->GetInteger(2, &vi))) { |
| 1683 *error = errors::kInvalidThemeTints; | 1683 *error = errors::kInvalidThemeTints; |
| 1684 return false; | 1684 return false; |
| 1685 } | 1685 } |
| 1686 } | 1686 } |
| 1687 theme_tints_.reset(tints_value->DeepCopy()); | 1687 theme_tints_.reset(tints_value->DeepCopy()); |
| 1688 } | 1688 } |
| 1689 | 1689 |
| 1690 DictionaryValue* display_properties_value; | 1690 DictionaryValue* display_properties_value = NULL; |
| 1691 if (theme_value->GetDictionary(keys::kThemeDisplayProperties, | 1691 if (theme_value->GetDictionary(keys::kThemeDisplayProperties, |
| 1692 &display_properties_value)) { | 1692 &display_properties_value)) { |
| 1693 theme_display_properties_.reset( | 1693 theme_display_properties_.reset( |
| 1694 display_properties_value->DeepCopy()); | 1694 display_properties_value->DeepCopy()); |
| 1695 } | 1695 } |
| 1696 | 1696 |
| 1697 return true; | 1697 return true; |
| 1698 } | 1698 } |
| 1699 | 1699 |
| 1700 // Initialize plugins (optional). | 1700 // Initialize plugins (optional). |
| 1701 if (source.HasKey(keys::kPlugins)) { | 1701 if (source.HasKey(keys::kPlugins)) { |
| 1702 ListValue* list_value; | 1702 ListValue* list_value = NULL; |
| 1703 if (!source.GetList(keys::kPlugins, &list_value)) { | 1703 if (!source.GetList(keys::kPlugins, &list_value)) { |
| 1704 *error = errors::kInvalidPlugins; | 1704 *error = errors::kInvalidPlugins; |
| 1705 return false; | 1705 return false; |
| 1706 } | 1706 } |
| 1707 | 1707 |
| 1708 #if defined(OS_CHROMEOS) | 1708 #if defined(OS_CHROMEOS) |
| 1709 if (list_value->GetSize() > 0) { | 1709 if (list_value->GetSize() > 0) { |
| 1710 *error = errors::kIllegalPlugins; | 1710 *error = errors::kIllegalPlugins; |
| 1711 return false; | 1711 return false; |
| 1712 } | 1712 } |
| 1713 #endif | 1713 #endif |
| 1714 | 1714 |
| 1715 for (size_t i = 0; i < list_value->GetSize(); ++i) { | 1715 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
| 1716 DictionaryValue* plugin_value; | 1716 DictionaryValue* plugin_value = NULL; |
| 1717 std::string path_str; | 1717 std::string path_str; |
| 1718 bool is_public = false; | 1718 bool is_public = false; |
| 1719 | 1719 |
| 1720 if (!list_value->GetDictionary(i, &plugin_value)) { | 1720 if (!list_value->GetDictionary(i, &plugin_value)) { |
| 1721 *error = errors::kInvalidPlugins; | 1721 *error = errors::kInvalidPlugins; |
| 1722 return false; | 1722 return false; |
| 1723 } | 1723 } |
| 1724 | 1724 |
| 1725 // Get plugins[i].path. | 1725 // Get plugins[i].path. |
| 1726 if (!plugin_value->GetString(keys::kPluginsPath, &path_str)) { | 1726 if (!plugin_value->GetString(keys::kPluginsPath, &path_str)) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1737 return false; | 1737 return false; |
| 1738 } | 1738 } |
| 1739 } | 1739 } |
| 1740 | 1740 |
| 1741 plugins_.push_back(PluginInfo()); | 1741 plugins_.push_back(PluginInfo()); |
| 1742 plugins_.back().path = path().AppendASCII(path_str); | 1742 plugins_.back().path = path().AppendASCII(path_str); |
| 1743 plugins_.back().is_public = is_public; | 1743 plugins_.back().is_public = is_public; |
| 1744 } | 1744 } |
| 1745 } | 1745 } |
| 1746 | 1746 |
| 1747 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1748 switches::kEnableExperimentalExtensionApis) && |
| 1749 source.HasKey(keys::kNaClModules)) { |
| 1750 ListValue* list_value = NULL; |
| 1751 if (!source.GetList(keys::kNaClModules, &list_value)) { |
| 1752 *error = errors::kInvalidNaClModules; |
| 1753 return false; |
| 1754 } |
| 1755 |
| 1756 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
| 1757 DictionaryValue* module_value = NULL; |
| 1758 std::string path_str; |
| 1759 std::string mime_type; |
| 1760 |
| 1761 if (!list_value->GetDictionary(i, &module_value)) { |
| 1762 *error = errors::kInvalidNaClModules; |
| 1763 return false; |
| 1764 } |
| 1765 |
| 1766 // Get nacl_modules[i].path. |
| 1767 if (!module_value->GetString(keys::kNaClModulesPath, &path_str)) { |
| 1768 *error = ExtensionErrorUtils::FormatErrorMessage( |
| 1769 errors::kInvalidNaClModulesPath, base::IntToString(i)); |
| 1770 return false; |
| 1771 } |
| 1772 |
| 1773 // Get nacl_modules[i].mime_type. |
| 1774 if (!module_value->GetString(keys::kNaClModulesMIMEType, &mime_type)) { |
| 1775 *error = ExtensionErrorUtils::FormatErrorMessage( |
| 1776 errors::kInvalidNaClModulesMIMEType, base::IntToString(i)); |
| 1777 return false; |
| 1778 } |
| 1779 |
| 1780 nacl_modules_.push_back(NaClModuleInfo()); |
| 1781 nacl_modules_.back().path = path().AppendASCII(path_str); |
| 1782 nacl_modules_.back().mime_type = mime_type; |
| 1783 } |
| 1784 } |
| 1785 |
| 1747 // Initialize background url (optional). | 1786 // Initialize background url (optional). |
| 1748 if (source.HasKey(keys::kBackground)) { | 1787 if (source.HasKey(keys::kBackground)) { |
| 1749 std::string background_str; | 1788 std::string background_str; |
| 1750 if (!source.GetString(keys::kBackground, &background_str)) { | 1789 if (!source.GetString(keys::kBackground, &background_str)) { |
| 1751 *error = errors::kInvalidBackground; | 1790 *error = errors::kInvalidBackground; |
| 1752 return false; | 1791 return false; |
| 1753 } | 1792 } |
| 1754 background_url_ = GetResourceURL(background_str); | 1793 background_url_ = GetResourceURL(background_str); |
| 1755 } | 1794 } |
| 1756 | 1795 |
| 1757 // Initialize toolstrips. This is deprecated for public use. | 1796 // Initialize toolstrips. This is deprecated for public use. |
| 1758 // NOTE(erikkay) Although deprecated, we intend to preserve this parsing | 1797 // NOTE(erikkay) Although deprecated, we intend to preserve this parsing |
| 1759 // code indefinitely. Please contact me or Joi for details as to why. | 1798 // code indefinitely. Please contact me or Joi for details as to why. |
| 1760 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1799 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1761 switches::kEnableExperimentalExtensionApis) && | 1800 switches::kEnableExperimentalExtensionApis) && |
| 1762 source.HasKey(keys::kToolstrips)) { | 1801 source.HasKey(keys::kToolstrips)) { |
| 1763 ListValue* list_value; | 1802 ListValue* list_value = NULL; |
| 1764 if (!source.GetList(keys::kToolstrips, &list_value)) { | 1803 if (!source.GetList(keys::kToolstrips, &list_value)) { |
| 1765 *error = errors::kInvalidToolstrips; | 1804 *error = errors::kInvalidToolstrips; |
| 1766 return false; | 1805 return false; |
| 1767 } | 1806 } |
| 1768 | 1807 |
| 1769 for (size_t i = 0; i < list_value->GetSize(); ++i) { | 1808 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
| 1770 GURL toolstrip; | 1809 GURL toolstrip; |
| 1771 DictionaryValue* toolstrip_value; | 1810 DictionaryValue* toolstrip_value = NULL; |
| 1772 std::string toolstrip_path; | 1811 std::string toolstrip_path; |
| 1773 if (list_value->GetString(i, &toolstrip_path)) { | 1812 if (list_value->GetString(i, &toolstrip_path)) { |
| 1774 // Support a simple URL value for backwards compatibility. | 1813 // Support a simple URL value for backwards compatibility. |
| 1775 toolstrip = GetResourceURL(toolstrip_path); | 1814 toolstrip = GetResourceURL(toolstrip_path); |
| 1776 } else if (list_value->GetDictionary(i, &toolstrip_value)) { | 1815 } else if (list_value->GetDictionary(i, &toolstrip_value)) { |
| 1777 if (!toolstrip_value->GetString(keys::kToolstripPath, | 1816 if (!toolstrip_value->GetString(keys::kToolstripPath, |
| 1778 &toolstrip_path)) { | 1817 &toolstrip_path)) { |
| 1779 *error = ExtensionErrorUtils::FormatErrorMessage( | 1818 *error = ExtensionErrorUtils::FormatErrorMessage( |
| 1780 errors::kInvalidToolstrip, base::IntToString(i)); | 1819 errors::kInvalidToolstrip, base::IntToString(i)); |
| 1781 return false; | 1820 return false; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1792 | 1831 |
| 1793 // Initialize content scripts (optional). | 1832 // Initialize content scripts (optional). |
| 1794 if (source.HasKey(keys::kContentScripts)) { | 1833 if (source.HasKey(keys::kContentScripts)) { |
| 1795 ListValue* list_value; | 1834 ListValue* list_value; |
| 1796 if (!source.GetList(keys::kContentScripts, &list_value)) { | 1835 if (!source.GetList(keys::kContentScripts, &list_value)) { |
| 1797 *error = errors::kInvalidContentScriptsList; | 1836 *error = errors::kInvalidContentScriptsList; |
| 1798 return false; | 1837 return false; |
| 1799 } | 1838 } |
| 1800 | 1839 |
| 1801 for (size_t i = 0; i < list_value->GetSize(); ++i) { | 1840 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
| 1802 DictionaryValue* content_script; | 1841 DictionaryValue* content_script = NULL; |
| 1803 if (!list_value->GetDictionary(i, &content_script)) { | 1842 if (!list_value->GetDictionary(i, &content_script)) { |
| 1804 *error = ExtensionErrorUtils::FormatErrorMessage( | 1843 *error = ExtensionErrorUtils::FormatErrorMessage( |
| 1805 errors::kInvalidContentScript, base::IntToString(i)); | 1844 errors::kInvalidContentScript, base::IntToString(i)); |
| 1806 return false; | 1845 return false; |
| 1807 } | 1846 } |
| 1808 | 1847 |
| 1809 UserScript script; | 1848 UserScript script; |
| 1810 if (!LoadUserScriptHelper(content_script, i, flags, error, &script)) | 1849 if (!LoadUserScriptHelper(content_script, i, flags, error, &script)) |
| 1811 return false; // Failed to parse script context definition. | 1850 return false; // Failed to parse script context definition. |
| 1812 script.set_extension_id(id()); | 1851 script.set_extension_id(id()); |
| 1813 if (converted_from_user_script_) { | 1852 if (converted_from_user_script_) { |
| 1814 script.set_emulate_greasemonkey(true); | 1853 script.set_emulate_greasemonkey(true); |
| 1815 script.set_match_all_frames(true); // Greasemonkey matches all frames. | 1854 script.set_match_all_frames(true); // Greasemonkey matches all frames. |
| 1816 } | 1855 } |
| 1817 content_scripts_.push_back(script); | 1856 content_scripts_.push_back(script); |
| 1818 } | 1857 } |
| 1819 } | 1858 } |
| 1820 | 1859 |
| 1821 // Initialize page action (optional). | 1860 // Initialize page action (optional). |
| 1822 DictionaryValue* page_action_value = NULL; | 1861 DictionaryValue* page_action_value = NULL; |
| 1823 | 1862 |
| 1824 if (source.HasKey(keys::kPageActions)) { | 1863 if (source.HasKey(keys::kPageActions)) { |
| 1825 ListValue* list_value; | 1864 ListValue* list_value = NULL; |
| 1826 if (!source.GetList(keys::kPageActions, &list_value)) { | 1865 if (!source.GetList(keys::kPageActions, &list_value)) { |
| 1827 *error = errors::kInvalidPageActionsList; | 1866 *error = errors::kInvalidPageActionsList; |
| 1828 return false; | 1867 return false; |
| 1829 } | 1868 } |
| 1830 | 1869 |
| 1831 size_t list_value_length = list_value->GetSize(); | 1870 size_t list_value_length = list_value->GetSize(); |
| 1832 | 1871 |
| 1833 if (list_value_length == 0u) { | 1872 if (list_value_length == 0u) { |
| 1834 // A list with zero items is allowed, and is equivalent to not having | 1873 // A list with zero items is allowed, and is equivalent to not having |
| 1835 // a page_actions key in the manifest. Don't set |page_action_value|. | 1874 // a page_actions key in the manifest. Don't set |page_action_value|. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1852 // If page_action_value is not NULL, then there was a valid page action. | 1891 // If page_action_value is not NULL, then there was a valid page action. |
| 1853 if (page_action_value) { | 1892 if (page_action_value) { |
| 1854 page_action_.reset( | 1893 page_action_.reset( |
| 1855 LoadExtensionActionHelper(page_action_value, error)); | 1894 LoadExtensionActionHelper(page_action_value, error)); |
| 1856 if (!page_action_.get()) | 1895 if (!page_action_.get()) |
| 1857 return false; // Failed to parse page action definition. | 1896 return false; // Failed to parse page action definition. |
| 1858 } | 1897 } |
| 1859 | 1898 |
| 1860 // Initialize browser action (optional). | 1899 // Initialize browser action (optional). |
| 1861 if (source.HasKey(keys::kBrowserAction)) { | 1900 if (source.HasKey(keys::kBrowserAction)) { |
| 1862 DictionaryValue* browser_action_value; | 1901 DictionaryValue* browser_action_value = NULL; |
| 1863 if (!source.GetDictionary(keys::kBrowserAction, &browser_action_value)) { | 1902 if (!source.GetDictionary(keys::kBrowserAction, &browser_action_value)) { |
| 1864 *error = errors::kInvalidBrowserAction; | 1903 *error = errors::kInvalidBrowserAction; |
| 1865 return false; | 1904 return false; |
| 1866 } | 1905 } |
| 1867 | 1906 |
| 1868 browser_action_.reset( | 1907 browser_action_.reset( |
| 1869 LoadExtensionActionHelper(browser_action_value, error)); | 1908 LoadExtensionActionHelper(browser_action_value, error)); |
| 1870 if (!browser_action_.get()) | 1909 if (!browser_action_.get()) |
| 1871 return false; // Failed to parse browser action definition. | 1910 return false; // Failed to parse browser action definition. |
| 1872 } | 1911 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2011 if (source.HasKey(keys::kDefaultLocale)) { | 2050 if (source.HasKey(keys::kDefaultLocale)) { |
| 2012 if (!source.GetString(keys::kDefaultLocale, &default_locale_) || | 2051 if (!source.GetString(keys::kDefaultLocale, &default_locale_) || |
| 2013 !l10n_util::IsValidLocaleSyntax(default_locale_)) { | 2052 !l10n_util::IsValidLocaleSyntax(default_locale_)) { |
| 2014 *error = errors::kInvalidDefaultLocale; | 2053 *error = errors::kInvalidDefaultLocale; |
| 2015 return false; | 2054 return false; |
| 2016 } | 2055 } |
| 2017 } | 2056 } |
| 2018 | 2057 |
| 2019 // Chrome URL overrides (optional) | 2058 // Chrome URL overrides (optional) |
| 2020 if (source.HasKey(keys::kChromeURLOverrides)) { | 2059 if (source.HasKey(keys::kChromeURLOverrides)) { |
| 2021 DictionaryValue* overrides; | 2060 DictionaryValue* overrides = NULL; |
| 2022 if (!source.GetDictionary(keys::kChromeURLOverrides, &overrides)) { | 2061 if (!source.GetDictionary(keys::kChromeURLOverrides, &overrides)) { |
| 2023 *error = errors::kInvalidChromeURLOverrides; | 2062 *error = errors::kInvalidChromeURLOverrides; |
| 2024 return false; | 2063 return false; |
| 2025 } | 2064 } |
| 2026 | 2065 |
| 2027 // Validate that the overrides are all strings | 2066 // Validate that the overrides are all strings |
| 2028 for (DictionaryValue::key_iterator iter = overrides->begin_keys(); | 2067 for (DictionaryValue::key_iterator iter = overrides->begin_keys(); |
| 2029 iter != overrides->end_keys(); ++iter) { | 2068 iter != overrides->end_keys(); ++iter) { |
| 2030 std::string page = *iter; | 2069 std::string page = *iter; |
| 2031 std::string val; | 2070 std::string val; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2071 } | 2110 } |
| 2072 if (!HasApiPermission(Extension::kExperimentalPermission)) { | 2111 if (!HasApiPermission(Extension::kExperimentalPermission)) { |
| 2073 *error = errors::kDevToolsExperimental; | 2112 *error = errors::kDevToolsExperimental; |
| 2074 return false; | 2113 return false; |
| 2075 } | 2114 } |
| 2076 devtools_url_ = GetResourceURL(devtools_str); | 2115 devtools_url_ = GetResourceURL(devtools_str); |
| 2077 } | 2116 } |
| 2078 | 2117 |
| 2079 // Initialize sidebar action (optional). | 2118 // Initialize sidebar action (optional). |
| 2080 if (source.HasKey(keys::kSidebar)) { | 2119 if (source.HasKey(keys::kSidebar)) { |
| 2081 DictionaryValue* sidebar_value; | 2120 DictionaryValue* sidebar_value = NULL; |
| 2082 if (!source.GetDictionary(keys::kSidebar, &sidebar_value)) { | 2121 if (!source.GetDictionary(keys::kSidebar, &sidebar_value)) { |
| 2083 *error = errors::kInvalidSidebar; | 2122 *error = errors::kInvalidSidebar; |
| 2084 return false; | 2123 return false; |
| 2085 } | 2124 } |
| 2086 if (!HasApiPermission(Extension::kExperimentalPermission)) { | 2125 if (!HasApiPermission(Extension::kExperimentalPermission)) { |
| 2087 *error = errors::kSidebarExperimental; | 2126 *error = errors::kSidebarExperimental; |
| 2088 return false; | 2127 return false; |
| 2089 } | 2128 } |
| 2090 sidebar_defaults_.reset(LoadExtensionSidebarDefaults(sidebar_value, error)); | 2129 sidebar_defaults_.reset(LoadExtensionSidebarDefaults(sidebar_value, error)); |
| 2091 if (!sidebar_defaults_.get()) | 2130 if (!sidebar_defaults_.get()) |
| 2092 return false; // Failed to parse sidebar definition. | 2131 return false; // Failed to parse sidebar definition. |
| 2093 } | 2132 } |
| 2094 | 2133 |
| 2095 // Initialize text-to-speech voices (optional). | 2134 // Initialize text-to-speech voices (optional). |
| 2096 if (source.HasKey(keys::kTts)) { | 2135 if (source.HasKey(keys::kTts)) { |
| 2097 DictionaryValue* tts_dict; | 2136 DictionaryValue* tts_dict = NULL; |
| 2098 if (!source.GetDictionary(keys::kTts, &tts_dict)) { | 2137 if (!source.GetDictionary(keys::kTts, &tts_dict)) { |
| 2099 *error = errors::kInvalidTts; | 2138 *error = errors::kInvalidTts; |
| 2100 return false; | 2139 return false; |
| 2101 } | 2140 } |
| 2102 | 2141 |
| 2103 if (tts_dict->HasKey(keys::kTtsVoices)) { | 2142 if (tts_dict->HasKey(keys::kTtsVoices)) { |
| 2104 ListValue* tts_voices; | 2143 ListValue* tts_voices = NULL; |
| 2105 if (!tts_dict->GetList(keys::kTtsVoices, &tts_voices)) { | 2144 if (!tts_dict->GetList(keys::kTtsVoices, &tts_voices)) { |
| 2106 *error = errors::kInvalidTtsVoices; | 2145 *error = errors::kInvalidTtsVoices; |
| 2107 return false; | 2146 return false; |
| 2108 } | 2147 } |
| 2109 | 2148 |
| 2110 for (size_t i = 0; i < tts_voices->GetSize(); i++) { | 2149 for (size_t i = 0; i < tts_voices->GetSize(); i++) { |
| 2111 DictionaryValue* one_tts_voice; | 2150 DictionaryValue* one_tts_voice = NULL; |
| 2112 if (!tts_voices->GetDictionary(i, &one_tts_voice)) { | 2151 if (!tts_voices->GetDictionary(i, &one_tts_voice)) { |
| 2113 *error = errors::kInvalidTtsVoices; | 2152 *error = errors::kInvalidTtsVoices; |
| 2114 return false; | 2153 return false; |
| 2115 } | 2154 } |
| 2116 | 2155 |
| 2117 TtsVoice voice_data; | 2156 TtsVoice voice_data; |
| 2118 if (one_tts_voice->HasKey(keys::kTtsVoicesVoiceName)) { | 2157 if (one_tts_voice->HasKey(keys::kTtsVoicesVoiceName)) { |
| 2119 if (!one_tts_voice->GetString( | 2158 if (!one_tts_voice->GetString( |
| 2120 keys::kTtsVoicesVoiceName, &voice_data.voice_name)) { | 2159 keys::kTtsVoicesVoiceName, &voice_data.voice_name)) { |
| 2121 *error = errors::kInvalidTtsVoicesVoiceName; | 2160 *error = errors::kInvalidTtsVoicesVoiceName; |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2609 | 2648 |
| 2610 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} | 2649 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} |
| 2611 | 2650 |
| 2612 | 2651 |
| 2613 UnloadedExtensionInfo::UnloadedExtensionInfo( | 2652 UnloadedExtensionInfo::UnloadedExtensionInfo( |
| 2614 const Extension* extension, | 2653 const Extension* extension, |
| 2615 Reason reason) | 2654 Reason reason) |
| 2616 : reason(reason), | 2655 : reason(reason), |
| 2617 already_disabled(false), | 2656 already_disabled(false), |
| 2618 extension(extension) {} | 2657 extension(extension) {} |
| OLD | NEW |