| Index: chrome/browser/tab_contents/render_view_context_menu.cc
|
| diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
|
| index ba0b6bb639393b5e3d5bcfb6fd8cc0acde2859e1..8cb23b524a7e5fe895810a480f0c385e9981ae33 100644
|
| --- a/chrome/browser/tab_contents/render_view_context_menu.cc
|
| +++ b/chrome/browser/tab_contents/render_view_context_menu.cc
|
| @@ -18,6 +18,7 @@
|
| #include "base/time.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/app/chrome_command_ids.h"
|
| +#include "chrome/browser/app_mode/app_mode_utils.h"
|
| #include "chrome/browser/autocomplete/autocomplete_classifier.h"
|
| #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
|
| #include "chrome/browser/autocomplete/autocomplete_match.h"
|
| @@ -231,9 +232,9 @@ void DevToolsInspectElementAt(RenderViewHost* rvh, int x, int y) {
|
| }
|
|
|
| // Helper function to escape "&" as "&&".
|
| -void EscapeAmpersands(string16& text) {
|
| +void EscapeAmpersands(string16* text) {
|
| const char16 ampersand[] = {'&', 0};
|
| - ReplaceChars(text, ampersand, ASCIIToUTF16("&&"), &text);
|
| + ReplaceChars(*text, ampersand, ASCIIToUTF16("&&"), text);
|
| }
|
|
|
| } // namespace
|
| @@ -298,9 +299,9 @@ bool RenderViewContextMenu::ExtensionContextAndPatternMatch(
|
| const content::ContextMenuParams& params,
|
| MenuItem::ContextList contexts,
|
| const extensions::URLPatternSet& target_url_patterns) {
|
| - bool has_link = !params.link_url.is_empty();
|
| - bool has_selection = !params.selection_text.empty();
|
| - bool in_frame = !params.frame_url.is_empty();
|
| + const bool has_link = !params.link_url.is_empty();
|
| + const bool has_selection = !params.selection_text.empty();
|
| + const bool in_frame = !params.frame_url.is_empty();
|
|
|
| if (contexts.Contains(MenuItem::ALL) ||
|
| (has_selection && contexts.Contains(MenuItem::SELECTION)) ||
|
| @@ -395,7 +396,7 @@ void RenderViewContextMenu::AppendAllExtensionItems() {
|
| for (i = sorted_ids.begin();
|
| i != sorted_ids.end(); ++i) {
|
| string16 printable_selection_text = PrintableSelectionText();
|
| - EscapeAmpersands(printable_selection_text);
|
| + EscapeAmpersands(&printable_selection_text);
|
|
|
| extension_items_.AppendExtensionItems(i->second, printable_selection_text,
|
| &index);
|
| @@ -406,6 +407,11 @@ void RenderViewContextMenu::AppendAllExtensionItems() {
|
| }
|
|
|
| void RenderViewContextMenu::InitMenu() {
|
| + if (chrome::IsRunningInForcedAppMode()) {
|
| + AppendAppModeItems();
|
| + return;
|
| + }
|
| +
|
| chrome::ViewType view_type = chrome::GetViewType(source_web_contents_);
|
| if (view_type == chrome::VIEW_TYPE_APP_SHELL) {
|
| AppendPlatformAppItems();
|
| @@ -418,8 +424,8 @@ void RenderViewContextMenu::InitMenu() {
|
| return;
|
| }
|
|
|
| - bool has_link = !params_.unfiltered_link_url.is_empty();
|
| - bool has_selection = !params_.selection_text.empty();
|
| + const bool has_link = !params_.unfiltered_link_url.is_empty();
|
| + const bool has_selection = !params_.selection_text.empty();
|
|
|
| if (AppendCustomItems()) {
|
| // If there's a selection, don't early return when there are custom items,
|
| @@ -519,6 +525,15 @@ const Extension* RenderViewContextMenu::GetExtension() const {
|
| source_web_contents_->GetRenderViewHost());
|
| }
|
|
|
| +void RenderViewContextMenu::AppendAppModeItems() {
|
| + const bool has_selection = !params_.selection_text.empty();
|
| +
|
| + if (params_.is_editable)
|
| + AppendEditableItems();
|
| + else if (has_selection)
|
| + AppendCopyItem();
|
| +}
|
| +
|
| void RenderViewContextMenu::AppendPlatformAppItems() {
|
| const Extension* platform_app = GetExtension();
|
|
|
| @@ -528,7 +543,7 @@ void RenderViewContextMenu::AppendPlatformAppItems() {
|
|
|
| DCHECK(platform_app->is_platform_app());
|
|
|
| - bool has_selection = !params_.selection_text.empty();
|
| + const bool has_selection = !params_.selection_text.empty();
|
|
|
| // Add undo/redo, cut/copy/paste etc for text fields.
|
| if (params_.is_editable)
|
| @@ -558,7 +573,7 @@ void RenderViewContextMenu::AppendPlatformAppItems() {
|
| }
|
|
|
| void RenderViewContextMenu::AppendPopupExtensionItems() {
|
| - bool has_selection = !params_.selection_text.empty();
|
| + const bool has_selection = !params_.selection_text.empty();
|
|
|
| if (params_.is_editable)
|
| AppendEditableItems();
|
| @@ -832,7 +847,7 @@ void RenderViewContextMenu::AppendSearchProvider() {
|
| return;
|
|
|
| string16 printable_selection_text = PrintableSelectionText();
|
| - EscapeAmpersands(printable_selection_text);
|
| + EscapeAmpersands(&printable_selection_text);
|
|
|
| if (AutocompleteMatch::IsSearchType(match.type)) {
|
| const TemplateURL* const default_provider =
|
| @@ -858,7 +873,10 @@ void RenderViewContextMenu::AppendSearchProvider() {
|
| }
|
|
|
| void RenderViewContextMenu::AppendEditableItems() {
|
| - AppendSpellingSuggestionsSubMenu();
|
| + const bool use_spellcheck_and_search = !chrome::IsRunningInForcedAppMode();
|
| +
|
| + if (use_spellcheck_and_search)
|
| + AppendSpellingSuggestionsSubMenu();
|
|
|
| menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_UNDO,
|
| IDS_CONTENT_CONTEXT_UNDO);
|
| @@ -877,13 +895,14 @@ void RenderViewContextMenu::AppendEditableItems() {
|
| IDS_CONTENT_CONTEXT_DELETE);
|
| menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
|
|
|
| - if (!params_.keyword_url.is_empty()) {
|
| + if (use_spellcheck_and_search && !params_.keyword_url.is_empty()) {
|
| menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ADDSEARCHENGINE,
|
| IDS_CONTENT_CONTEXT_ADDSEARCHENGINE);
|
| menu_model_.AddSeparator(ui::NORMAL_SEPARATOR);
|
| }
|
|
|
| - AppendSpellcheckOptionsSubMenu();
|
| + if (use_spellcheck_and_search)
|
| + AppendSpellcheckOptionsSubMenu();
|
| AppendSpeechInputOptionsSubMenu();
|
| AppendPlatformEditableItems();
|
|
|
|
|