diff options
author | jcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-30 20:13:48 +0000 |
---|---|---|
committer | jcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-30 20:13:48 +0000 |
commit | 579317eee3c39cdb8d2f6bc082912757a5706c55 (patch) | |
tree | 915a295e4d930e7f52afcbfbc8d48b8de8ad93f0 /chrome/browser/cocoa/translate/translate_infobar_base.mm | |
parent | a4aeaf46531bf14c25b93c0ded418c220bf222cb (diff) | |
download | chromium_src-579317eee3c39cdb8d2f6bc082912757a5706c55.zip chromium_src-579317eee3c39cdb8d2f6bc082912757a5706c55.tar.gz chromium_src-579317eee3c39cdb8d2f6bc082912757a5706c55.tar.bz2 |
Adds support for language detection on the server side.
Relanding: http://codereview.chromium.org/2860037 The CLD can sometimes fail to detect the language of a page, in which case the translate server might be able to. This CL ensures the browser deals with the server side language detection properly.
Also added a new factory method to create error translate infobar delegates that does not assert when the language code is incorrect.
Also changed the enums in TranslateInfoBarDelegate2 to use the constant name style, as it is the preferred naming for enums according to the style guide.
BUG=40857
TEST=Visit http://www.saanconf.org/saanday.htm, use the context menu
to translate the page. You should get an error mentioning the
page is already in English.
Review URL: http://codereview.chromium.org/2854032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51288 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/translate/translate_infobar_base.mm')
-rw-r--r-- | chrome/browser/cocoa/translate/translate_infobar_base.mm | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/chrome/browser/cocoa/translate/translate_infobar_base.mm b/chrome/browser/cocoa/translate/translate_infobar_base.mm index f93a733..7daf09a 100644 --- a/chrome/browser/cocoa/translate/translate_infobar_base.mm +++ b/chrome/browser/cocoa/translate/translate_infobar_base.mm @@ -114,16 +114,16 @@ InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { InfoBar* TranslateInfoBarDelegate2::CreateInfoBar() { TranslateInfoBarControllerBase* infobar_controller = NULL; switch (type_) { - case BEFORE_TRANSLATE: + case kBeforeTranslate: infobar_controller = [[BeforeTranslateInfobarController alloc] initWithDelegate:this]; break; - case AFTER_TRANSLATE: + case kAfterTranslate: infobar_controller = [[AfterTranslateInfobarController alloc] initWithDelegate:this]; break; - case TRANSLATING: - case TRANSLATION_ERROR: + case kTranslating: + case kTranslationError: infobar_controller = [[TranslateMessageInfobarController alloc] initWithDelegate:this]; break; @@ -456,8 +456,8 @@ InfoBar* TranslateInfoBarDelegate2::CreateInfoBar() { - (IBAction)ok:(id)sender { TranslateInfoBarDelegate2* delegate = [self delegate]; TranslateInfoBarDelegate2::Type state = delegate->type(); - DCHECK(state == TranslateInfoBarDelegate2::BEFORE_TRANSLATE || - state == TranslateInfoBarDelegate2::TRANSLATION_ERROR); + DCHECK(state == TranslateInfoBarDelegate2::kBeforeTranslate || + state == TranslateInfoBarDelegate2::kTranslationError); delegate->Translate(); UMA_HISTOGRAM_COUNTS("Translate.Translate", 1); } @@ -465,7 +465,7 @@ InfoBar* TranslateInfoBarDelegate2::CreateInfoBar() { // Called when someone clicks on the "Nope" button. - (IBAction)cancel:(id)sender { DCHECK( - [self delegate]->type() == TranslateInfoBarDelegate2::BEFORE_TRANSLATE); + [self delegate]->type() == TranslateInfoBarDelegate2::kBeforeTranslate); [self delegate]->TranslationDeclined(); UMA_HISTOGRAM_COUNTS("Translate.DeclineTranslate", 1); [super dismiss:nil]; |