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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 const TemplateURL* template_url, | 640 const TemplateURL* template_url, |
641 const AutocompleteInput& input) { | 641 const AutocompleteInput& input) { |
642 if (!template_url || template_url->suggestions_url().empty()) | 642 if (!template_url || template_url->suggestions_url().empty()) |
643 return NULL; | 643 return NULL; |
644 | 644 |
645 // Bail if the suggestion URL is invalid with the given replacements. | 645 // Bail if the suggestion URL is invalid with the given replacements. |
646 TemplateURLRef::SearchTermsArgs search_term_args(input.text()); | 646 TemplateURLRef::SearchTermsArgs search_term_args(input.text()); |
647 search_term_args.input_type = input.type(); | 647 search_term_args.input_type = input.type(); |
648 search_term_args.cursor_position = input.cursor_position(); | 648 search_term_args.cursor_position = input.cursor_position(); |
649 search_term_args.page_classification = input.current_page_classification(); | 649 search_term_args.page_classification = input.current_page_classification(); |
650 if (CommandLine::ForCurrentProcess()->HasSwitch( | 650 if (chrome::IsAnswersInSuggestEnabled()) |
651 switches::kEnableAnswersInSuggest)) | |
652 search_term_args.session_token = GetSessionToken(); | 651 search_term_args.session_token = GetSessionToken(); |
653 GURL suggest_url(template_url->suggestions_url_ref().ReplaceSearchTerms( | 652 GURL suggest_url(template_url->suggestions_url_ref().ReplaceSearchTerms( |
654 search_term_args, | 653 search_term_args, |
655 providers_.template_url_service()->search_terms_data())); | 654 providers_.template_url_service()->search_terms_data())); |
656 if (!suggest_url.is_valid()) | 655 if (!suggest_url.is_valid()) |
657 return NULL; | 656 return NULL; |
658 // Send the current page URL if user setting and URL requirements are met and | 657 // Send the current page URL if user setting and URL requirements are met and |
659 // the user is in the field trial. | 658 // the user is in the field trial. |
660 if (CanSendURL(current_page_url_, suggest_url, template_url, | 659 if (CanSendURL(current_page_url_, suggest_url, template_url, |
661 input.current_page_classification(), profile_) && | 660 input.current_page_classification(), profile_) && |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 // Make the base64 encoded value URL and filename safe(see RFC 3548). | 1161 // Make the base64 encoded value URL and filename safe(see RFC 3548). |
1163 std::replace(current_token_.begin(), current_token_.end(), '+', '-'); | 1162 std::replace(current_token_.begin(), current_token_.end(), '+', '-'); |
1164 std::replace(current_token_.begin(), current_token_.end(), '/', '_'); | 1163 std::replace(current_token_.begin(), current_token_.end(), '/', '_'); |
1165 } | 1164 } |
1166 | 1165 |
1167 // Extend expiration time another 60 seconds. | 1166 // Extend expiration time another 60 seconds. |
1168 token_expiration_time_ = current_time + base::TimeDelta::FromSeconds(60); | 1167 token_expiration_time_ = current_time + base::TimeDelta::FromSeconds(60); |
1169 | 1168 |
1170 return current_token_; | 1169 return current_token_; |
1171 } | 1170 } |
OLD | NEW |