OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/android/contextualsearch/contextual_search_delegate.h" | 5 #include "chrome/browser/android/contextualsearch/contextual_search_delegate.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 DCHECK(request_url.is_valid()); | 129 DCHECK(request_url.is_valid()); |
130 | 130 |
131 // Reset will delete any previous fetcher, and we won't get any callback. | 131 // Reset will delete any previous fetcher, and we won't get any callback. |
132 search_term_fetcher_.reset( | 132 search_term_fetcher_.reset( |
133 net::URLFetcher::Create(kContextualSearchURLFetcherID, request_url, | 133 net::URLFetcher::Create(kContextualSearchURLFetcherID, request_url, |
134 net::URLFetcher::GET, this).release()); | 134 net::URLFetcher::GET, this).release()); |
135 search_term_fetcher_->SetRequestContext(url_request_context_); | 135 search_term_fetcher_->SetRequestContext(url_request_context_); |
136 | 136 |
137 // Add Chrome experiment state to the request headers. | 137 // Add Chrome experiment state to the request headers. |
138 net::HttpRequestHeaders headers; | 138 net::HttpRequestHeaders headers; |
139 // Note: It's fine to pass in |is_signed_in| false, which does not affect | 139 // Note: It's OK to pass |is_signed_in| false if it's unknown, as it does |
140 // transmission of experiment ids coming from the variations server. | 140 // not affect transmission of experiments coming from the variations server. |
141 bool is_signed_in = false; | 141 bool is_signed_in = false; |
142 variations::AppendVariationHeaders( | 142 variations::AppendVariationHeaders( |
143 search_term_fetcher_->GetOriginalURL(), | 143 search_term_fetcher_->GetOriginalURL(), |
144 false, // Impossible to be incognito at this point. | 144 false, // Impossible to be incognito at this point. |
145 false, is_signed_in, &headers); | 145 false, is_signed_in, &headers); |
146 search_term_fetcher_->SetExtraRequestHeaders(headers.ToString()); | 146 search_term_fetcher_->SetExtraRequestHeaders(headers.ToString()); |
147 | 147 |
148 SetDiscourseContextAndAddToHeader(*context_); | 148 SetDiscourseContextAndAddToHeader(*context_); |
149 | 149 |
150 search_term_fetcher_->Start(); | 150 search_term_fetcher_->Start(); |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 end_offset -= trim; | 608 end_offset -= trim; |
609 } | 609 } |
610 if (result_text.length() > end_offset + padding_each_side_pinned) { | 610 if (result_text.length() > end_offset + padding_each_side_pinned) { |
611 // Trim the end. | 611 // Trim the end. |
612 result_text = result_text.substr(0, end_offset + padding_each_side_pinned); | 612 result_text = result_text.substr(0, end_offset + padding_each_side_pinned); |
613 } | 613 } |
614 *start = start_offset; | 614 *start = start_offset; |
615 *end = end_offset; | 615 *end = end_offset; |
616 return result_text; | 616 return result_text; |
617 } | 617 } |
OLD | NEW |