| 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/browser/extensions/webstore_inline_installer.h" | 5 #include "chrome/browser/extensions/webstore_inline_installer.h" |
| 6 | 6 |
| 7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 | 10 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 AbortInstall(); | 140 AbortInstall(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 // static | 143 // static |
| 144 bool WebstoreInlineInstaller::IsRequestorURLInVerifiedSite( | 144 bool WebstoreInlineInstaller::IsRequestorURLInVerifiedSite( |
| 145 const GURL& requestor_url, | 145 const GURL& requestor_url, |
| 146 const std::string& verified_site) { | 146 const std::string& verified_site) { |
| 147 // Turn the verified site (which may be a bare domain, or have a port and/or a | 147 // Turn the verified site (which may be a bare domain, or have a port and/or a |
| 148 // path) into a URL that can be parsed by URLPattern. | 148 // path) into a URL that can be parsed by URLPattern. |
| 149 std::string verified_site_url = | 149 std::string verified_site_url = |
| 150 StringPrintf("http://*.%s%s", | 150 base::StringPrintf( |
| 151 "http://*.%s%s", |
| 151 verified_site.c_str(), | 152 verified_site.c_str(), |
| 152 verified_site.find('/') == std::string::npos ? "/*" : "*"); | 153 verified_site.find('/') == std::string::npos ? "/*" : "*"); |
| 153 | 154 |
| 154 URLPattern verified_site_pattern( | 155 URLPattern verified_site_pattern( |
| 155 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS); | 156 URLPattern::SCHEME_HTTP | URLPattern::SCHEME_HTTPS); |
| 156 URLPattern::ParseResult parse_result = | 157 URLPattern::ParseResult parse_result = |
| 157 verified_site_pattern.Parse(verified_site_url); | 158 verified_site_pattern.Parse(verified_site_url); |
| 158 if (parse_result != URLPattern::PARSE_SUCCESS) { | 159 if (parse_result != URLPattern::PARSE_SUCCESS) { |
| 159 DLOG(WARNING) << "Could not parse " << verified_site_url << | 160 DLOG(WARNING) << "Could not parse " << verified_site_url << |
| 160 " as URL pattern " << parse_result; | 161 " as URL pattern " << parse_result; |
| 161 return false; | 162 return false; |
| 162 } | 163 } |
| 163 verified_site_pattern.SetScheme("*"); | 164 verified_site_pattern.SetScheme("*"); |
| 164 | 165 |
| 165 return verified_site_pattern.MatchesURL(requestor_url); | 166 return verified_site_pattern.MatchesURL(requestor_url); |
| 166 } | 167 } |
| 167 | 168 |
| 168 } // namespace extensions | 169 } // namespace extensions |
| OLD | NEW |