OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/autocomplete/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 | 632 |
633 net::URLFetcher* SearchProvider::CreateSuggestFetcher( | 633 net::URLFetcher* SearchProvider::CreateSuggestFetcher( |
634 int id, | 634 int id, |
635 const TemplateURL* template_url, | 635 const TemplateURL* template_url, |
636 const AutocompleteInput& input) { | 636 const AutocompleteInput& input) { |
637 if (!template_url || template_url->suggestions_url().empty()) | 637 if (!template_url || template_url->suggestions_url().empty()) |
638 return NULL; | 638 return NULL; |
639 | 639 |
640 // Bail if the suggestion URL is invalid with the given replacements. | 640 // Bail if the suggestion URL is invalid with the given replacements. |
641 TemplateURLRef::SearchTermsArgs search_term_args(input.text()); | 641 TemplateURLRef::SearchTermsArgs search_term_args(input.text()); |
| 642 search_term_args.input_type = input.type(); |
642 search_term_args.cursor_position = input.cursor_position(); | 643 search_term_args.cursor_position = input.cursor_position(); |
643 search_term_args.page_classification = input.current_page_classification(); | 644 search_term_args.page_classification = input.current_page_classification(); |
644 if (CommandLine::ForCurrentProcess()->HasSwitch( | 645 if (CommandLine::ForCurrentProcess()->HasSwitch( |
645 switches::kEnableAnswersInSuggest)) | 646 switches::kEnableAnswersInSuggest)) |
646 search_term_args.session_token = GetSessionToken(); | 647 search_term_args.session_token = GetSessionToken(); |
647 GURL suggest_url(template_url->suggestions_url_ref().ReplaceSearchTerms( | 648 GURL suggest_url(template_url->suggestions_url_ref().ReplaceSearchTerms( |
648 search_term_args)); | 649 search_term_args)); |
649 if (!suggest_url.is_valid()) | 650 if (!suggest_url.is_valid()) |
650 return NULL; | 651 return NULL; |
651 // Send the current page URL if user setting and URL requirements are met and | 652 // Send the current page URL if user setting and URL requirements are met and |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 // Make the base64 encoded value URL and filename safe(see RFC 3548). | 1155 // Make the base64 encoded value URL and filename safe(see RFC 3548). |
1155 std::replace(current_token_.begin(), current_token_.end(), '+', '-'); | 1156 std::replace(current_token_.begin(), current_token_.end(), '+', '-'); |
1156 std::replace(current_token_.begin(), current_token_.end(), '/', '_'); | 1157 std::replace(current_token_.begin(), current_token_.end(), '/', '_'); |
1157 } | 1158 } |
1158 | 1159 |
1159 // Extend expiration time another 60 seconds. | 1160 // Extend expiration time another 60 seconds. |
1160 token_expiration_time_ = current_time + base::TimeDelta::FromSeconds(60); | 1161 token_expiration_time_ = current_time + base::TimeDelta::FromSeconds(60); |
1161 | 1162 |
1162 return current_token_; | 1163 return current_token_; |
1163 } | 1164 } |
OLD | NEW |