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 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 // Only allow HTTP URLs or HTTPS URLs. | 375 // Only allow HTTP URLs or HTTPS URLs. |
376 if (current_page_url.scheme() != url::kHttpScheme && | 376 if (current_page_url.scheme() != url::kHttpScheme && |
377 (current_page_url.scheme() != url::kHttpsScheme)) | 377 (current_page_url.scheme() != url::kHttpsScheme)) |
378 return false; | 378 return false; |
379 | 379 |
380 // Check that the user has sync enabled, is logged in, and syncs their Chrome | 380 // Check that the user has sync enabled, is logged in, and syncs their Chrome |
381 // History. | 381 // History. |
382 ProfileSyncService* service = | 382 ProfileSyncService* service = |
383 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | 383 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
384 sync_driver::SyncPrefs sync_prefs(profile->GetPrefs()); | 384 sync_driver::SyncPrefs sync_prefs(profile->GetPrefs()); |
385 if (service == NULL || !service->IsSyncEnabledAndLoggedIn() || | 385 if (service == NULL || !service->CanSyncStart() || |
386 !sync_prefs.GetPreferredDataTypes(syncer::UserTypes()) | 386 !sync_prefs.GetPreferredDataTypes(syncer::UserTypes()) |
387 .Has(syncer::PROXY_TABS) || | 387 .Has(syncer::PROXY_TABS) || |
388 !service->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES)) { | 388 !service->GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES)) { |
389 return false; | 389 return false; |
390 } | 390 } |
391 | 391 |
392 return true; | 392 return true; |
393 } | 393 } |
394 | 394 |
395 // Decodes the given response from the search term resolution request and sets | 395 // Decodes the given response from the search term resolution request and sets |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 end_offset -= trim; | 481 end_offset -= trim; |
482 } | 482 } |
483 if (result_text.length() > end_offset + padding_each_side_pinned) { | 483 if (result_text.length() > end_offset + padding_each_side_pinned) { |
484 // Trim the end. | 484 // Trim the end. |
485 result_text = result_text.substr(0, end_offset + padding_each_side_pinned); | 485 result_text = result_text.substr(0, end_offset + padding_each_side_pinned); |
486 } | 486 } |
487 *start = start_offset; | 487 *start = start_offset; |
488 *end = end_offset; | 488 *end = end_offset; |
489 return result_text; | 489 return result_text; |
490 } | 490 } |
OLD | NEW |