| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 5 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/app/chrome_dll_resource.h" | 8 #include "chrome/app/chrome_dll_resource.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| 11 #include "chrome/browser/search_engines/template_url_model.h" | 11 #include "chrome/browser/search_engines/template_url_model.h" |
| 12 #include "chrome/browser/spellchecker.h" | 12 #include "chrome/browser/spellchecker.h" |
| 13 #include "chrome/common/l10n_util.h" | 13 #include "chrome/common/l10n_util.h" |
| 14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 15 | 15 |
| 16 RenderViewContextMenu::RenderViewContextMenu( | 16 RenderViewContextMenu::RenderViewContextMenu( |
| 17 Menu::Delegate* delegate, | 17 Menu::Delegate* delegate, |
| 18 HWND owner, | 18 gfx::NativeWindow owner, |
| 19 ContextNode node, | 19 ContextNode node, |
| 20 const std::wstring& misspelled_word, | 20 const std::wstring& misspelled_word, |
| 21 const std::vector<std::wstring>& misspelled_word_suggestions, | 21 const std::vector<std::wstring>& misspelled_word_suggestions, |
| 22 Profile* profile) | 22 Profile* profile) |
| 23 : Menu(delegate, Menu::TOPLEFT, owner), | 23 : Menu(delegate, Menu::TOPLEFT, owner), |
| 24 misspelled_word_(misspelled_word), | 24 misspelled_word_(misspelled_word), |
| 25 misspelled_word_suggestions_(misspelled_word_suggestions), | 25 misspelled_word_suggestions_(misspelled_word_suggestions), |
| 26 profile_(profile) { | 26 profile_(profile) { |
| 27 InitMenu(node); | 27 InitMenu(node); |
| 28 } | 28 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 void RenderViewContextMenu::AppendEditableItems() { | 113 void RenderViewContextMenu::AppendEditableItems() { |
| 114 // Append Dictionary spell check suggestions. | 114 // Append Dictionary spell check suggestions. |
| 115 for (size_t i = 0; i < misspelled_word_suggestions_.size() && | 115 for (size_t i = 0; i < misspelled_word_suggestions_.size() && |
| 116 IDC_SPELLCHECK_SUGGESTION_0 + i <= IDC_SPELLCHECK_SUGGESTION_LAST; | 116 IDC_SPELLCHECK_SUGGESTION_0 + i <= IDC_SPELLCHECK_SUGGESTION_LAST; |
| 117 i ++) { | 117 i ++) { |
| 118 AppendMenuItemWithLabel(IDC_SPELLCHECK_SUGGESTION_0 + static_cast<int>(i), | 118 AppendMenuItemWithLabel(IDC_SPELLCHECK_SUGGESTION_0 + static_cast<int>(i), |
| 119 misspelled_word_suggestions_[i]); | 119 misspelled_word_suggestions_[i]); |
| 120 } | 120 } |
| 121 if (misspelled_word_suggestions_.size() > 0) | 121 if (misspelled_word_suggestions_.size() > 0) |
| 122 AppendSeparator(); | 122 AppendSeparator(); |
| 123 | 123 |
| 124 // If word is misspelled, give option for "Add to dictionary" | 124 // If word is misspelled, give option for "Add to dictionary" |
| 125 if (!misspelled_word_.empty()) { | 125 if (!misspelled_word_.empty()) { |
| 126 if (misspelled_word_suggestions_.size() == 0) { | 126 if (misspelled_word_suggestions_.size() == 0) { |
| 127 AppendMenuItemWithLabel(0, | 127 AppendMenuItemWithLabel(0, |
| 128 l10n_util::GetString(IDS_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS)); | 128 l10n_util::GetString(IDS_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS)); |
| 129 } | 129 } |
| 130 AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY); | 130 AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY); |
| 131 AppendSeparator(); | 131 AppendSeparator(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_UNDO); | 134 AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_UNDO); |
| 135 AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_REDO); | 135 AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_REDO); |
| 136 AppendSeparator(); | 136 AppendSeparator(); |
| 137 AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_CUT); | 137 AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_CUT); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 165 | 165 |
| 166 // Add 'Check the spelling of this field' item in the sub menu. | 166 // Add 'Check the spelling of this field' item in the sub menu. |
| 167 spellchecker_sub_menu_->AppendMenuItem( | 167 spellchecker_sub_menu_->AppendMenuItem( |
| 168 IDC_CHECK_SPELLING_OF_THIS_FIELD, | 168 IDC_CHECK_SPELLING_OF_THIS_FIELD, |
| 169 l10n_util::GetString(IDS_CONTENT_CONTEXT_CHECK_SPELLING_OF_THIS_FIELD), | 169 l10n_util::GetString(IDS_CONTENT_CONTEXT_CHECK_SPELLING_OF_THIS_FIELD), |
| 170 CHECKBOX); | 170 CHECKBOX); |
| 171 | 171 |
| 172 AppendSeparator(); | 172 AppendSeparator(); |
| 173 AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_SELECTALL); | 173 AppendDelegateMenuItem(IDS_CONTENT_CONTEXT_SELECTALL); |
| 174 } | 174 } |
| OLD | NEW |