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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java

Issue 2776883002: Revert of Removed SelectionPopupController.invalidateActionMode() (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.app.Activity; 8 import android.app.Activity;
9 import android.app.SearchManager; 9 import android.app.SearchManager;
10 import android.content.ClipboardManager; 10 import android.content.ClipboardManager;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 /** 187 /**
188 * Show (activate) android action mode by starting it. 188 * Show (activate) android action mode by starting it.
189 * 189 *
190 * <p>Action mode in floating mode is tried first, and then falls back to 190 * <p>Action mode in floating mode is tried first, and then falls back to
191 * a normal one. 191 * a normal one.
192 * @return {@code true} if the action mode started successfully or is alread y on. 192 * @return {@code true} if the action mode started successfully or is alread y on.
193 */ 193 */
194 public boolean showActionMode() { 194 public boolean showActionMode() {
195 if (isEmpty()) return false; 195 if (isEmpty()) return false;
196 196
197 destroyActionModeAndKeepSelection(); 197 // Just refreshes the view if it is already showing.
198 if (isActionModeValid()) {
199 invalidateActionMode();
200 return true;
201 }
198 202
199 if (mView.getParent() != null) { 203 if (mView.getParent() != null) {
200 // On ICS, startActionMode throws an NPE when getParent() is null. 204 // On ICS, startActionMode throws an NPE when getParent() is null.
201 assert mWebContents != null; 205 assert mWebContents != null;
202 ActionMode actionMode = supportsFloatingActionMode() 206 ActionMode actionMode = supportsFloatingActionMode()
203 ? startFloatingActionMode() 207 ? startFloatingActionMode()
204 : mView.startActionMode(mCallback); 208 : mView.startActionMode(mCallback);
205 if (actionMode != null) { 209 if (actionMode != null) {
206 // This is to work around an LGE email issue. See crbug.com/6517 06 for more details. 210 // This is to work around an LGE email issue. See crbug.com/6517 06 for more details.
207 LGEmailActionModeWorkaround.runIfNecessary(mContext, actionMode) ; 211 LGEmailActionModeWorkaround.runIfNecessary(mContext, actionMode) ;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 @Override 289 @Override
286 public void finishActionMode() { 290 public void finishActionMode() {
287 if (isActionModeValid()) { 291 if (isActionModeValid()) {
288 mActionMode.finish(); 292 mActionMode.finish();
289 293
290 // Should be nulled out in case #onDestroyActionMode() is not invoke d in response. 294 // Should be nulled out in case #onDestroyActionMode() is not invoke d in response.
291 mActionMode = null; 295 mActionMode = null;
292 } 296 }
293 } 297 }
294 298
299 /**
300 * @see ActionMode#invalidate()
301 * Note that invalidation will also reset visibility state. The caller
302 * should account for this when making subsequent visibility updates.
303 */
304 private void invalidateActionMode() {
305 if (!isActionModeValid()) return;
306 if (mHidden) {
307 assert canHideActionMode();
308 mHidden = false;
309 mView.removeCallbacks(mRepeatingHideRunnable);
310 mPendingInvalidateContentRect = false;
311 }
312
313 // Try/catch necessary for framework bug, crbug.com/446717.
314 try {
315 mActionMode.invalidate();
316 } catch (NullPointerException e) {
317 Log.w(TAG, "Ignoring NPE from ActionMode.invalidate() as workaround for L", e);
318 }
319 }
320
295 /** 321 /**
296 * @see ActionMode#invalidateContentRect() 322 * @see ActionMode#invalidateContentRect()
297 */ 323 */
298 public void invalidateContentRect() { 324 public void invalidateContentRect() {
299 if (supportsFloatingActionMode()) { 325 if (supportsFloatingActionMode()) {
300 if (mHidden) { 326 if (mHidden) {
301 mPendingInvalidateContentRect = true; 327 mPendingInvalidateContentRect = true;
302 } else { 328 } else {
303 mPendingInvalidateContentRect = false; 329 mPendingInvalidateContentRect = false;
304 if (isActionModeValid()) mActionMode.invalidateContentRect(); 330 if (isActionModeValid()) mActionMode.invalidateContentRect();
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 mIsInsertion = insertion; 903 mIsInsertion = insertion;
878 } 904 }
879 905
880 private boolean isShareAvailable() { 906 private boolean isShareAvailable() {
881 Intent intent = new Intent(Intent.ACTION_SEND); 907 Intent intent = new Intent(Intent.ACTION_SEND);
882 intent.setType("text/plain"); 908 intent.setType("text/plain");
883 return mContext.getPackageManager().queryIntentActivities(intent, 909 return mContext.getPackageManager().queryIntentActivities(intent,
884 PackageManager.MATCH_DEFAULT_ONLY).size() > 0; 910 PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
885 } 911 }
886 } 912 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698