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/translate/translate_manager.h" | 5 #include "chrome/browser/translate/translate_manager.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/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "content/public/browser/notification_source.h" | 43 #include "content/public/browser/notification_source.h" |
44 #include "content/public/browser/notification_types.h" | 44 #include "content/public/browser/notification_types.h" |
45 #include "content/public/browser/render_process_host.h" | 45 #include "content/public/browser/render_process_host.h" |
46 #include "content/public/browser/render_view_host.h" | 46 #include "content/public/browser/render_view_host.h" |
47 #include "content/public/browser/web_contents.h" | 47 #include "content/public/browser/web_contents.h" |
48 #include "content/public/common/url_fetcher.h" | 48 #include "content/public/common/url_fetcher.h" |
49 #include "grit/browser_resources.h" | 49 #include "grit/browser_resources.h" |
50 #include "net/base/escape.h" | 50 #include "net/base/escape.h" |
51 #include "net/base/load_flags.h" | 51 #include "net/base/load_flags.h" |
52 #include "net/url_request/url_request_status.h" | 52 #include "net/url_request/url_request_status.h" |
| 53 #include "ui/base/layout.h" |
53 #include "ui/base/resource/resource_bundle.h" | 54 #include "ui/base/resource/resource_bundle.h" |
54 | 55 |
55 #ifdef FILE_MANAGER_EXTENSION | 56 #ifdef FILE_MANAGER_EXTENSION |
56 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 57 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
57 #endif | 58 #endif |
58 | 59 |
59 using content::NavigationController; | 60 using content::NavigationController; |
60 using content::NavigationEntry; | 61 using content::NavigationEntry; |
61 using content::WebContents; | 62 using content::WebContents; |
62 | 63 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 } | 421 } |
421 | 422 |
422 bool error = | 423 bool error = |
423 (source->GetStatus().status() != net::URLRequestStatus::SUCCESS || | 424 (source->GetStatus().status() != net::URLRequestStatus::SUCCESS || |
424 source->GetResponseCode() != 200); | 425 source->GetResponseCode() != 200); |
425 if (translate_script_request_pending_.get() == source) { | 426 if (translate_script_request_pending_.get() == source) { |
426 scoped_ptr<const content::URLFetcher> delete_ptr( | 427 scoped_ptr<const content::URLFetcher> delete_ptr( |
427 translate_script_request_pending_.release()); | 428 translate_script_request_pending_.release()); |
428 if (!error) { | 429 if (!error) { |
429 base::StringPiece str = ResourceBundle::GetSharedInstance(). | 430 base::StringPiece str = ResourceBundle::GetSharedInstance(). |
430 GetRawDataResource(IDR_TRANSLATE_JS); | 431 GetRawDataResource(IDR_TRANSLATE_JS, |
| 432 ui::SCALE_FACTOR_NONE); |
431 DCHECK(translate_script_.empty()); | 433 DCHECK(translate_script_.empty()); |
432 str.CopyToString(&translate_script_); | 434 str.CopyToString(&translate_script_); |
433 std::string data; | 435 std::string data; |
434 source->GetResponseAsString(&data); | 436 source->GetResponseAsString(&data); |
435 translate_script_ += "\n" + data; | 437 translate_script_ += "\n" + data; |
436 // We'll expire the cached script after some time, to make sure long | 438 // We'll expire the cached script after some time, to make sure long |
437 // running browsers still get fixes that might get pushed with newer | 439 // running browsers still get fixes that might get pushed with newer |
438 // scripts. | 440 // scripts. |
439 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 441 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
440 base::Bind(&TranslateManager::ClearTranslateScript, | 442 base::Bind(&TranslateManager::ClearTranslateScript, |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); | 901 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); |
900 | 902 |
901 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { | 903 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { |
902 TranslateInfoBarDelegate* delegate = | 904 TranslateInfoBarDelegate* delegate = |
903 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); | 905 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); |
904 if (delegate) | 906 if (delegate) |
905 return delegate; | 907 return delegate; |
906 } | 908 } |
907 return NULL; | 909 return NULL; |
908 } | 910 } |
OLD | NEW |