| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 bool all_frames = false; | 591 bool all_frames = false; |
| 592 if (!content_script->GetBoolean(keys::kAllFrames, &all_frames)) { | 592 if (!content_script->GetBoolean(keys::kAllFrames, &all_frames)) { |
| 593 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 593 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 594 errors::kInvalidAllFrames, base::IntToString(definition_index)); | 594 errors::kInvalidAllFrames, base::IntToString(definition_index)); |
| 595 return false; | 595 return false; |
| 596 } | 596 } |
| 597 result->set_match_all_frames(all_frames); | 597 result->set_match_all_frames(all_frames); |
| 598 } | 598 } |
| 599 | 599 |
| 600 // matches (required) | 600 // matches (required) |
| 601 ListValue* matches = NULL; | 601 const ListValue* matches = NULL; |
| 602 if (!content_script->GetList(keys::kMatches, &matches)) { | 602 if (!content_script->GetList(keys::kMatches, &matches)) { |
| 603 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 603 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 604 errors::kInvalidMatches, | 604 errors::kInvalidMatches, |
| 605 base::IntToString(definition_index)); | 605 base::IntToString(definition_index)); |
| 606 return false; | 606 return false; |
| 607 } | 607 } |
| 608 | 608 |
| 609 if (matches->GetSize() == 0) { | 609 if (matches->GetSize() == 0) { |
| 610 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 610 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 611 errors::kInvalidMatchCount, | 611 errors::kInvalidMatchCount, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 if (!(creation_flags_ & ALLOW_FILE_ACCESS)) | 643 if (!(creation_flags_ & ALLOW_FILE_ACCESS)) |
| 644 pattern.SetValidSchemes( | 644 pattern.SetValidSchemes( |
| 645 pattern.valid_schemes() & ~URLPattern::SCHEME_FILE); | 645 pattern.valid_schemes() & ~URLPattern::SCHEME_FILE); |
| 646 } | 646 } |
| 647 | 647 |
| 648 result->add_url_pattern(pattern); | 648 result->add_url_pattern(pattern); |
| 649 } | 649 } |
| 650 | 650 |
| 651 // exclude_matches | 651 // exclude_matches |
| 652 if (content_script->HasKey(keys::kExcludeMatches)) { // optional | 652 if (content_script->HasKey(keys::kExcludeMatches)) { // optional |
| 653 ListValue* exclude_matches = NULL; | 653 const ListValue* exclude_matches = NULL; |
| 654 if (!content_script->GetList(keys::kExcludeMatches, &exclude_matches)) { | 654 if (!content_script->GetList(keys::kExcludeMatches, &exclude_matches)) { |
| 655 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 655 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 656 errors::kInvalidExcludeMatches, | 656 errors::kInvalidExcludeMatches, |
| 657 base::IntToString(definition_index)); | 657 base::IntToString(definition_index)); |
| 658 return false; | 658 return false; |
| 659 } | 659 } |
| 660 | 660 |
| 661 for (size_t j = 0; j < exclude_matches->GetSize(); ++j) { | 661 for (size_t j = 0; j < exclude_matches->GetSize(); ++j) { |
| 662 std::string match_str; | 662 std::string match_str; |
| 663 if (!exclude_matches->GetString(j, &match_str)) { | 663 if (!exclude_matches->GetString(j, &match_str)) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 690 error, &UserScript::add_glob, result)) { | 690 error, &UserScript::add_glob, result)) { |
| 691 return false; | 691 return false; |
| 692 } | 692 } |
| 693 | 693 |
| 694 if (!LoadGlobsHelper(content_script, definition_index, keys::kExcludeGlobs, | 694 if (!LoadGlobsHelper(content_script, definition_index, keys::kExcludeGlobs, |
| 695 error, &UserScript::add_exclude_glob, result)) { | 695 error, &UserScript::add_exclude_glob, result)) { |
| 696 return false; | 696 return false; |
| 697 } | 697 } |
| 698 | 698 |
| 699 // js and css keys | 699 // js and css keys |
| 700 ListValue* js = NULL; | 700 const ListValue* js = NULL; |
| 701 if (content_script->HasKey(keys::kJs) && | 701 if (content_script->HasKey(keys::kJs) && |
| 702 !content_script->GetList(keys::kJs, &js)) { | 702 !content_script->GetList(keys::kJs, &js)) { |
| 703 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 703 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 704 errors::kInvalidJsList, | 704 errors::kInvalidJsList, |
| 705 base::IntToString(definition_index)); | 705 base::IntToString(definition_index)); |
| 706 return false; | 706 return false; |
| 707 } | 707 } |
| 708 | 708 |
| 709 ListValue* css = NULL; | 709 const ListValue* css = NULL; |
| 710 if (content_script->HasKey(keys::kCss) && | 710 if (content_script->HasKey(keys::kCss) && |
| 711 !content_script->GetList(keys::kCss, &css)) { | 711 !content_script->GetList(keys::kCss, &css)) { |
| 712 *error = ExtensionErrorUtils:: | 712 *error = ExtensionErrorUtils:: |
| 713 FormatErrorMessageUTF16(errors::kInvalidCssList, | 713 FormatErrorMessageUTF16(errors::kInvalidCssList, |
| 714 base::IntToString(definition_index)); | 714 base::IntToString(definition_index)); |
| 715 return false; | 715 return false; |
| 716 } | 716 } |
| 717 | 717 |
| 718 // The manifest needs to have at least one js or css user script definition. | 718 // The manifest needs to have at least one js or css user script definition. |
| 719 if (((js ? js->GetSize() : 0) + (css ? css->GetSize() : 0)) == 0) { | 719 if (((js ? js->GetSize() : 0) + (css ? css->GetSize() : 0)) == 0) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 bool Extension::LoadGlobsHelper( | 767 bool Extension::LoadGlobsHelper( |
| 768 const DictionaryValue* content_script, | 768 const DictionaryValue* content_script, |
| 769 int content_script_index, | 769 int content_script_index, |
| 770 const char* globs_property_name, | 770 const char* globs_property_name, |
| 771 string16* error, | 771 string16* error, |
| 772 void(UserScript::*add_method)(const std::string& glob), | 772 void(UserScript::*add_method)(const std::string& glob), |
| 773 UserScript* instance) { | 773 UserScript* instance) { |
| 774 if (!content_script->HasKey(globs_property_name)) | 774 if (!content_script->HasKey(globs_property_name)) |
| 775 return true; // they are optional | 775 return true; // they are optional |
| 776 | 776 |
| 777 ListValue* list = NULL; | 777 const ListValue* list = NULL; |
| 778 if (!content_script->GetList(globs_property_name, &list)) { | 778 if (!content_script->GetList(globs_property_name, &list)) { |
| 779 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 779 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 780 errors::kInvalidGlobList, | 780 errors::kInvalidGlobList, |
| 781 base::IntToString(content_script_index), | 781 base::IntToString(content_script_index), |
| 782 globs_property_name); | 782 globs_property_name); |
| 783 return false; | 783 return false; |
| 784 } | 784 } |
| 785 | 785 |
| 786 for (size_t i = 0; i < list->GetSize(); ++i) { | 786 for (size_t i = 0; i < list->GetSize(); ++i) { |
| 787 std::string glob; | 787 std::string glob; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 805 ExtensionAction::Type action_type, | 805 ExtensionAction::Type action_type, |
| 806 string16* error) { | 806 string16* error) { |
| 807 scoped_ptr<ExtensionAction> result(new ExtensionAction(id(), action_type)); | 807 scoped_ptr<ExtensionAction> result(new ExtensionAction(id(), action_type)); |
| 808 | 808 |
| 809 // Page actions are hidden/disabled by default, and browser actions are | 809 // Page actions are hidden/disabled by default, and browser actions are |
| 810 // visible/enabled by default. | 810 // visible/enabled by default. |
| 811 result->SetIsVisible(ExtensionAction::kDefaultTabId, | 811 result->SetIsVisible(ExtensionAction::kDefaultTabId, |
| 812 action_type != ExtensionAction::TYPE_PAGE); | 812 action_type != ExtensionAction::TYPE_PAGE); |
| 813 | 813 |
| 814 if (manifest_version_ == 1) { | 814 if (manifest_version_ == 1) { |
| 815 ListValue* icons = NULL; | 815 const ListValue* icons = NULL; |
| 816 if (extension_action->HasKey(keys::kPageActionIcons) && | 816 if (extension_action->HasKey(keys::kPageActionIcons) && |
| 817 extension_action->GetList(keys::kPageActionIcons, &icons)) { | 817 extension_action->GetList(keys::kPageActionIcons, &icons)) { |
| 818 for (ListValue::const_iterator iter = icons->begin(); | 818 for (ListValue::const_iterator iter = icons->begin(); |
| 819 iter != icons->end(); ++iter) { | 819 iter != icons->end(); ++iter) { |
| 820 std::string path; | 820 std::string path; |
| 821 if (!(*iter)->GetAsString(&path) || path.empty()) { | 821 if (!(*iter)->GetAsString(&path) || path.empty()) { |
| 822 *error = ASCIIToUTF16(errors::kInvalidPageActionIconPath); | 822 *error = ASCIIToUTF16(errors::kInvalidPageActionIconPath); |
| 823 return scoped_ptr<ExtensionAction>(); | 823 return scoped_ptr<ExtensionAction>(); |
| 824 } | 824 } |
| 825 | 825 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 876 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 877 errors::kInvalidPageActionOldAndNewKeys, | 877 errors::kInvalidPageActionOldAndNewKeys, |
| 878 keys::kPageActionDefaultPopup, | 878 keys::kPageActionDefaultPopup, |
| 879 keys::kPageActionPopup); | 879 keys::kPageActionPopup); |
| 880 return scoped_ptr<ExtensionAction>(); | 880 return scoped_ptr<ExtensionAction>(); |
| 881 } | 881 } |
| 882 popup_key = keys::kPageActionPopup; | 882 popup_key = keys::kPageActionPopup; |
| 883 } | 883 } |
| 884 | 884 |
| 885 if (popup_key) { | 885 if (popup_key) { |
| 886 DictionaryValue* popup = NULL; | 886 const DictionaryValue* popup = NULL; |
| 887 std::string url_str; | 887 std::string url_str; |
| 888 | 888 |
| 889 if (extension_action->GetString(popup_key, &url_str)) { | 889 if (extension_action->GetString(popup_key, &url_str)) { |
| 890 // On success, |url_str| is set. Nothing else to do. | 890 // On success, |url_str| is set. Nothing else to do. |
| 891 } else if (manifest_version_ == 1 && | 891 } else if (manifest_version_ == 1 && |
| 892 extension_action->GetDictionary(popup_key, &popup)) { | 892 extension_action->GetDictionary(popup_key, &popup)) { |
| 893 if (!popup->GetString(keys::kPageActionPopupPath, &url_str)) { | 893 if (!popup->GetString(keys::kPageActionPopupPath, &url_str)) { |
| 894 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 894 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 895 errors::kInvalidPageActionPopupPath, "<missing>"); | 895 errors::kInvalidPageActionPopupPath, "<missing>"); |
| 896 return scoped_ptr<ExtensionAction>(); | 896 return scoped_ptr<ExtensionAction>(); |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 | 1900 |
| 1901 bool Extension::LoadWebIntentAction(const std::string& action_name, | 1901 bool Extension::LoadWebIntentAction(const std::string& action_name, |
| 1902 const DictionaryValue& intent_service, | 1902 const DictionaryValue& intent_service, |
| 1903 string16* error) { | 1903 string16* error) { |
| 1904 DCHECK(error); | 1904 DCHECK(error); |
| 1905 webkit_glue::WebIntentServiceData service; | 1905 webkit_glue::WebIntentServiceData service; |
| 1906 std::string value; | 1906 std::string value; |
| 1907 | 1907 |
| 1908 service.action = UTF8ToUTF16(action_name); | 1908 service.action = UTF8ToUTF16(action_name); |
| 1909 | 1909 |
| 1910 ListValue* mime_types = NULL; | 1910 const ListValue* mime_types = NULL; |
| 1911 if (!intent_service.HasKey(keys::kIntentType) || | 1911 if (!intent_service.HasKey(keys::kIntentType) || |
| 1912 !intent_service.GetList(keys::kIntentType, &mime_types) || | 1912 !intent_service.GetList(keys::kIntentType, &mime_types) || |
| 1913 mime_types->GetSize() == 0) { | 1913 mime_types->GetSize() == 0) { |
| 1914 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 1914 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 1915 errors::kInvalidIntentType, action_name); | 1915 errors::kInvalidIntentType, action_name); |
| 1916 return false; | 1916 return false; |
| 1917 } | 1917 } |
| 1918 | 1918 |
| 1919 std::string href; | 1919 std::string href; |
| 1920 if (intent_service.HasKey(keys::kIntentPath)) { | 1920 if (intent_service.HasKey(keys::kIntentPath)) { |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2437 // Read the page action title from |default_title| (mandatory). | 2437 // Read the page action title from |default_title| (mandatory). |
| 2438 std::string title; | 2438 std::string title; |
| 2439 if (!file_browser_handler->HasKey(keys::kPageActionDefaultTitle) || | 2439 if (!file_browser_handler->HasKey(keys::kPageActionDefaultTitle) || |
| 2440 !file_browser_handler->GetString(keys::kPageActionDefaultTitle, &title)) { | 2440 !file_browser_handler->GetString(keys::kPageActionDefaultTitle, &title)) { |
| 2441 *error = ASCIIToUTF16(errors::kInvalidPageActionDefaultTitle); | 2441 *error = ASCIIToUTF16(errors::kInvalidPageActionDefaultTitle); |
| 2442 return NULL; | 2442 return NULL; |
| 2443 } | 2443 } |
| 2444 result->set_title(title); | 2444 result->set_title(title); |
| 2445 | 2445 |
| 2446 // Initialize access permissions (optional). | 2446 // Initialize access permissions (optional). |
| 2447 ListValue* access_list_value = NULL; | 2447 const ListValue* access_list_value = NULL; |
| 2448 if (file_browser_handler->HasKey(keys::kFileAccessList)) { | 2448 if (file_browser_handler->HasKey(keys::kFileAccessList)) { |
| 2449 if (!file_browser_handler->GetList(keys::kFileAccessList, | 2449 if (!file_browser_handler->GetList(keys::kFileAccessList, |
| 2450 &access_list_value) || | 2450 &access_list_value) || |
| 2451 access_list_value->empty()) { | 2451 access_list_value->empty()) { |
| 2452 *error = ASCIIToUTF16(errors::kInvalidFileAccessList); | 2452 *error = ASCIIToUTF16(errors::kInvalidFileAccessList); |
| 2453 return NULL; | 2453 return NULL; |
| 2454 } | 2454 } |
| 2455 for (size_t i = 0; i < access_list_value->GetSize(); ++i) { | 2455 for (size_t i = 0; i < access_list_value->GetSize(); ++i) { |
| 2456 std::string access; | 2456 std::string access; |
| 2457 if (!access_list_value->GetString(i, &access) || | 2457 if (!access_list_value->GetString(i, &access) || |
| 2458 result->AddFileAccessPermission(access)) { | 2458 result->AddFileAccessPermission(access)) { |
| 2459 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 2459 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| 2460 errors::kInvalidFileAccessValue, base::IntToString(i)); | 2460 errors::kInvalidFileAccessValue, base::IntToString(i)); |
| 2461 return NULL; | 2461 return NULL; |
| 2462 } | 2462 } |
| 2463 } | 2463 } |
| 2464 } | 2464 } |
| 2465 if (!result->ValidateFileAccessPermissions()) { | 2465 if (!result->ValidateFileAccessPermissions()) { |
| 2466 *error = ASCIIToUTF16(errors::kInvalidFileAccessList); | 2466 *error = ASCIIToUTF16(errors::kInvalidFileAccessList); |
| 2467 return NULL; | 2467 return NULL; |
| 2468 } | 2468 } |
| 2469 | 2469 |
| 2470 // Initialize file filters (mandatory, unless "create" access is specified, | 2470 // Initialize file filters (mandatory, unless "create" access is specified, |
| 2471 // in which case is ignored). | 2471 // in which case is ignored). |
| 2472 if (!result->HasCreateAccessPermission()) { | 2472 if (!result->HasCreateAccessPermission()) { |
| 2473 ListValue* list_value = NULL; | 2473 const ListValue* list_value = NULL; |
| 2474 if (!file_browser_handler->HasKey(keys::kFileFilters) || | 2474 if (!file_browser_handler->HasKey(keys::kFileFilters) || |
| 2475 !file_browser_handler->GetList(keys::kFileFilters, &list_value) || | 2475 !file_browser_handler->GetList(keys::kFileFilters, &list_value) || |
| 2476 list_value->empty()) { | 2476 list_value->empty()) { |
| 2477 *error = ASCIIToUTF16(errors::kInvalidFileFiltersList); | 2477 *error = ASCIIToUTF16(errors::kInvalidFileFiltersList); |
| 2478 return NULL; | 2478 return NULL; |
| 2479 } | 2479 } |
| 2480 for (size_t i = 0; i < list_value->GetSize(); ++i) { | 2480 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
| 2481 std::string filter; | 2481 std::string filter; |
| 2482 if (!list_value->GetString(i, &filter)) { | 2482 if (!list_value->GetString(i, &filter)) { |
| 2483 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 2483 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2795 if (!LoadThemeTints(theme_value, error)) | 2795 if (!LoadThemeTints(theme_value, error)) |
| 2796 return false; | 2796 return false; |
| 2797 if (!LoadThemeDisplayProperties(theme_value, error)) | 2797 if (!LoadThemeDisplayProperties(theme_value, error)) |
| 2798 return false; | 2798 return false; |
| 2799 | 2799 |
| 2800 return true; | 2800 return true; |
| 2801 } | 2801 } |
| 2802 | 2802 |
| 2803 bool Extension::LoadThemeImages(const DictionaryValue* theme_value, | 2803 bool Extension::LoadThemeImages(const DictionaryValue* theme_value, |
| 2804 string16* error) { | 2804 string16* error) { |
| 2805 DictionaryValue* images_value = NULL; | 2805 const DictionaryValue* images_value = NULL; |
| 2806 if (theme_value->GetDictionary(keys::kThemeImages, &images_value)) { | 2806 if (theme_value->GetDictionary(keys::kThemeImages, &images_value)) { |
| 2807 // Validate that the images are all strings | 2807 // Validate that the images are all strings |
| 2808 for (DictionaryValue::key_iterator iter = images_value->begin_keys(); | 2808 for (DictionaryValue::key_iterator iter = images_value->begin_keys(); |
| 2809 iter != images_value->end_keys(); ++iter) { | 2809 iter != images_value->end_keys(); ++iter) { |
| 2810 std::string val; | 2810 std::string val; |
| 2811 if (!images_value->GetString(*iter, &val)) { | 2811 if (!images_value->GetString(*iter, &val)) { |
| 2812 *error = ASCIIToUTF16(errors::kInvalidThemeImages); | 2812 *error = ASCIIToUTF16(errors::kInvalidThemeImages); |
| 2813 return false; | 2813 return false; |
| 2814 } | 2814 } |
| 2815 } | 2815 } |
| 2816 theme_images_.reset(images_value->DeepCopy()); | 2816 theme_images_.reset(images_value->DeepCopy()); |
| 2817 } | 2817 } |
| 2818 return true; | 2818 return true; |
| 2819 } | 2819 } |
| 2820 | 2820 |
| 2821 bool Extension::LoadThemeColors(const DictionaryValue* theme_value, | 2821 bool Extension::LoadThemeColors(const DictionaryValue* theme_value, |
| 2822 string16* error) { | 2822 string16* error) { |
| 2823 DictionaryValue* colors_value = NULL; | 2823 const DictionaryValue* colors_value = NULL; |
| 2824 if (theme_value->GetDictionary(keys::kThemeColors, &colors_value)) { | 2824 if (theme_value->GetDictionary(keys::kThemeColors, &colors_value)) { |
| 2825 // Validate that the colors are RGB or RGBA lists | 2825 // Validate that the colors are RGB or RGBA lists |
| 2826 for (DictionaryValue::key_iterator iter = colors_value->begin_keys(); | 2826 for (DictionaryValue::key_iterator iter = colors_value->begin_keys(); |
| 2827 iter != colors_value->end_keys(); ++iter) { | 2827 iter != colors_value->end_keys(); ++iter) { |
| 2828 ListValue* color_list = NULL; | 2828 const ListValue* color_list = NULL; |
| 2829 double alpha = 0.0; | 2829 double alpha = 0.0; |
| 2830 int color = 0; | 2830 int color = 0; |
| 2831 // The color must be a list | 2831 // The color must be a list |
| 2832 if (!colors_value->GetListWithoutPathExpansion(*iter, &color_list) || | 2832 if (!colors_value->GetListWithoutPathExpansion(*iter, &color_list) || |
| 2833 // And either 3 items (RGB) or 4 (RGBA) | 2833 // And either 3 items (RGB) or 4 (RGBA) |
| 2834 ((color_list->GetSize() != 3) && | 2834 ((color_list->GetSize() != 3) && |
| 2835 ((color_list->GetSize() != 4) || | 2835 ((color_list->GetSize() != 4) || |
| 2836 // For RGBA, the fourth item must be a real or int alpha value. | 2836 // For RGBA, the fourth item must be a real or int alpha value. |
| 2837 // Note that GetDouble() can get an integer value. | 2837 // Note that GetDouble() can get an integer value. |
| 2838 !color_list->GetDouble(3, &alpha))) || | 2838 !color_list->GetDouble(3, &alpha))) || |
| 2839 // For both RGB and RGBA, the first three items must be ints (R,G,B) | 2839 // For both RGB and RGBA, the first three items must be ints (R,G,B) |
| 2840 !color_list->GetInteger(0, &color) || | 2840 !color_list->GetInteger(0, &color) || |
| 2841 !color_list->GetInteger(1, &color) || | 2841 !color_list->GetInteger(1, &color) || |
| 2842 !color_list->GetInteger(2, &color)) { | 2842 !color_list->GetInteger(2, &color)) { |
| 2843 *error = ASCIIToUTF16(errors::kInvalidThemeColors); | 2843 *error = ASCIIToUTF16(errors::kInvalidThemeColors); |
| 2844 return false; | 2844 return false; |
| 2845 } | 2845 } |
| 2846 } | 2846 } |
| 2847 theme_colors_.reset(colors_value->DeepCopy()); | 2847 theme_colors_.reset(colors_value->DeepCopy()); |
| 2848 } | 2848 } |
| 2849 return true; | 2849 return true; |
| 2850 } | 2850 } |
| 2851 | 2851 |
| 2852 bool Extension::LoadThemeTints(const DictionaryValue* theme_value, | 2852 bool Extension::LoadThemeTints(const DictionaryValue* theme_value, |
| 2853 string16* error) { | 2853 string16* error) { |
| 2854 DictionaryValue* tints_value = NULL; | 2854 const DictionaryValue* tints_value = NULL; |
| 2855 if (theme_value->GetDictionary(keys::kThemeTints, &tints_value)) { | 2855 if (theme_value->GetDictionary(keys::kThemeTints, &tints_value)) { |
| 2856 // Validate that the tints are all reals. | 2856 // Validate that the tints are all reals. |
| 2857 for (DictionaryValue::key_iterator iter = tints_value->begin_keys(); | 2857 for (DictionaryValue::key_iterator iter = tints_value->begin_keys(); |
| 2858 iter != tints_value->end_keys(); ++iter) { | 2858 iter != tints_value->end_keys(); ++iter) { |
| 2859 ListValue* tint_list = NULL; | 2859 const ListValue* tint_list = NULL; |
| 2860 double v = 0.0; | 2860 double v = 0.0; |
| 2861 if (!tints_value->GetListWithoutPathExpansion(*iter, &tint_list) || | 2861 if (!tints_value->GetListWithoutPathExpansion(*iter, &tint_list) || |
| 2862 tint_list->GetSize() != 3 || | 2862 tint_list->GetSize() != 3 || |
| 2863 !tint_list->GetDouble(0, &v) || | 2863 !tint_list->GetDouble(0, &v) || |
| 2864 !tint_list->GetDouble(1, &v) || | 2864 !tint_list->GetDouble(1, &v) || |
| 2865 !tint_list->GetDouble(2, &v)) { | 2865 !tint_list->GetDouble(2, &v)) { |
| 2866 *error = ASCIIToUTF16(errors::kInvalidThemeTints); | 2866 *error = ASCIIToUTF16(errors::kInvalidThemeTints); |
| 2867 return false; | 2867 return false; |
| 2868 } | 2868 } |
| 2869 } | 2869 } |
| 2870 theme_tints_.reset(tints_value->DeepCopy()); | 2870 theme_tints_.reset(tints_value->DeepCopy()); |
| 2871 } | 2871 } |
| 2872 return true; | 2872 return true; |
| 2873 } | 2873 } |
| 2874 | 2874 |
| 2875 bool Extension::LoadThemeDisplayProperties(const DictionaryValue* theme_value, | 2875 bool Extension::LoadThemeDisplayProperties(const DictionaryValue* theme_value, |
| 2876 string16* error) { | 2876 string16* error) { |
| 2877 DictionaryValue* display_properties_value = NULL; | 2877 const DictionaryValue* display_properties_value = NULL; |
| 2878 if (theme_value->GetDictionary(keys::kThemeDisplayProperties, | 2878 if (theme_value->GetDictionary(keys::kThemeDisplayProperties, |
| 2879 &display_properties_value)) { | 2879 &display_properties_value)) { |
| 2880 theme_display_properties_.reset( | 2880 theme_display_properties_.reset( |
| 2881 display_properties_value->DeepCopy()); | 2881 display_properties_value->DeepCopy()); |
| 2882 } | 2882 } |
| 2883 return true; | 2883 return true; |
| 2884 } | 2884 } |
| 2885 | 2885 |
| 2886 // static | 2886 // static |
| 2887 bool Extension::IsTrustedId(const std::string& id) { | 2887 bool Extension::IsTrustedId(const std::string& id) { |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3884 | 3884 |
| 3885 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3885 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 3886 const Extension* extension, | 3886 const Extension* extension, |
| 3887 const PermissionSet* permissions, | 3887 const PermissionSet* permissions, |
| 3888 Reason reason) | 3888 Reason reason) |
| 3889 : reason(reason), | 3889 : reason(reason), |
| 3890 extension(extension), | 3890 extension(extension), |
| 3891 permissions(permissions) {} | 3891 permissions(permissions) {} |
| 3892 | 3892 |
| 3893 } // namespace extensions | 3893 } // namespace extensions |
| OLD | NEW |