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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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.cursor_position = input.cursor_position(); | 642 search_term_args.cursor_position = input.cursor_position(); |
643 search_term_args.page_classification = input.current_page_classification(); | 643 search_term_args.page_classification = input.current_page_classification(); |
644 #if defined(OS_ANDROID) | |
645 if (CommandLine::ForCurrentProcess()->HasSwitch( | 644 if (CommandLine::ForCurrentProcess()->HasSwitch( |
646 switches::kEnableAnswersInSuggest)) | 645 switches::kEnableAnswersInSuggest)) |
647 search_term_args.session_token = GetSessionToken(); | 646 search_term_args.session_token = GetSessionToken(); |
648 #endif | |
649 GURL suggest_url(template_url->suggestions_url_ref().ReplaceSearchTerms( | 647 GURL suggest_url(template_url->suggestions_url_ref().ReplaceSearchTerms( |
650 search_term_args)); | 648 search_term_args)); |
651 if (!suggest_url.is_valid()) | 649 if (!suggest_url.is_valid()) |
652 return NULL; | 650 return NULL; |
653 // Send the current page URL if user setting and URL requirements are met and | 651 // Send the current page URL if user setting and URL requirements are met and |
654 // the user is in the field trial. | 652 // the user is in the field trial. |
655 if (CanSendURL(current_page_url_, suggest_url, template_url, | 653 if (CanSendURL(current_page_url_, suggest_url, template_url, |
656 input.current_page_classification(), profile_) && | 654 input.current_page_classification(), profile_) && |
657 OmniboxFieldTrial::InZeroSuggestAfterTypingFieldTrial()) { | 655 OmniboxFieldTrial::InZeroSuggestAfterTypingFieldTrial()) { |
658 search_term_args.current_page_url = current_page_url_.spec(); | 656 search_term_args.current_page_url = current_page_url_.spec(); |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 std::string raw_data; | 1147 std::string raw_data; |
1150 base::RandBytes(WriteInto(&raw_data, kTokenBytes + 1), kTokenBytes); | 1148 base::RandBytes(WriteInto(&raw_data, kTokenBytes + 1), kTokenBytes); |
1151 base::Base64Encode(raw_data, ¤t_token_); | 1149 base::Base64Encode(raw_data, ¤t_token_); |
1152 } | 1150 } |
1153 | 1151 |
1154 // Extend expiration time another 60 seconds. | 1152 // Extend expiration time another 60 seconds. |
1155 token_expiration_time_ = current_time + base::TimeDelta::FromSeconds(60); | 1153 token_expiration_time_ = current_time + base::TimeDelta::FromSeconds(60); |
1156 | 1154 |
1157 return current_token_; | 1155 return current_token_; |
1158 } | 1156 } |
OLD | NEW |