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