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

Unified Diff: chrome/browser/renderer_context_menu/spelling_menu_observer.cc

Issue 1357393002: Desktop context menu reorganisation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/renderer_context_menu/spelling_menu_observer.cc
diff --git a/chrome/browser/renderer_context_menu/spelling_menu_observer.cc b/chrome/browser/renderer_context_menu/spelling_menu_observer.cc
index 330e583d921c267146699a1875a3277b8d07a215..645b600e9fc768f734e505688d3c1907079353d2 100644
--- a/chrome/browser/renderer_context_menu/spelling_menu_observer.cc
+++ b/chrome/browser/renderer_context_menu/spelling_menu_observer.cc
@@ -35,6 +35,8 @@
using content::BrowserThread;
+const int kMaxSpellingSuggestions = 3;
+
SpellingMenuObserver::SpellingMenuObserver(RenderViewContextMenuProxy* proxy)
: proxy_(proxy),
loading_frame_(0),
@@ -79,7 +81,9 @@ void SpellingMenuObserver::InitMenu(const content::ContextMenuParams& params) {
proxy_->AddSeparator();
// Append Dictionary spell check suggestions.
- for (size_t i = 0; i < params.dictionary_suggestions.size() &&
+ int length = std::min(kMaxSpellingSuggestions,
+ static_cast<int>(params.dictionary_suggestions.size()));
+ for (int i = 0; i < length &&
IDC_SPELLCHECK_SUGGESTION_0 + i <= IDC_SPELLCHECK_SUGGESTION_LAST;
++i) {
proxy_->AddMenuItem(IDC_SPELLCHECK_SUGGESTION_0 + static_cast<int>(i),
@@ -146,17 +150,7 @@ void SpellingMenuObserver::InitMenu(const content::ContextMenuParams& params) {
}
}
- if (params.dictionary_suggestions.empty()) {
- proxy_->AddMenuItem(
- IDC_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS,
- l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS));
- bool use_spelling_service = SpellingServiceClient::IsAvailable(
- browser_context, SpellingServiceClient::SPELLCHECK);
- if (use_suggestions || use_spelling_service)
- proxy_->AddSeparator();
- } else {
- proxy_->AddSeparator();
-
+ if (!params.dictionary_suggestions.empty()) {
// |spellcheck_service| can be null when the suggested word is
// provided by Web SpellCheck API.
SpellcheckService* spellcheck_service =

Powered by Google App Engine
This is Rietveld 408576698