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/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 21 matching lines...) Expand all Loading... |
32 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
33 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
34 #include "chrome/common/render_messages.h" | 34 #include "chrome/common/render_messages.h" |
35 #include "chrome/common/translate_errors.h" | 35 #include "chrome/common/translate_errors.h" |
36 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
37 #include "content/browser/renderer_host/render_process_host.h" | 37 #include "content/browser/renderer_host/render_process_host.h" |
38 #include "content/browser/renderer_host/render_view_host.h" | 38 #include "content/browser/renderer_host/render_view_host.h" |
39 #include "content/browser/tab_contents/navigation_details.h" | 39 #include "content/browser/tab_contents/navigation_details.h" |
40 #include "content/browser/tab_contents/navigation_entry.h" | 40 #include "content/browser/tab_contents/navigation_entry.h" |
41 #include "content/browser/tab_contents/tab_contents.h" | 41 #include "content/browser/tab_contents/tab_contents.h" |
42 #include "content/common/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
43 #include "content/public/browser/notification_details.h" | 43 #include "content/public/browser/notification_details.h" |
44 #include "content/public/browser/notification_source.h" | 44 #include "content/public/browser/notification_source.h" |
45 #include "content/public/browser/notification_types.h" | 45 #include "content/public/browser/notification_types.h" |
46 #include "grit/browser_resources.h" | 46 #include "grit/browser_resources.h" |
47 #include "net/base/escape.h" | 47 #include "net/base/escape.h" |
48 #include "net/url_request/url_request_status.h" | 48 #include "net/url_request/url_request_status.h" |
49 #include "ui/base/resource/resource_bundle.h" | 49 #include "ui/base/resource/resource_bundle.h" |
50 | 50 |
51 namespace { | 51 namespace { |
52 | 52 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 438 |
439 // static | 439 // static |
440 bool TranslateManager::IsShowingTranslateInfobar(TabContents* tab) { | 440 bool TranslateManager::IsShowingTranslateInfobar(TabContents* tab) { |
441 return GetTranslateInfoBarDelegate(tab) != NULL; | 441 return GetTranslateInfoBarDelegate(tab) != NULL; |
442 } | 442 } |
443 | 443 |
444 TranslateManager::TranslateManager() | 444 TranslateManager::TranslateManager() |
445 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_method_factory_(this)), | 445 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_method_factory_(this)), |
446 translate_script_expiration_delay_(kTranslateScriptExpirationDelayMS) { | 446 translate_script_expiration_delay_(kTranslateScriptExpirationDelayMS) { |
447 notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 447 notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
448 NotificationService::AllSources()); | 448 content::NotificationService::AllSources()); |
449 notification_registrar_.Add(this, | 449 notification_registrar_.Add(this, |
450 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 450 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
451 NotificationService::AllSources()); | 451 content::NotificationService::AllSources()); |
452 notification_registrar_.Add(this, chrome::NOTIFICATION_PAGE_TRANSLATED, | 452 notification_registrar_.Add(this, chrome::NOTIFICATION_PAGE_TRANSLATED, |
453 NotificationService::AllSources()); | 453 content::NotificationService::AllSources()); |
454 } | 454 } |
455 | 455 |
456 void TranslateManager::InitiateTranslation(TabContents* tab, | 456 void TranslateManager::InitiateTranslation(TabContents* tab, |
457 const std::string& page_lang) { | 457 const std::string& page_lang) { |
458 Profile* profile = Profile::FromBrowserContext(tab->browser_context()); | 458 Profile* profile = Profile::FromBrowserContext(tab->browser_context()); |
459 PrefService* prefs = profile->GetOriginalProfile()->GetPrefs(); | 459 PrefService* prefs = profile->GetOriginalProfile()->GetPrefs(); |
460 if (!prefs->GetBoolean(prefs::kEnableTranslate)) | 460 if (!prefs->GetBoolean(prefs::kEnableTranslate)) |
461 return; | 461 return; |
462 | 462 |
463 // Allow disabling of translate from the command line to assist with | 463 // Allow disabling of translate from the command line to assist with |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); | 834 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); |
835 | 835 |
836 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { | 836 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { |
837 TranslateInfoBarDelegate* delegate = | 837 TranslateInfoBarDelegate* delegate = |
838 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); | 838 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); |
839 if (delegate) | 839 if (delegate) |
840 return delegate; | 840 return delegate; |
841 } | 841 } |
842 return NULL; | 842 return NULL; |
843 } | 843 } |
OLD | NEW |