| 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/pattern.h" | 8 #include "base/strings/pattern.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 URLPatternSet accessible_resources_; | 51 URLPatternSet accessible_resources_; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 WebviewInfo::WebviewInfo(const std::string& extension_id) | 54 WebviewInfo::WebviewInfo(const std::string& extension_id) |
| 55 : extension_id_(extension_id) { | 55 : extension_id_(extension_id) { |
| 56 } | 56 } |
| 57 | 57 |
| 58 WebviewInfo::~WebviewInfo() { | 58 WebviewInfo::~WebviewInfo() { |
| 59 } | 59 } |
| 60 | 60 |
| 61 // static |
| 61 bool WebviewInfo::IsResourceWebviewAccessible( | 62 bool WebviewInfo::IsResourceWebviewAccessible( |
| 62 const Extension* extension, | 63 const Extension* extension, |
| 63 const std::string& partition_id, | 64 const std::string& partition_id, |
| 64 const std::string& relative_path) const { | 65 const std::string& relative_path) { |
| 65 if (!extension || extension->id() != extension_id_) | 66 if (!extension) |
| 66 return false; | 67 return false; |
| 67 | 68 |
| 68 DCHECK_EQ(this, | 69 const WebviewInfo* webview_info = static_cast<const WebviewInfo*>( |
| 69 extension->GetManifestData(keys::kWebviewAccessibleResources)); | 70 extension->GetManifestData(keys::kWebviewAccessibleResources)); |
| 71 if (!webview_info) |
| 72 return false; |
| 70 | 73 |
| 71 for (size_t i = 0; i < partition_items_.size(); ++i) { | 74 for (const PartitionItem* item : webview_info->partition_items_) { |
| 72 const PartitionItem* const item = partition_items_[i]; | |
| 73 if (item->Matches(partition_id) && | 75 if (item->Matches(partition_id) && |
| 74 extension->ResourceMatches(item->accessible_resources(), | 76 extension->ResourceMatches(item->accessible_resources(), |
| 75 relative_path)) { | 77 relative_path)) { |
| 76 return true; | 78 return true; |
| 77 } | 79 } |
| 78 } | 80 } |
| 79 | 81 |
| 80 return false; | 82 return false; |
| 81 } | 83 } |
| 82 | 84 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 164 |
| 163 extension->SetManifestData(keys::kWebviewAccessibleResources, info.release()); | 165 extension->SetManifestData(keys::kWebviewAccessibleResources, info.release()); |
| 164 return true; | 166 return true; |
| 165 } | 167 } |
| 166 | 168 |
| 167 const std::vector<std::string> WebviewHandler::Keys() const { | 169 const std::vector<std::string> WebviewHandler::Keys() const { |
| 168 return SingleKey(keys::kWebview); | 170 return SingleKey(keys::kWebview); |
| 169 } | 171 } |
| 170 | 172 |
| 171 } // namespace extensions | 173 } // namespace extensions |
| OLD | NEW |