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..d909963489edfd4fbbf0f44511f0032cf52b8e11 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 |
@@ -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(); |
@@ -519,6 +525,15 @@ const Extension* RenderViewContextMenu::GetExtension() const { |
source_web_contents_->GetRenderViewHost()); |
} |
+void RenderViewContextMenu::AppendAppModeItems() { |
+ bool has_selection = !params_.selection_text.empty(); |
tfarina
2013/03/04 21:07:58
do you want to avoid this temp variable? otherwise
xiyuan
2013/03/04 21:55:32
Added "const" here and all similar cases in this f
|
+ |
+ if (params_.is_editable) |
+ AppendEditableItems(); |
+ else if (has_selection) |
+ AppendCopyItem(); |
+} |
+ |
void RenderViewContextMenu::AppendPlatformAppItems() { |
const Extension* platform_app = GetExtension(); |
@@ -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(); |