| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/spelling_menu_observer.h" | 5 #include "chrome/browser/tab_contents/spelling_menu_observer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // suggested words. If the replaced text is included in the suggestion list | 247 // suggested words. If the replaced text is included in the suggestion list |
| 248 // provided by the local spellchecker, we show a "No suggestions from Google" | 248 // provided by the local spellchecker, we show a "No suggestions from Google" |
| 249 // message. | 249 // message. |
| 250 succeeded_ = true; | 250 succeeded_ = true; |
| 251 if (results.empty()) { | 251 if (results.empty()) { |
| 252 succeeded_ = false; | 252 succeeded_ = false; |
| 253 } else { | 253 } else { |
| 254 typedef std::vector<WebKit::WebTextCheckingResult> WebTextCheckingResults; | 254 typedef std::vector<WebKit::WebTextCheckingResult> WebTextCheckingResults; |
| 255 for (WebTextCheckingResults::const_iterator it = results.begin(); | 255 for (WebTextCheckingResults::const_iterator it = results.begin(); |
| 256 it != results.end(); ++it) { | 256 it != results.end(); ++it) { |
| 257 result_.replace(it->position, it->length, it->replacement); | 257 result_.replace(it->location, it->length, it->replacement); |
| 258 } | 258 } |
| 259 for (std::vector<string16>::const_iterator it = suggestions_.begin(); | 259 for (std::vector<string16>::const_iterator it = suggestions_.begin(); |
| 260 it != suggestions_.end(); ++it) { | 260 it != suggestions_.end(); ++it) { |
| 261 if (result_ == *it) { | 261 if (result_ == *it) { |
| 262 succeeded_ = false; | 262 succeeded_ = false; |
| 263 break; | 263 break; |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 } | 266 } |
| 267 if (!succeeded_) { | 267 if (!succeeded_) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 280 loading_frame_ = (loading_frame_ + 1) & 3; | 280 loading_frame_ = (loading_frame_ + 1) & 3; |
| 281 string16 loading_message = loading_message_; | 281 string16 loading_message = loading_message_; |
| 282 for (int i = 0; i < loading_frame_; ++i) | 282 for (int i = 0; i < loading_frame_; ++i) |
| 283 loading_message.push_back('.'); | 283 loading_message.push_back('.'); |
| 284 | 284 |
| 285 // Update the menu item with the text. We disable this item to prevent users | 285 // Update the menu item with the text. We disable this item to prevent users |
| 286 // from selecting it. | 286 // from selecting it. |
| 287 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, | 287 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, |
| 288 loading_message); | 288 loading_message); |
| 289 } | 289 } |
| OLD | NEW |