Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: chrome/browser/extensions/webstore_inline_installer.cc

Issue 9269020: Handle paths and ports in verified domains in inline install. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright header.x Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/extensions/crx_installer.h" 13 #include "chrome/browser/extensions/crx_installer.h"
14 #include "chrome/browser/extensions/extension_install_dialog.h" 14 #include "chrome/browser/extensions/extension_install_dialog.h"
15 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/chrome_utility_messages.h" 17 #include "chrome/common/chrome_utility_messages.h"
18 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
19 #include "chrome/common/extensions/extension_constants.h" 19 #include "chrome/common/extensions/extension_constants.h"
20 #include "chrome/common/extensions/url_pattern.h" 20 #include "chrome/common/extensions/url_pattern.h"
21 #include "chrome/common/url_constants.h"
21 #include "content/browser/utility_process_host.h" 22 #include "content/browser/utility_process_host.h"
22 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
23 #include "content/public/common/url_fetcher.h" 24 #include "content/public/common/url_fetcher.h"
24 #include "net/base/escape.h" 25 #include "net/base/escape.h"
25 #include "net/base/load_flags.h" 26 #include "net/base/load_flags.h"
26 #include "net/url_request/url_request_status.h" 27 #include "net/url_request/url_request_status.h"
27 28
28 using content::BrowserThread; 29 using content::BrowserThread;
29 using content::OpenURLParams; 30 using content::OpenURLParams;
30 using content::WebContents; 31 using content::WebContents;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // Verified site is required 296 // Verified site is required
296 if (webstore_data->HasKey(kVerifiedSiteKey)) { 297 if (webstore_data->HasKey(kVerifiedSiteKey)) {
297 std::string verified_site_domain; 298 std::string verified_site_domain;
298 if (!webstore_data->GetString(kVerifiedSiteKey, &verified_site_domain)) { 299 if (!webstore_data->GetString(kVerifiedSiteKey, &verified_site_domain)) {
299 CompleteInstall(kInvalidWebstoreResponseError); 300 CompleteInstall(kInvalidWebstoreResponseError);
300 return; 301 return;
301 } 302 }
302 303
303 URLPattern verified_site_pattern(URLPattern::SCHEME_ALL); 304 URLPattern verified_site_pattern(URLPattern::SCHEME_ALL);
304 verified_site_pattern.SetScheme("*"); 305 verified_site_pattern.SetScheme("*");
305 verified_site_pattern.SetHost(verified_site_domain); 306 // Verified domains can have ports, so we have to parse them out.
jstritar 2012/01/23 21:37:28 URLPattern already handles a lot of this if you us
Mihai Parparita -not on Chrome 2012/01/25 00:53:24 Yeah, that ended up being easier, especially since
307 size_t host_end_pos = verified_site_domain.find(':');
308 if (host_end_pos == std::string::npos) {
309 verified_site_pattern.SetHost(verified_site_domain);
310 } else {
311 std::string verified_site_port =
312 verified_site_domain.substr(host_end_pos + 1);
313 // We temporarily set the scheme to be HTTP, since URLPattern doesn't
314 // allow specific ports unless the scheme has a default port.
jstritar 2012/01/23 21:37:28 Hm, strange, is this a bug?
Mihai Parparita -not on Chrome 2012/01/25 00:53:24 It appears to be intentional behavior (see IsValid
315 verified_site_pattern.SetScheme(chrome::kHttpScheme);
316 if (!verified_site_pattern.SetPort(verified_site_port)) {
317 CompleteInstall(kInvalidWebstoreResponseError);
318 return;
319 }
320 verified_site_pattern.SetScheme("*");
321 verified_site_pattern.SetHost(
322 verified_site_domain.substr(0, host_end_pos));
323 }
306 verified_site_pattern.SetMatchSubdomains(true); 324 verified_site_pattern.SetMatchSubdomains(true);
307 verified_site_pattern.SetPath("/*"); 325 verified_site_pattern.SetPath("/*");
308 326
309 if (!verified_site_pattern.MatchesURL(requestor_url_)) { 327 if (!verified_site_pattern.MatchesURL(requestor_url_)) {
310 CompleteInstall(kNotFromVerifiedSiteError); 328 CompleteInstall(kNotFromVerifiedSiteError);
311 return; 329 return;
312 } 330 }
313 } else { 331 } else {
314 CompleteInstall(kNoVerifiedSiteError); 332 CompleteInstall(kNoVerifiedSiteError);
315 return; 333 return;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 if (web_contents()) { 448 if (web_contents()) {
431 if (error.empty()) { 449 if (error.empty()) {
432 delegate_->OnInlineInstallSuccess(install_id_); 450 delegate_->OnInlineInstallSuccess(install_id_);
433 } else { 451 } else {
434 delegate_->OnInlineInstallFailure(install_id_, error); 452 delegate_->OnInlineInstallFailure(install_id_, error);
435 } 453 }
436 } 454 }
437 455
438 Release(); // Matches the AddRef in BeginInstall. 456 Release(); // Matches the AddRef in BeginInstall.
439 } 457 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698