summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
authorjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-30 16:59:03 +0000
committerjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-30 16:59:03 +0000
commit7838c2502799cbfe33ba16575b0e7d0b03740dd1 (patch)
tree17e926b6917b11264605ca01c7c9c1bfb3125d55 /chrome/browser/cocoa
parent5179b0eb8c7f0399157d747f8bce1838cdeb89d7 (diff)
downloadchromium_src-7838c2502799cbfe33ba16575b0e7d0b03740dd1.zip
chromium_src-7838c2502799cbfe33ba16575b0e7d0b03740dd1.tar.gz
chromium_src-7838c2502799cbfe33ba16575b0e7d0b03740dd1.tar.bz2
Revert 51263 (breaks the Linux views build)
Adds support for language detection on the server side. 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. Original review: http://codereview.chromium.org/2859013/show 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/2860037 TBR=jcivelli@chromium.org Review URL: http://codereview.chromium.org/2873035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51265 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/translate/translate_infobar_base.mm14
-rw-r--r--chrome/browser/cocoa/translate/translate_infobar_unittest.mm14
-rw-r--r--chrome/browser/cocoa/translate/translate_message_infobar_controller.mm6
3 files changed, 17 insertions, 17 deletions
diff --git a/chrome/browser/cocoa/translate/translate_infobar_base.mm b/chrome/browser/cocoa/translate/translate_infobar_base.mm
index 7daf09a..f93a733 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 kBeforeTranslate:
+ case BEFORE_TRANSLATE:
infobar_controller =
[[BeforeTranslateInfobarController alloc] initWithDelegate:this];
break;
- case kAfterTranslate:
+ case AFTER_TRANSLATE:
infobar_controller =
[[AfterTranslateInfobarController alloc] initWithDelegate:this];
break;
- case kTranslating:
- case kTranslationError:
+ case TRANSLATING:
+ case TRANSLATION_ERROR:
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::kBeforeTranslate ||
- state == TranslateInfoBarDelegate2::kTranslationError);
+ DCHECK(state == TranslateInfoBarDelegate2::BEFORE_TRANSLATE ||
+ state == TranslateInfoBarDelegate2::TRANSLATION_ERROR);
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::kBeforeTranslate);
+ [self delegate]->type() == TranslateInfoBarDelegate2::BEFORE_TRANSLATE);
[self delegate]->TranslationDeclined();
UMA_HISTOGRAM_COUNTS("Translate.DeclineTranslate", 1);
[super dismiss:nil];
diff --git a/chrome/browser/cocoa/translate/translate_infobar_unittest.mm b/chrome/browser/cocoa/translate/translate_infobar_unittest.mm
index dd3410e..38eb1ac 100644
--- a/chrome/browser/cocoa/translate/translate_infobar_unittest.mm
+++ b/chrome/browser/cocoa/translate/translate_infobar_unittest.mm
@@ -26,10 +26,10 @@ namespace {
// All states the translate toolbar can assume.
TranslateInfoBarDelegate2::Type kTranslateToolbarStates[] = {
- TranslateInfoBarDelegate2::kBeforeTranslate,
- TranslateInfoBarDelegate2::kAfterTranslate,
- TranslateInfoBarDelegate2::kTranslating,
- TranslateInfoBarDelegate2::kTranslationError
+ TranslateInfoBarDelegate2::BEFORE_TRANSLATE,
+ TranslateInfoBarDelegate2::AFTER_TRANSLATE,
+ TranslateInfoBarDelegate2::TRANSLATING,
+ TranslateInfoBarDelegate2::TRANSLATION_ERROR
};
class MockTranslateInfoBarDelegate : public TranslateInfoBarDelegate2 {
@@ -82,7 +82,7 @@ class TranslationInfoBarTest : public CocoaTest {
}
void CreateInfoBar() {
- CreateInfoBar(TranslateInfoBarDelegate2::kBeforeTranslate);
+ CreateInfoBar(TranslateInfoBarDelegate2::BEFORE_TRANSLATE);
}
void CreateInfoBar(TranslateInfoBarDelegate2::Type type) {
@@ -94,7 +94,7 @@ class TranslationInfoBarTest : public CocoaTest {
MSG_ROUTING_NONE,
NULL));
TranslateErrors::Type error = TranslateErrors::NONE;
- if (type == TranslateInfoBarDelegate2::kTranslationError)
+ if (type == TranslateInfoBarDelegate2::TRANSLATION_ERROR)
error = TranslateErrors::NETWORK;
infobar_delegate.reset(
new MockTranslateInfoBarDelegate(type, error, tab_contents.get()));
@@ -125,7 +125,7 @@ TEST_F(TranslationInfoBarTest, TranslateCalledOnButtonPress) {
// Check that clicking the "Retry" button calls Translate() when we're
// in the error mode - http://crbug.com/41315 .
TEST_F(TranslationInfoBarTest, TranslateCalledInErrorMode) {
- CreateInfoBar(TranslateInfoBarDelegate2::kTranslationError);
+ CreateInfoBar(TranslateInfoBarDelegate2::TRANSLATION_ERROR);
EXPECT_CALL(*infobar_delegate, Translate()).Times(1);
diff --git a/chrome/browser/cocoa/translate/translate_message_infobar_controller.mm b/chrome/browser/cocoa/translate/translate_message_infobar_controller.mm
index 3288cea..1087820 100644
--- a/chrome/browser/cocoa/translate/translate_message_infobar_controller.mm
+++ b/chrome/browser/cocoa/translate/translate_message_infobar_controller.mm
@@ -14,9 +14,9 @@ using TranslateInfoBarUtilities::MoveControl;
if ((self = [super initWithDelegate:delegate])) {
TranslateInfoBarDelegate2* delegate = [self delegate];
if (delegate->IsError())
- state_ = TranslateInfoBarDelegate2::kTranslationError;
+ state_ = TranslateInfoBarDelegate2::TRANSLATION_ERROR;
else
- state_ = TranslateInfoBarDelegate2::kTranslating;
+ state_ = TranslateInfoBarDelegate2::TRANSLATING;
}
return self;
}
@@ -33,7 +33,7 @@ using TranslateInfoBarUtilities::MoveControl;
- (NSArray*)visibleControls {
NSMutableArray* visibleControls =
[NSMutableArray arrayWithObjects:label1_.get(), nil];
- if (state_ == TranslateInfoBarDelegate2::kTranslationError)
+ if (state_ == TranslateInfoBarDelegate2::TRANSLATION_ERROR)
[visibleControls addObject:tryAgainButton_];
return visibleControls;
}