| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.content.ClipboardManager; | 7 import android.content.ClipboardManager; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.res.Resources; |
| 9 import android.graphics.Rect; | 10 import android.graphics.Rect; |
| 10 import android.view.ActionMode; | 11 import android.view.ActionMode; |
| 11 import android.view.Menu; | 12 import android.view.Menu; |
| 12 import android.view.MenuInflater; | 13 import android.view.MenuInflater; |
| 13 import android.view.MenuItem; | 14 import android.view.MenuItem; |
| 14 import android.view.View; | 15 import android.view.View; |
| 15 | 16 |
| 16 import org.chromium.content.R; | 17 import org.chromium.content.R; |
| 17 | 18 |
| 18 /** | 19 /** |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 mIsPasswordType = isPasswordNow; | 136 mIsPasswordType = isPasswordNow; |
| 136 mIsInsertion = isInsertionNow; | 137 mIsInsertion = isInsertionNow; |
| 137 menu.clear(); | 138 menu.clear(); |
| 138 createActionMenu(mode, menu); | 139 createActionMenu(mode, menu); |
| 139 return true; | 140 return true; |
| 140 } | 141 } |
| 141 return false; | 142 return false; |
| 142 } | 143 } |
| 143 | 144 |
| 144 private void createActionMenu(ActionMode mode, Menu menu) { | 145 private void createActionMenu(ActionMode mode, Menu menu) { |
| 145 new MenuInflater(getContext()).inflate(R.menu.select_action_menu, menu); | 146 try { |
| 147 mode.getMenuInflater().inflate(R.menu.select_action_menu, menu); |
| 148 } catch (Resources.NotFoundException e) { |
| 149 // TODO(tobiasjs) by the time we get here we have already |
| 150 // caused a resource loading failure to be logged. WebView |
| 151 // resource access needs to be improved so that this |
| 152 // logspam can be avoided. |
| 153 new MenuInflater(getContext()).inflate(R.menu.select_action_menu, me
nu); |
| 154 } |
| 146 | 155 |
| 147 if (mIsInsertion) { | 156 if (mIsInsertion) { |
| 148 menu.removeItem(R.id.select_action_menu_select_all); | 157 menu.removeItem(R.id.select_action_menu_select_all); |
| 149 menu.removeItem(R.id.select_action_menu_cut); | 158 menu.removeItem(R.id.select_action_menu_cut); |
| 150 menu.removeItem(R.id.select_action_menu_copy); | 159 menu.removeItem(R.id.select_action_menu_copy); |
| 151 menu.removeItem(R.id.select_action_menu_share); | 160 menu.removeItem(R.id.select_action_menu_share); |
| 152 menu.removeItem(R.id.select_action_menu_web_search); | 161 menu.removeItem(R.id.select_action_menu_web_search); |
| 153 return; | 162 return; |
| 154 } | 163 } |
| 155 | 164 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 public void onGetContentRect(ActionMode mode, View view, Rect outRect) { | 228 public void onGetContentRect(ActionMode mode, View view, Rect outRect) { |
| 220 mActionHandler.onGetContentRect(outRect); | 229 mActionHandler.onGetContentRect(outRect); |
| 221 } | 230 } |
| 222 | 231 |
| 223 private boolean canPaste() { | 232 private boolean canPaste() { |
| 224 ClipboardManager clipMgr = (ClipboardManager) | 233 ClipboardManager clipMgr = (ClipboardManager) |
| 225 getContext().getSystemService(Context.CLIPBOARD_SERVICE); | 234 getContext().getSystemService(Context.CLIPBOARD_SERVICE); |
| 226 return clipMgr.hasPrimaryClip(); | 235 return clipMgr.hasPrimaryClip(); |
| 227 } | 236 } |
| 228 } | 237 } |
| OLD | NEW |