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

Side by Side Diff: chrome/browser/android/contextualsearch/contextual_search_delegate.cc

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: Created 4 years, 2 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 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>
9 8
10 #include "base/base64.h" 9 #include "base/base64.h"
11 #include "base/command_line.h" 10 #include "base/command_line.h"
12 #include "base/json/json_string_value_serializer.h" 11 #include "base/json/json_string_value_serializer.h"
13 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/android/contextualsearch/contextual_search_field_trial. h" 15 #include "chrome/browser/android/contextualsearch/contextual_search_field_trial. h"
17 #include "chrome/browser/android/contextualsearch/resolved_search_term.h" 16 #include "chrome/browser/android/contextualsearch/resolved_search_term.h"
18 #include "chrome/browser/android/proto/client_discourse_context.pb.h" 17 #include "chrome/browser/android/proto/client_discourse_context.pb.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 const char kXssiEscape[] = ")]}'\n"; 53 const char kXssiEscape[] = ")]}'\n";
55 const char kDiscourseContextHeaderPrefix[] = "X-Additional-Discourse-Context: "; 54 const char kDiscourseContextHeaderPrefix[] = "X-Additional-Discourse-Context: ";
56 const char kDoPreventPreloadValue[] = "1"; 55 const char kDoPreventPreloadValue[] = "1";
57 56
58 // The number of characters that should be shown after the selected expression. 57 // The number of characters that should be shown after the selected expression.
59 const int kSurroundingSizeForUI = 60; 58 const int kSurroundingSizeForUI = 60;
60 59
61 // The version of the Contextual Cards API that we want to invoke. 60 // The version of the Contextual Cards API that we want to invoke.
62 const int kContextualCardsVersion = 1; 61 const int kContextualCardsVersion = 1;
63 62
64 } // namespace 63 } // namespace
65 64
66 // URLFetcher ID, only used for tests: we only have one kind of fetcher. 65 // URLFetcher ID, only used for tests: we only have one kind of fetcher.
67 const int ContextualSearchDelegate::kContextualSearchURLFetcherID = 1; 66 const int ContextualSearchDelegate::kContextualSearchURLFetcherID = 1;
68 67
69 // Handles tasks for the ContextualSearchManager in a separable, testable way. 68 // Handles tasks for the ContextualSearchManager in a separable, testable way.
70 ContextualSearchDelegate::ContextualSearchDelegate( 69 ContextualSearchDelegate::ContextualSearchDelegate(
71 net::URLRequestContextGetter* url_request_context, 70 net::URLRequestContextGetter* url_request_context,
72 TemplateURLService* template_url_service, 71 TemplateURLService* template_url_service,
73 const ContextualSearchDelegate::SearchTermResolutionCallback& 72 const ContextualSearchDelegate::SearchTermResolutionCallback&
74 search_term_callback, 73 search_term_callback,
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 402
404 // Only allow HTTP URLs or HTTPS URLs. 403 // Only allow HTTP URLs or HTTPS URLs.
405 if (current_page_url.scheme() != url::kHttpScheme && 404 if (current_page_url.scheme() != url::kHttpScheme &&
406 (current_page_url.scheme() != url::kHttpsScheme)) 405 (current_page_url.scheme() != url::kHttpsScheme))
407 return false; 406 return false;
408 407
409 // Check that the user has sync enabled, is logged in, and syncs their Chrome 408 // Check that the user has sync enabled, is logged in, and syncs their Chrome
410 // History. 409 // History.
411 browser_sync::ProfileSyncService* service = 410 browser_sync::ProfileSyncService* service =
412 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); 411 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
413 syncer::SyncPrefs sync_prefs(profile->GetPrefs()); 412 sync_driver::SyncPrefs sync_prefs(profile->GetPrefs());
414 if (service == NULL || !service->CanSyncStart() || 413 if (service == NULL || !service->CanSyncStart() ||
415 !sync_prefs.GetPreferredDataTypes(syncer::UserTypes()) 414 !sync_prefs.GetPreferredDataTypes(syncer::UserTypes())
416 .Has(syncer::PROXY_TABS) || 415 .Has(syncer::PROXY_TABS) ||
417 !service->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES)) { 416 !service->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES)) {
418 return false; 417 return false;
419 } 418 }
420 419
421 return true; 420 return true;
422 } 421 }
423 422
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 end_offset -= trim; 537 end_offset -= trim;
539 } 538 }
540 if (result_text.length() > end_offset + padding_each_side_pinned) { 539 if (result_text.length() > end_offset + padding_each_side_pinned) {
541 // Trim the end. 540 // Trim the end.
542 result_text = result_text.substr(0, end_offset + padding_each_side_pinned); 541 result_text = result_text.substr(0, end_offset + padding_each_side_pinned);
543 } 542 }
544 *start = start_offset; 543 *start = start_offset;
545 *end = end_offset; 544 *end = end_offset;
546 return result_text; 545 return result_text;
547 } 546 }
OLDNEW
« no previous file with comments | « chrome/browser/android/contextualsearch/contextual_search_delegate.h ('k') | chrome/browser/android/foreign_session_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698