OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/extensions/chrome_webstore_bindings.h" | 5 #include "chrome/renderer/extensions/chrome_webstore_bindings.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
9 #include "chrome/renderer/extensions/bindings_utils.h" | 9 #include "chrome/renderer/extensions/bindings_utils.h" |
10 #include "chrome/renderer/extensions/extension_helper.h" | 10 #include "chrome/renderer/extensions/extension_helper.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 return false; | 104 return false; |
105 } | 105 } |
106 | 106 |
107 WebElement head = document.head(); | 107 WebElement head = document.head(); |
108 if (head.isNull()) { | 108 if (head.isNull()) { |
109 *error = kNoWebstoreItemLinkFoundError; | 109 *error = kNoWebstoreItemLinkFoundError; |
110 return false; | 110 return false; |
111 } | 111 } |
112 | 112 |
113 GURL webstore_base_url = | 113 GURL webstore_base_url = |
114 GURL(extension_misc::GetWebstoreItemDetailURLPrefix()); | 114 GURL(extension_urls::GetWebstoreItemDetailURLPrefix()); |
115 WebNodeList children = head.childNodes(); | 115 WebNodeList children = head.childNodes(); |
116 for (unsigned i = 0; i < children.length(); ++i) { | 116 for (unsigned i = 0; i < children.length(); ++i) { |
117 WebNode child = children.item(i); | 117 WebNode child = children.item(i); |
118 if (!child.isElementNode()) | 118 if (!child.isElementNode()) |
119 continue; | 119 continue; |
120 WebElement elem = child.to<WebElement>(); | 120 WebElement elem = child.to<WebElement>(); |
121 | 121 |
122 if (!elem.hasTagName("link") || !elem.hasAttribute("rel") || | 122 if (!elem.hasTagName("link") || !elem.hasAttribute("rel") || |
123 !elem.hasAttribute("href")) | 123 !elem.hasAttribute("href")) |
124 continue; | 124 continue; |
(...skipping 18 matching lines...) Expand all Loading... |
143 } | 143 } |
144 | 144 |
145 std::string candidate_webstore_item_id = webstore_url.path().substr( | 145 std::string candidate_webstore_item_id = webstore_url.path().substr( |
146 webstore_base_url.path().length()); | 146 webstore_base_url.path().length()); |
147 if (!::Extension::IdIsValid(candidate_webstore_item_id)) { | 147 if (!::Extension::IdIsValid(candidate_webstore_item_id)) { |
148 *error = kInvalidWebstoreItemUrlError; | 148 *error = kInvalidWebstoreItemUrlError; |
149 return false; | 149 return false; |
150 } | 150 } |
151 | 151 |
152 std::string reconstructed_webstore_item_url_string = | 152 std::string reconstructed_webstore_item_url_string = |
153 extension_misc::GetWebstoreItemDetailURLPrefix() + | 153 extension_urls::GetWebstoreItemDetailURLPrefix() + |
154 candidate_webstore_item_id; | 154 candidate_webstore_item_id; |
155 if (reconstructed_webstore_item_url_string != webstore_url_string) { | 155 if (reconstructed_webstore_item_url_string != webstore_url_string) { |
156 *error = kInvalidWebstoreItemUrlError; | 156 *error = kInvalidWebstoreItemUrlError; |
157 return false; | 157 return false; |
158 } | 158 } |
159 | 159 |
160 *webstore_item_id = candidate_webstore_item_id; | 160 *webstore_item_id = candidate_webstore_item_id; |
161 return true; | 161 return true; |
162 } | 162 } |
163 | 163 |
164 *error = kNoWebstoreItemLinkFoundError; | 164 *error = kNoWebstoreItemLinkFoundError; |
165 return false; | 165 return false; |
166 } | 166 } |
167 }; | 167 }; |
168 | 168 |
169 v8::Extension* ChromeWebstoreExtension::Get() { | 169 v8::Extension* ChromeWebstoreExtension::Get() { |
170 return new ChromeWebstoreExtensionWrapper(); | 170 return new ChromeWebstoreExtensionWrapper(); |
171 } | 171 } |
172 | 172 |
173 } // namespace extensions_v8 | 173 } // namespace extensions_v8 |
OLD | NEW |