OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderer_context_menu/spelling_menu_observer.h" | 5 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 14 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
15 #include "chrome/browser/renderer_context_menu/spelling_bubble_model.h" | 15 #include "chrome/browser/renderer_context_menu/spelling_bubble_model.h" |
16 #include "chrome/browser/spellchecker/feedback_sender.h" | 16 #include "chrome/browser/spellchecker/feedback_sender.h" |
17 #include "chrome/browser/spellchecker/spellcheck_factory.h" | 17 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
18 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 18 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
19 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" | 19 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" |
20 #include "chrome/browser/spellchecker/spellcheck_service.h" | 20 #include "chrome/browser/spellchecker/spellcheck_service.h" |
21 #include "chrome/browser/spellchecker/spelling_service_client.h" | 21 #include "chrome/browser/spellchecker/spelling_service_client.h" |
22 #include "chrome/browser/ui/confirm_bubble.h" | 22 #include "chrome/browser/ui/confirm_bubble.h" |
23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
25 #include "chrome/common/spellcheck_common.h" | |
25 #include "chrome/common/spellcheck_result.h" | 26 #include "chrome/common/spellcheck_result.h" |
26 #include "chrome/grit/generated_resources.h" | 27 #include "chrome/grit/generated_resources.h" |
27 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
28 #include "content/public/browser/render_widget_host_view.h" | 29 #include "content/public/browser/render_widget_host_view.h" |
29 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
30 #include "content/public/common/context_menu_params.h" | 31 #include "content/public/common/context_menu_params.h" |
31 #include "extensions/browser/view_type_utils.h" | 32 #include "extensions/browser/view_type_utils.h" |
32 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
33 #include "ui/gfx/geometry/rect.h" | 34 #include "ui/gfx/geometry/rect.h" |
34 | 35 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 default: | 199 default: |
199 return false; | 200 return false; |
200 } | 201 } |
201 } | 202 } |
202 | 203 |
203 bool SpellingMenuObserver::IsCommandIdChecked(int command_id) { | 204 bool SpellingMenuObserver::IsCommandIdChecked(int command_id) { |
204 DCHECK(IsCommandIdSupported(command_id)); | 205 DCHECK(IsCommandIdSupported(command_id)); |
205 Profile* profile = Profile::FromBrowserContext(proxy_->GetBrowserContext()); | 206 Profile* profile = Profile::FromBrowserContext(proxy_->GetBrowserContext()); |
206 | 207 |
207 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_TOGGLE) | 208 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_TOGGLE) |
208 return integrate_spelling_service_.GetValue() && !profile->IsOffTheRecord(); | 209 return integrate_spelling_service_.GetValue() && !profile->IsOffTheRecord(); |
please use gerrit instead
2015/06/21 23:43:44
&& !chrome::spellcheck_common::IsMultilingualSpell
Julius
2015/06/24 21:17:58
Done.
| |
209 if (command_id == IDC_CONTENT_CONTEXT_AUTOCORRECT_SPELLING_TOGGLE) | 210 if (command_id == IDC_CONTENT_CONTEXT_AUTOCORRECT_SPELLING_TOGGLE) |
210 return autocorrect_spelling_.GetValue() && !profile->IsOffTheRecord(); | 211 return autocorrect_spelling_.GetValue() && !profile->IsOffTheRecord(); |
211 return false; | 212 return false; |
212 } | 213 } |
213 | 214 |
214 bool SpellingMenuObserver::IsCommandIdEnabled(int command_id) { | 215 bool SpellingMenuObserver::IsCommandIdEnabled(int command_id) { |
215 DCHECK(IsCommandIdSupported(command_id)); | 216 DCHECK(IsCommandIdSupported(command_id)); |
216 | 217 |
217 if (command_id >= IDC_SPELLCHECK_SUGGESTION_0 && | 218 if (command_id >= IDC_SPELLCHECK_SUGGESTION_0 && |
218 command_id <= IDC_SPELLCHECK_SUGGESTION_LAST) | 219 command_id <= IDC_SPELLCHECK_SUGGESTION_LAST) |
219 return true; | 220 return true; |
220 | 221 |
221 Profile* profile = Profile::FromBrowserContext(proxy_->GetBrowserContext()); | 222 Profile* profile = Profile::FromBrowserContext(proxy_->GetBrowserContext()); |
222 switch (command_id) { | 223 switch (command_id) { |
223 case IDC_SPELLCHECK_ADD_TO_DICTIONARY: | 224 case IDC_SPELLCHECK_ADD_TO_DICTIONARY: |
224 return !misspelled_word_.empty(); | 225 return !misspelled_word_.empty(); |
225 | 226 |
226 case IDC_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS: | 227 case IDC_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS: |
227 return false; | 228 return false; |
228 | 229 |
229 case IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION: | 230 case IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION: |
230 return succeeded_; | 231 return succeeded_; |
231 | 232 |
232 case IDC_CONTENT_CONTEXT_SPELLING_TOGGLE: | 233 case IDC_CONTENT_CONTEXT_SPELLING_TOGGLE: |
233 return integrate_spelling_service_.IsUserModifiable() && | 234 return integrate_spelling_service_.IsUserModifiable() && |
234 !profile->IsOffTheRecord(); | 235 !profile->IsOffTheRecord() && |
236 !chrome::spellcheck_common::IsMultilingualSpellcheckEnabled(); | |
235 | 237 |
236 case IDC_CONTENT_CONTEXT_AUTOCORRECT_SPELLING_TOGGLE: | 238 case IDC_CONTENT_CONTEXT_AUTOCORRECT_SPELLING_TOGGLE: |
237 return integrate_spelling_service_.IsUserModifiable() && | 239 return integrate_spelling_service_.IsUserModifiable() && |
238 !profile->IsOffTheRecord(); | 240 !profile->IsOffTheRecord(); |
239 | 241 |
240 default: | 242 default: |
241 return false; | 243 return false; |
242 } | 244 } |
243 } | 245 } |
244 | 246 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 // Append '.' characters to the end of "Checking". | 407 // Append '.' characters to the end of "Checking". |
406 loading_frame_ = (loading_frame_ + 1) & 3; | 408 loading_frame_ = (loading_frame_ + 1) & 3; |
407 base::string16 loading_message = | 409 base::string16 loading_message = |
408 loading_message_ + base::string16(loading_frame_,'.'); | 410 loading_message_ + base::string16(loading_frame_,'.'); |
409 | 411 |
410 // Update the menu item with the text. We disable this item to prevent users | 412 // Update the menu item with the text. We disable this item to prevent users |
411 // from selecting it. | 413 // from selecting it. |
412 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, | 414 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, |
413 loading_message); | 415 loading_message); |
414 } | 416 } |
OLD | NEW |