| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/string_escape.h" | 10 #include "base/json/string_escape.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1), | 147 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1), |
| 148 this, &SpellingMenuObserver::OnAnimationTimerExpired); | 148 this, &SpellingMenuObserver::OnAnimationTimerExpired); |
| 149 | 149 |
| 150 return true; | 150 return true; |
| 151 } | 151 } |
| 152 | 152 |
| 153 void SpellingMenuObserver::OnURLFetchComplete( | 153 void SpellingMenuObserver::OnURLFetchComplete( |
| 154 const content::URLFetcher* source) { | 154 const content::URLFetcher* source) { |
| 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 156 | 156 |
| 157 fetcher_.reset(); | 157 scoped_ptr<content::URLFetcher> clean_up_fetcher(fetcher_.release()); |
| 158 animation_timer_.Stop(); | 158 animation_timer_.Stop(); |
| 159 | 159 |
| 160 // Parse the response JSON and replace misspelled words in the |result_| text | 160 // Parse the response JSON and replace misspelled words in the |result_| text |
| 161 // with their suggestions. | 161 // with their suggestions. |
| 162 std::string data; | 162 std::string data; |
| 163 source->GetResponseAsString(&data); | 163 source->GetResponseAsString(&data); |
| 164 succeeded_ = ParseResponse(source->GetResponseCode(), data); | 164 succeeded_ = ParseResponse(source->GetResponseCode(), data); |
| 165 if (!succeeded_) | 165 if (!succeeded_) |
| 166 result_ = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_SPELLING_CORRECT); | 166 result_ = l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_SPELLING_CORRECT); |
| 167 | 167 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 loading_frame_ = (loading_frame_ + 1) & 3; | 265 loading_frame_ = (loading_frame_ + 1) & 3; |
| 266 string16 loading_message = loading_message_; | 266 string16 loading_message = loading_message_; |
| 267 for (int i = 0; i < loading_frame_; ++i) | 267 for (int i = 0; i < loading_frame_; ++i) |
| 268 loading_message.push_back('.'); | 268 loading_message.push_back('.'); |
| 269 | 269 |
| 270 // Update the menu item with the text. We disable this item to prevent users | 270 // Update the menu item with the text. We disable this item to prevent users |
| 271 // from selecting it. | 271 // from selecting it. |
| 272 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, | 272 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, |
| 273 loading_message); | 273 loading_message); |
| 274 } | 274 } |
| OLD | NEW |