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

Side by Side Diff: chrome/browser/search_engines/template_url_parser.cc

Issue 6804032: Add TLS-SRP (RFC 5054) support Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: use system srp and mpi libs, not local copies Created 9 years, 8 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) 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/browser/search_engines/template_url_parser.h" 5 #include "chrome/browser/search_engines/template_url_parser.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 context->ResetString(); 512 context->ResetString();
513 context->PopElement(); 513 context->PopElement();
514 } 514 }
515 515
516 void CharactersImpl(void *ctx, const xmlChar *ch, int len) { 516 void CharactersImpl(void *ctx, const xmlChar *ch, int len) {
517 ParsingContext* context = reinterpret_cast<ParsingContext*>(ctx); 517 ParsingContext* context = reinterpret_cast<ParsingContext*>(ctx);
518 context->AppendString(XMLCharToUTF16(ch, len)); 518 context->AppendString(XMLCharToUTF16(ch, len));
519 } 519 }
520 520
521 // Returns true if the ref is null, or the url wrapped by ref is 521 // Returns true if the ref is null, or the url wrapped by ref is
522 // valid with a spec of http/https. 522 // valid with a spec of http/https/httpsv.
523 bool IsHTTPRef(const TemplateURLRef* ref) { 523 bool IsHTTPRef(const TemplateURLRef* ref) {
524 if (ref == NULL) 524 if (ref == NULL)
525 return true; 525 return true;
526 GURL url(ref->url()); 526 GURL url(ref->url());
527 return (url.is_valid() && (url.SchemeIs(chrome::kHttpScheme) || 527 return (url.is_valid() && (url.SchemeIs(chrome::kHttpScheme) ||
528 url.SchemeIs(chrome::kHttpsScheme))); 528 url.SchemeIs(chrome::kHttpsScheme) ||
529 url.SchemeIs(chrome::kHttpsvScheme)));
529 } 530 }
530 531
531 // Returns true if the TemplateURL is legal. A legal TemplateURL is one 532 // Returns true if the TemplateURL is legal. A legal TemplateURL is one
532 // where all URLs have a spec of http/https. 533 // where all URLs have a spec of http/https.
533 bool IsLegal(TemplateURL* url) { 534 bool IsLegal(TemplateURL* url) {
534 if (!IsHTTPRef(url->url()) || !IsHTTPRef(url->suggestions_url())) 535 if (!IsHTTPRef(url->url()) || !IsHTTPRef(url->suggestions_url()))
535 return false; 536 return false;
536 // Make sure all the image refs are legal. 537 // Make sure all the image refs are legal.
537 const std::vector<TemplateURL::ImageRef>& image_refs = url->image_refs(); 538 const std::vector<TemplateURL::ImageRef>& image_refs = url->image_refs();
538 for (size_t i = 0; i < image_refs.size(); i++) { 539 for (size_t i = 0; i < image_refs.size(); i++) {
539 GURL image_url(image_refs[i].url); 540 GURL image_url(image_refs[i].url);
540 if (!image_url.is_valid() || 541 if (!image_url.is_valid() ||
541 !(image_url.SchemeIs(chrome::kHttpScheme) || 542 !(image_url.SchemeIs(chrome::kHttpScheme) ||
542 image_url.SchemeIs(chrome::kHttpsScheme))) { 543 image_url.SchemeIs(chrome::kHttpsScheme) ||
544 image_url.SchemeIs(chrome::kHttpsvScheme))) {
543 return false; 545 return false;
544 } 546 }
545 } 547 }
546 return true; 548 return true;
547 } 549 }
548 550
549 } // namespace 551 } // namespace
550 552
551 // static 553 // static
552 bool TemplateURLParser::Parse(const unsigned char* data, size_t length, 554 bool TemplateURLParser::Parse(const unsigned char* data, size_t length,
(...skipping 25 matching lines...) Expand all
578 return false; 580 return false;
579 if (context.suggestion_method() == ParsingContext::POST) 581 if (context.suggestion_method() == ParsingContext::POST)
580 url->SetSuggestionsURL("", 0, 0); 582 url->SetSuggestionsURL("", 0, 0);
581 583
582 if (!url->short_name().empty() && !url->description().empty()) { 584 if (!url->short_name().empty() && !url->description().empty()) {
583 // So far so good, make sure the urls are http. 585 // So far so good, make sure the urls are http.
584 return IsLegal(url); 586 return IsLegal(url);
585 } 587 }
586 return false; 588 return false;
587 } 589 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698