Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 | 742 |
| 743 // Initialize toolstrips (optional). | 743 // Initialize toolstrips (optional). |
| 744 if (source.HasKey(keys::kToolstrips)) { | 744 if (source.HasKey(keys::kToolstrips)) { |
| 745 ListValue* list_value; | 745 ListValue* list_value; |
| 746 if (!source.GetList(keys::kToolstrips, &list_value)) { | 746 if (!source.GetList(keys::kToolstrips, &list_value)) { |
| 747 *error = errors::kInvalidToolstrips; | 747 *error = errors::kInvalidToolstrips; |
| 748 return false; | 748 return false; |
| 749 } | 749 } |
| 750 | 750 |
| 751 for (size_t i = 0; i < list_value->GetSize(); ++i) { | 751 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
| 752 std::string toolstrip; | 752 ToolstripInfo toolstrip; |
| 753 if (!list_value->GetString(i, &toolstrip)) { | 753 DictionaryValue* toolstrip_value; |
| 754 std::string toolstrip_path; | |
| 755 if (list_value->GetString(i, &toolstrip_path)) { | |
|
Matt Perry
2009/07/24 23:11:11
is this temporary for back compat, or do you plan
Erik does not do reviews
2009/07/26 00:34:46
It's unclear. I added a comment with a TODO to lo
| |
| 756 toolstrip.toolstrip = GetResourceURL(toolstrip_path); | |
| 757 } else if (list_value->GetDictionary(i, &toolstrip_value)) { | |
| 758 if (!toolstrip_value->GetString(keys::kToolstripPath, | |
| 759 &toolstrip_path)) { | |
| 760 *error = ExtensionErrorUtils::FormatErrorMessage( | |
| 761 errors::kInvalidToolstrip, IntToString(i)); | |
| 762 return false; | |
| 763 } | |
| 764 toolstrip.toolstrip = GetResourceURL(toolstrip_path); | |
| 765 if (toolstrip_value->HasKey(keys::kToolstripMolePath)) { | |
| 766 std::string mole_path; | |
| 767 if (!toolstrip_value->GetString(keys::kToolstripMolePath, | |
| 768 &mole_path)) { | |
| 769 *error = ExtensionErrorUtils::FormatErrorMessage( | |
| 770 errors::kInvalidToolstrip, IntToString(i)); | |
| 771 return false; | |
| 772 } | |
| 773 // TODO(erikkay) is there a better way to get this dynamically | |
| 774 // from the content itself? | |
| 775 int height; | |
| 776 if (!toolstrip_value->GetInteger(keys::kToolstripMoleHeight, | |
| 777 &height) || (height < 0)) { | |
| 778 *error = ExtensionErrorUtils::FormatErrorMessage( | |
| 779 errors::kInvalidToolstrip, IntToString(i)); | |
| 780 return false; | |
| 781 } | |
| 782 toolstrip.mole = GetResourceURL(mole_path); | |
| 783 toolstrip.mole_height = height; | |
| 784 } | |
| 785 } else { | |
| 754 *error = ExtensionErrorUtils::FormatErrorMessage( | 786 *error = ExtensionErrorUtils::FormatErrorMessage( |
| 755 errors::kInvalidToolstrip, IntToString(i)); | 787 errors::kInvalidToolstrip, IntToString(i)); |
| 756 return false; | 788 return false; |
| 757 } | 789 } |
| 758 toolstrips_.push_back(toolstrip); | 790 toolstrips_.push_back(toolstrip); |
| 759 } | 791 } |
| 760 } | 792 } |
| 761 | 793 |
| 762 // Initialize content scripts (optional). | 794 // Initialize content scripts (optional). |
| 763 if (source.HasKey(keys::kContentScripts)) { | 795 if (source.HasKey(keys::kContentScripts)) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 877 it != page_actions().end(); ++it) { | 909 it != page_actions().end(); ++it) { |
| 878 const std::vector<FilePath>& icon_paths = it->second->icon_paths(); | 910 const std::vector<FilePath>& icon_paths = it->second->icon_paths(); |
| 879 for (std::vector<FilePath>::const_iterator iter = icon_paths.begin(); | 911 for (std::vector<FilePath>::const_iterator iter = icon_paths.begin(); |
| 880 iter != icon_paths.end(); ++iter) { | 912 iter != icon_paths.end(); ++iter) { |
| 881 image_paths.insert(*iter); | 913 image_paths.insert(*iter); |
| 882 } | 914 } |
| 883 } | 915 } |
| 884 | 916 |
| 885 return image_paths; | 917 return image_paths; |
| 886 } | 918 } |
| OLD | NEW |