| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/common/manifest_handlers/webview_info.h" | 5 #include "extensions/common/manifest_handlers/webview_info.h" | 
| 6 | 6 | 
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" | 
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" | 
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" | 
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" | 
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 97 | 97 | 
| 98 WebviewHandler::WebviewHandler() { | 98 WebviewHandler::WebviewHandler() { | 
| 99 } | 99 } | 
| 100 | 100 | 
| 101 WebviewHandler::~WebviewHandler() { | 101 WebviewHandler::~WebviewHandler() { | 
| 102 } | 102 } | 
| 103 | 103 | 
| 104 bool WebviewHandler::Parse(Extension* extension, base::string16* error) { | 104 bool WebviewHandler::Parse(Extension* extension, base::string16* error) { | 
| 105   scoped_ptr<WebviewInfo> info(new WebviewInfo()); | 105   scoped_ptr<WebviewInfo> info(new WebviewInfo()); | 
| 106 | 106 | 
| 107   const base::DictionaryValue* dict_value = NULL; | 107   const base::DictionaryValue* dict_value = nullptr; | 
| 108   if (!extension->manifest()->GetDictionary(keys::kWebview, | 108   if (!extension->manifest()->GetDictionary(keys::kWebview, | 
| 109                                             &dict_value)) { | 109                                             &dict_value)) { | 
| 110     *error = base::ASCIIToUTF16(errors::kInvalidWebview); | 110     *error = base::ASCIIToUTF16(errors::kInvalidWebview); | 
| 111     return false; | 111     return false; | 
| 112   } | 112   } | 
| 113 | 113 | 
| 114   const base::ListValue* partition_list = NULL; | 114   const base::ListValue* partition_list = nullptr; | 
| 115   if (!dict_value->GetList(keys::kWebviewPartitions, &partition_list)) { | 115   if (!dict_value->GetList(keys::kWebviewPartitions, &partition_list)) { | 
| 116     *error = base::ASCIIToUTF16(errors::kInvalidWebviewPartitionsList); | 116     *error = base::ASCIIToUTF16(errors::kInvalidWebviewPartitionsList); | 
| 117     return false; | 117     return false; | 
| 118   } | 118   } | 
| 119 | 119 | 
| 120   // The partition list must have at least one entry. | 120   // The partition list must have at least one entry. | 
| 121   if (partition_list->GetSize() == 0) { | 121   if (partition_list->GetSize() == 0) { | 
| 122     *error = base::ASCIIToUTF16(errors::kInvalidWebviewPartitionsList); | 122     *error = base::ASCIIToUTF16(errors::kInvalidWebviewPartitionsList); | 
| 123     return false; | 123     return false; | 
| 124   } | 124   } | 
| 125 | 125 | 
| 126   for (size_t i = 0; i < partition_list->GetSize(); ++i) { | 126   for (size_t i = 0; i < partition_list->GetSize(); ++i) { | 
| 127     const base::DictionaryValue* partition = NULL; | 127     const base::DictionaryValue* partition = nullptr; | 
| 128     if (!partition_list->GetDictionary(i, &partition)) { | 128     if (!partition_list->GetDictionary(i, &partition)) { | 
| 129       *error = ErrorUtils::FormatErrorMessageUTF16( | 129       *error = ErrorUtils::FormatErrorMessageUTF16( | 
| 130           errors::kInvalidWebviewPartition, base::IntToString(i)); | 130           errors::kInvalidWebviewPartition, base::IntToString(i)); | 
| 131       return false; | 131       return false; | 
| 132     } | 132     } | 
| 133 | 133 | 
| 134     std::string partition_pattern; | 134     std::string partition_pattern; | 
| 135     if (!partition->GetString(keys::kWebviewName, &partition_pattern)) { | 135     if (!partition->GetString(keys::kWebviewName, &partition_pattern)) { | 
| 136       *error = ErrorUtils::FormatErrorMessageUTF16( | 136       *error = ErrorUtils::FormatErrorMessageUTF16( | 
| 137           errors::kInvalidWebviewPartitionName, base::IntToString(i)); | 137           errors::kInvalidWebviewPartitionName, base::IntToString(i)); | 
| 138       return false; | 138       return false; | 
| 139     } | 139     } | 
| 140 | 140 | 
| 141     const base::ListValue* url_list = NULL; | 141     const base::ListValue* url_list = nullptr; | 
| 142     if (!partition->GetList(keys::kWebviewAccessibleResources, | 142     if (!partition->GetList(keys::kWebviewAccessibleResources, | 
| 143                             &url_list)) { | 143                             &url_list)) { | 
| 144       *error = base::ASCIIToUTF16( | 144       *error = base::ASCIIToUTF16( | 
| 145           errors::kInvalidWebviewAccessibleResourcesList); | 145           errors::kInvalidWebviewAccessibleResourcesList); | 
| 146       return false; | 146       return false; | 
| 147     } | 147     } | 
| 148 | 148 | 
| 149     // The URL list should have at least one entry. | 149     // The URL list should have at least one entry. | 
| 150     if (url_list->GetSize() == 0) { | 150     if (url_list->GetSize() == 0) { | 
| 151       *error = base::ASCIIToUTF16( | 151       *error = base::ASCIIToUTF16( | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 173 | 173 | 
| 174   extension->SetManifestData(keys::kWebviewAccessibleResources, info.release()); | 174   extension->SetManifestData(keys::kWebviewAccessibleResources, info.release()); | 
| 175   return true; | 175   return true; | 
| 176 } | 176 } | 
| 177 | 177 | 
| 178 const std::vector<std::string> WebviewHandler::Keys() const { | 178 const std::vector<std::string> WebviewHandler::Keys() const { | 
| 179   return SingleKey(keys::kWebview); | 179   return SingleKey(keys::kWebview); | 
| 180 } | 180 } | 
| 181 | 181 | 
| 182 }  // namespace extensions | 182 }  // namespace extensions | 
| OLD | NEW | 
|---|