OLD | NEW |
1 // Copyright (c) 2010 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/translate/translate_manager.h" | 5 #include "chrome/browser/translate/translate_manager.h" |
6 | 6 |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/singleton.h" | 11 #include "base/singleton.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 InitAcceptLanguages(prefs); | 273 InitAcceptLanguages(prefs); |
274 break; | 274 break; |
275 } | 275 } |
276 default: | 276 default: |
277 NOTREACHED(); | 277 NOTREACHED(); |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 void TranslateManager::OnURLFetchComplete(const URLFetcher* source, | 281 void TranslateManager::OnURLFetchComplete(const URLFetcher* source, |
282 const GURL& url, | 282 const GURL& url, |
283 const URLRequestStatus& status, | 283 const net::URLRequestStatus& status, |
284 int response_code, | 284 int response_code, |
285 const ResponseCookies& cookies, | 285 const ResponseCookies& cookies, |
286 const std::string& data) { | 286 const std::string& data) { |
287 scoped_ptr<const URLFetcher> delete_ptr(source); | 287 scoped_ptr<const URLFetcher> delete_ptr(source); |
288 DCHECK(translate_script_request_pending_); | 288 DCHECK(translate_script_request_pending_); |
289 translate_script_request_pending_ = false; | 289 translate_script_request_pending_ = false; |
290 bool error = | 290 bool error = |
291 (status.status() != URLRequestStatus::SUCCESS || response_code != 200); | 291 (status.status() != net::URLRequestStatus::SUCCESS || |
| 292 response_code != 200); |
292 | 293 |
293 if (!error) { | 294 if (!error) { |
294 base::StringPiece str = ResourceBundle::GetSharedInstance(). | 295 base::StringPiece str = ResourceBundle::GetSharedInstance(). |
295 GetRawDataResource(IDR_TRANSLATE_JS); | 296 GetRawDataResource(IDR_TRANSLATE_JS); |
296 DCHECK(translate_script_.empty()); | 297 DCHECK(translate_script_.empty()); |
297 str.CopyToString(&translate_script_); | 298 str.CopyToString(&translate_script_); |
298 translate_script_ += "\n" + data; | 299 translate_script_ += "\n" + data; |
299 // We'll expire the cached script after some time, to make sure long running | 300 // We'll expire the cached script after some time, to make sure long running |
300 // browsers still get fixes that might get pushed with newer scripts. | 301 // browsers still get fixes that might get pushed with newer scripts. |
301 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 302 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 TranslateInfoBarDelegate* TranslateManager::GetTranslateInfoBarDelegate( | 632 TranslateInfoBarDelegate* TranslateManager::GetTranslateInfoBarDelegate( |
632 TabContents* tab) { | 633 TabContents* tab) { |
633 for (int i = 0; i < tab->infobar_delegate_count(); ++i) { | 634 for (int i = 0; i < tab->infobar_delegate_count(); ++i) { |
634 TranslateInfoBarDelegate* delegate = | 635 TranslateInfoBarDelegate* delegate = |
635 tab->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); | 636 tab->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); |
636 if (delegate) | 637 if (delegate) |
637 return delegate; | 638 return delegate; |
638 } | 639 } |
639 return NULL; | 640 return NULL; |
640 } | 641 } |
OLD | NEW |