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

Side by Side Diff: ios/chrome/browser/ui/contextual_search/contextual_search_delegate.cc

Issue 2816383002: Remove non-const version of GetDefaultSearchProvider() and make all callers call the const version (Closed)
Patch Set: Fix unit test (the model was already loaded) Created 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ios/chrome/browser/ui/contextual_search/contextual_search_delegate.h" 5 #include "ios/chrome/browser/ui/contextual_search/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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 std::string request = 260 std::string request =
261 GetSearchTermResolutionUrlString(selected_text_escaped, base_page_url); 261 GetSearchTermResolutionUrlString(selected_text_escaped, base_page_url);
262 262
263 return GURL(request); 263 return GURL(request);
264 } 264 }
265 265
266 std::string ContextualSearchDelegate::GetSearchTermResolutionUrlString( 266 std::string ContextualSearchDelegate::GetSearchTermResolutionUrlString(
267 const std::string& selected_text, 267 const std::string& selected_text,
268 const std::string& base_page_url) { 268 const std::string& base_page_url) {
269 TemplateURL* template_url = template_url_service_->GetDefaultSearchProvider(); 269 const TemplateURL* template_url =
270 template_url_service_->GetDefaultSearchProvider();
270 271
271 TemplateURLRef::SearchTermsArgs search_terms_args = 272 TemplateURLRef::SearchTermsArgs search_terms_args =
272 TemplateURLRef::SearchTermsArgs(base::string16()); 273 TemplateURLRef::SearchTermsArgs(base::string16());
273 274
274 TemplateURLRef::SearchTermsArgs::ContextualSearchParams params( 275 TemplateURLRef::SearchTermsArgs::ContextualSearchParams params(
275 kContextualSearchRequestVersion, kContextualCardsNoIntegration, 276 kContextualSearchRequestVersion, kContextualCardsNoIntegration,
276 std::string()); 277 std::string());
277 278
278 search_terms_args.contextual_search_params = params; 279 search_terms_args.contextual_search_params = params;
279 280
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 proto.SerializeToString(&serialized); 326 proto.SerializeToString(&serialized);
326 327
327 std::string encoded_context; 328 std::string encoded_context;
328 base::Base64Encode(serialized, &encoded_context); 329 base::Base64Encode(serialized, &encoded_context);
329 // The server memoizer expects a web-safe encoding. 330 // The server memoizer expects a web-safe encoding.
330 std::replace(encoded_context.begin(), encoded_context.end(), '+', '-'); 331 std::replace(encoded_context.begin(), encoded_context.end(), '+', '-');
331 std::replace(encoded_context.begin(), encoded_context.end(), '/', '_'); 332 std::replace(encoded_context.begin(), encoded_context.end(), '/', '_');
332 search_term_fetcher_->AddExtraRequestHeader(kDiscourseContextHeaderPrefix + 333 search_term_fetcher_->AddExtraRequestHeader(kDiscourseContextHeaderPrefix +
333 encoded_context); 334 encoded_context);
334 } 335 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698