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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java

Issue 2830843004: Update to newer Android Lint and suppress new Lint errors (Closed)
Patch Set: rebase Created 3 years, 7 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 package org.chromium.chrome.browser.contextualsearch; 5 package org.chromium.chrome.browser.contextualsearch;
6 6
7 import android.annotation.SuppressLint;
7 import android.os.Handler; 8 import android.os.Handler;
8 import android.text.TextUtils; 9 import android.text.TextUtils;
9 import android.view.View; 10 import android.view.View;
10 import android.view.ViewGroup; 11 import android.view.ViewGroup;
11 import android.view.ViewTreeObserver; 12 import android.view.ViewTreeObserver;
12 import android.view.ViewTreeObserver.OnGlobalFocusChangeListener; 13 import android.view.ViewTreeObserver.OnGlobalFocusChangeListener;
13 14
14 import org.chromium.base.ObserverList; 15 import org.chromium.base.ObserverList;
15 import org.chromium.base.SysUtils; 16 import org.chromium.base.SysUtils;
16 import org.chromium.base.VisibleForTesting; 17 import org.chromium.base.VisibleForTesting;
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 final String searchTerm, final String displayText, final String alte rnateTerm, 629 final String searchTerm, final String displayText, final String alte rnateTerm,
629 final String mid, boolean doPreventPreload, int selectionStartAdjust , 630 final String mid, boolean doPreventPreload, int selectionStartAdjust ,
630 int selectionEndAdjust, final String contextLanguage, final String t humbnailUrl, 631 int selectionEndAdjust, final String contextLanguage, final String t humbnailUrl,
631 final String caption, final String quickActionUri, final int quickAc tionCategory) { 632 final String caption, final String quickActionUri, final int quickAc tionCategory) {
632 mNetworkCommunicator.handleSearchTermResolutionResponse(isNetworkUnavail able, responseCode, 633 mNetworkCommunicator.handleSearchTermResolutionResponse(isNetworkUnavail able, responseCode,
633 searchTerm, displayText, alternateTerm, mid, doPreventPreload, s electionStartAdjust, 634 searchTerm, displayText, alternateTerm, mid, doPreventPreload, s electionStartAdjust,
634 selectionEndAdjust, contextLanguage, thumbnailUrl, caption, quic kActionUri, 635 selectionEndAdjust, contextLanguage, thumbnailUrl, caption, quic kActionUri,
635 quickActionCategory); 636 quickActionCategory);
636 } 637 }
637 638
639 @SuppressLint("StringFormatMatches")
638 @Override 640 @Override
639 public void handleSearchTermResolutionResponse(boolean isNetworkUnavailable, int responseCode, 641 public void handleSearchTermResolutionResponse(boolean isNetworkUnavailable, int responseCode,
640 String searchTerm, String displayText, String alternateTerm, String mid, 642 String searchTerm, String displayText, String alternateTerm, String mid,
641 boolean doPreventPreload, int selectionStartAdjust, int selectionEnd Adjust, 643 boolean doPreventPreload, int selectionStartAdjust, int selectionEnd Adjust,
642 String contextLanguage, String thumbnailUrl, String caption, String quickActionUri, 644 String contextLanguage, String thumbnailUrl, String caption, String quickActionUri,
643 int quickActionCategory) { 645 int quickActionCategory) {
644 if (!mInternalStateController.isStillWorkingOn(InternalState.RESOLVING)) return; 646 if (!mInternalStateController.isStillWorkingOn(InternalState.RESOLVING)) return;
645 647
646 // Show an appropriate message for what to search for. 648 // Show an appropriate message for what to search for.
647 String message; 649 String message;
648 boolean doLiteralSearch = false; 650 boolean doLiteralSearch = false;
649 if (isNetworkUnavailable) { 651 if (isNetworkUnavailable) {
650 // TODO(donnd): double-check that the network is really unavailable, maybe using 652 // TODO(donnd): double-check that the network is really unavailable, maybe using
651 // NetworkChangeNotifier#isOnline. 653 // NetworkChangeNotifier#isOnline.
652 message = mActivity.getResources().getString( 654 message = mActivity.getResources().getString(
653 R.string.contextual_search_network_unavailable); 655 R.string.contextual_search_network_unavailable);
654 } else if (!isHttpFailureCode(responseCode) && !TextUtils.isEmpty(displa yText)) { 656 } else if (!isHttpFailureCode(responseCode) && !TextUtils.isEmpty(displa yText)) {
655 message = displayText; 657 message = displayText;
656 } else if (!mPolicy.shouldShowErrorCodeInBar()) { 658 } else if (!mPolicy.shouldShowErrorCodeInBar()) {
657 message = mSelectionController.getSelectedText(); 659 message = mSelectionController.getSelectedText();
658 doLiteralSearch = true; 660 doLiteralSearch = true;
659 } else { 661 } else {
662 // TODO(crbug.com/635567): Fix lint properly.
660 message = mActivity.getResources().getString( 663 message = mActivity.getResources().getString(
661 R.string.contextual_search_error, responseCode); 664 R.string.contextual_search_error, responseCode);
662 doLiteralSearch = true; 665 doLiteralSearch = true;
663 } 666 }
664 667
665 boolean receivedCaptionOrThumbnail = !TextUtils.isEmpty(caption) 668 boolean receivedCaptionOrThumbnail = !TextUtils.isEmpty(caption)
666 || !TextUtils.isEmpty(thumbnailUrl); 669 || !TextUtils.isEmpty(thumbnailUrl);
667 670
668 mSearchPanel.onSearchTermResolved(message, thumbnailUrl, quickActionUri, 671 mSearchPanel.onSearchTermResolved(message, thumbnailUrl, quickActionUri,
669 quickActionCategory); 672 quickActionCategory);
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 private native void nativeStartSearchTermResolutionRequest(long nativeContex tualSearchManager, 1569 private native void nativeStartSearchTermResolutionRequest(long nativeContex tualSearchManager,
1567 ContextualSearchContext contextualSearchContext, WebContents baseWeb Contents); 1570 ContextualSearchContext contextualSearchContext, WebContents baseWeb Contents);
1568 protected native void nativeGatherSurroundingText(long nativeContextualSearc hManager, 1571 protected native void nativeGatherSurroundingText(long nativeContextualSearc hManager,
1569 ContextualSearchContext contextualSearchContext, WebContents baseWeb Contents); 1572 ContextualSearchContext contextualSearchContext, WebContents baseWeb Contents);
1570 private native void nativeEnableContextualSearchJsApiForOverlay( 1573 private native void nativeEnableContextualSearchJsApiForOverlay(
1571 long nativeContextualSearchManager, WebContents overlayWebContents); 1574 long nativeContextualSearchManager, WebContents overlayWebContents);
1572 // Don't call these directly, instead call the private methods that cache th e results. 1575 // Don't call these directly, instead call the private methods that cache th e results.
1573 private native String nativeGetTargetLanguage(long nativeContextualSearchMan ager); 1576 private native String nativeGetTargetLanguage(long nativeContextualSearchMan ager);
1574 private native String nativeGetAcceptLanguages(long nativeContextualSearchMa nager); 1577 private native String nativeGetAcceptLanguages(long nativeContextualSearchMa nager);
1575 } 1578 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698