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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java

Issue 396063009: Context Menu "Open image" doesn't make sense in a Image URL Tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated comment as suggested Created 6 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.contextmenu; 5 package org.chromium.chrome.browser.contextmenu;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.Build; 8 import android.os.Build;
9 import android.text.TextUtils; 9 import android.text.TextUtils;
10 import android.view.ContextMenu; 10 import android.view.ContextMenu;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } else if (params.isImage()) { 68 } else if (params.isImage()) {
69 menu.findItem(R.id.contextmenu_save_image).setEnabled( 69 menu.findItem(R.id.contextmenu_save_image).setEnabled(
70 UrlUtilities.isDownloadableScheme(params.getSrcUrl())); 70 UrlUtilities.isDownloadableScheme(params.getSrcUrl()));
71 71
72 if (mDelegate.canLoadOriginalImage()) { 72 if (mDelegate.canLoadOriginalImage()) {
73 menu.findItem(R.id.contextmenu_open_image_in_new_tab).setVisible (false); 73 menu.findItem(R.id.contextmenu_open_image_in_new_tab).setVisible (false);
74 } else { 74 } else {
75 menu.findItem(R.id.contextmenu_open_original_image_in_new_tab).s etVisible(false); 75 menu.findItem(R.id.contextmenu_open_original_image_in_new_tab).s etVisible(false);
76 } 76 }
77 77
78 // Avoid showing open image option for same image which is already o pened.
79 if (mDelegate.getPageUrl().equals(params.getSrcUrl())) {
80 menu.findItem(R.id.contextmenu_open_image).setVisible(false);
81 }
78 final TemplateUrlService templateUrlServiceInstance = TemplateUrlSer vice.getInstance(); 82 final TemplateUrlService templateUrlServiceInstance = TemplateUrlSer vice.getInstance();
79 final boolean isSearchByImageAvailable = 83 final boolean isSearchByImageAvailable =
80 UrlUtilities.isDownloadableScheme(params.getSrcUrl()) && 84 UrlUtilities.isDownloadableScheme(params.getSrcUrl()) &&
81 templateUrlServiceInstance.isLoaded() && 85 templateUrlServiceInstance.isLoaded() &&
82 templateUrlServiceInstance.isSearchByImageAvailable( ) && 86 templateUrlServiceInstance.isSearchByImageAvailable( ) &&
83 templateUrlServiceInstance.getDefaultSearchEngineTem plateUrl() != null; 87 templateUrlServiceInstance.getDefaultSearchEngineTem plateUrl() != null;
84 88
85 menu.findItem(R.id.contextmenu_search_by_image).setVisible(isSearchB yImageAvailable); 89 menu.findItem(R.id.contextmenu_search_by_image).setVisible(isSearchB yImageAvailable);
86 if (isSearchByImageAvailable) { 90 if (isSearchByImageAvailable) {
87 menu.findItem(R.id.contextmenu_search_by_image).setTitle( 91 menu.findItem(R.id.contextmenu_search_by_image).setTitle(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 mDelegate.onSearchByImageInNewTab(); 123 mDelegate.onSearchByImageInNewTab();
120 } else if (itemId == R.id.contextmenu_copy_image) { 124 } else if (itemId == R.id.contextmenu_copy_image) {
121 mDelegate.onSaveImageToClipboard(params.getSrcUrl()); 125 mDelegate.onSaveImageToClipboard(params.getSrcUrl());
122 } else { 126 } else {
123 assert false; 127 assert false;
124 } 128 }
125 129
126 return true; 130 return true;
127 } 131 }
128 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698