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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 if (resolved_term != *search_term) { | 494 if (resolved_term != *search_term) { |
495 *alternate_term = resolved_term; | 495 *alternate_term = resolved_term; |
496 } | 496 } |
497 } | 497 } |
498 | 498 |
499 if (field_trial_->IsContextualCardsBarIntegrationEnabled()) { | 499 if (field_trial_->IsContextualCardsBarIntegrationEnabled()) { |
500 // Get the basic Bar data for Contextual Cards integration directly | 500 // Get the basic Bar data for Contextual Cards integration directly |
501 // from the root. | 501 // from the root. |
502 dict->GetString(kContextualSearchCaption, caption); | 502 dict->GetString(kContextualSearchCaption, caption); |
503 dict->GetString(kContextualSearchThumbnail, thumbnail_url); | 503 dict->GetString(kContextualSearchThumbnail, thumbnail_url); |
| 504 // For testing purposes check if there was a coca backend failure and |
| 505 // flag that in the log. |
| 506 // TODO(donnd): remove after full Coca integration. |
| 507 bool contextual_cards_backend_responded = true; |
| 508 dict->GetBoolean("coca_responded", &contextual_cards_backend_responded); |
| 509 if (!contextual_cards_backend_responded) { |
| 510 DVLOG(0) << ""; |
| 511 DVLOG(0) << "!!! CONTEXTUAL SEARCH WARNING !!!"; |
| 512 DVLOG(0) |
| 513 << "The Contextual Cards backend did not respond to this " |
| 514 "request!!! The backend server may not be configured or is down."; |
| 515 DVLOG(0) << ""; |
| 516 } |
504 } | 517 } |
505 } | 518 } |
506 | 519 |
507 // Extract the Start/End of the mentions in the surrounding text | 520 // Extract the Start/End of the mentions in the surrounding text |
508 // for selection-expansion. | 521 // for selection-expansion. |
509 void ContextualSearchDelegate::ExtractMentionsStartEnd( | 522 void ContextualSearchDelegate::ExtractMentionsStartEnd( |
510 const base::ListValue& mentions_list, | 523 const base::ListValue& mentions_list, |
511 int* startResult, | 524 int* startResult, |
512 int* endResult) { | 525 int* endResult) { |
513 int int_value; | 526 int int_value; |
(...skipping 23 matching lines...) Expand all Loading... |
537 end_offset -= trim; | 550 end_offset -= trim; |
538 } | 551 } |
539 if (result_text.length() > end_offset + padding_each_side_pinned) { | 552 if (result_text.length() > end_offset + padding_each_side_pinned) { |
540 // Trim the end. | 553 // Trim the end. |
541 result_text = result_text.substr(0, end_offset + padding_each_side_pinned); | 554 result_text = result_text.substr(0, end_offset + padding_each_side_pinned); |
542 } | 555 } |
543 *start = start_offset; | 556 *start = start_offset; |
544 *end = end_offset; | 557 *end = end_offset; |
545 return result_text; | 558 return result_text; |
546 } | 559 } |
OLD | NEW |