summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
authorjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-21 18:30:05 +0000
committerjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-21 18:30:05 +0000
commit59efee1132427f4610125f2933992b5952783b26 (patch)
tree0dc78d7c15a9dff63597422d5d230c935f394185 /chrome/browser/cocoa
parent6b77976f7ebe04fd91ccbaf5bfd77c5a9065c518 (diff)
downloadchromium_src-59efee1132427f4610125f2933992b5952783b26.zip
chromium_src-59efee1132427f4610125f2933992b5952783b26.tar.gz
chromium_src-59efee1132427f4610125f2933992b5952783b26.tar.bz2
Makes the browser fetch the translate script regularly.
New versions of that script may get pushed from time to time. Fetching the script again ensures people that don't restart their browser for long periods of time still get the new versions. Also renamed the enum from constant style to macro-style, as it is the Chromium way to go from the Chromium style guide (which is in that regard different than the Google style guide). BUG=None TEST=Run the unit-tests. Review URL: http://codereview.chromium.org/3034013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53220 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/translate/translate_infobar_base.mm16
-rw-r--r--chrome/browser/cocoa/translate/translate_infobar_unittest.mm18
-rw-r--r--chrome/browser/cocoa/translate/translate_message_infobar_controller.mm6
3 files changed, 20 insertions, 20 deletions
diff --git a/chrome/browser/cocoa/translate/translate_infobar_base.mm b/chrome/browser/cocoa/translate/translate_infobar_base.mm
index 108ce74..e267074 100644
--- a/chrome/browser/cocoa/translate/translate_infobar_base.mm
+++ b/chrome/browser/cocoa/translate/translate_infobar_base.mm
@@ -102,16 +102,16 @@ void AddMenuItem(NSMenu *menu, id target, SEL selector, NSString* title,
InfoBar* TranslateInfoBarDelegate::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;
@@ -471,7 +471,7 @@ InfoBar* TranslateInfoBarDelegate::CreateInfoBar() {
[self rebuildOptionsMenu:NO];
[[optionsPopUp_ cell] setArrowPosition:NSPopUpArrowAtBottom];
[optionsPopUp_ sizeToFit];
-
+
MoveControl(closeButton_, optionsPopUp_, spaceBetweenControls_, false);
if (!VerifyControlOrderAndSpacing(lastView, optionsPopUp_)) {
[self rebuildOptionsMenu:YES];
@@ -490,8 +490,8 @@ InfoBar* TranslateInfoBarDelegate::CreateInfoBar() {
- (IBAction)ok:(id)sender {
TranslateInfoBarDelegate* delegate = [self delegate];
TranslateInfoBarDelegate::Type state = delegate->type();
- DCHECK(state == TranslateInfoBarDelegate::kBeforeTranslate ||
- state == TranslateInfoBarDelegate::kTranslationError);
+ DCHECK(state == TranslateInfoBarDelegate::BEFORE_TRANSLATE ||
+ state == TranslateInfoBarDelegate::TRANSLATION_ERROR);
delegate->Translate();
UMA_HISTOGRAM_COUNTS("Translate.Translate", 1);
}
@@ -499,7 +499,7 @@ InfoBar* TranslateInfoBarDelegate::CreateInfoBar() {
// Called when someone clicks on the "Nope" button.
- (IBAction)cancel:(id)sender {
DCHECK(
- [self delegate]->type() == TranslateInfoBarDelegate::kBeforeTranslate);
+ [self delegate]->type() == TranslateInfoBarDelegate::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 8e3d257..668d8bf 100644
--- a/chrome/browser/cocoa/translate/translate_infobar_unittest.mm
+++ b/chrome/browser/cocoa/translate/translate_infobar_unittest.mm
@@ -23,10 +23,10 @@ namespace {
// All states the translate toolbar can assume.
TranslateInfoBarDelegate::Type kTranslateToolbarStates[] = {
- TranslateInfoBarDelegate::kBeforeTranslate,
- TranslateInfoBarDelegate::kAfterTranslate,
- TranslateInfoBarDelegate::kTranslating,
- TranslateInfoBarDelegate::kTranslationError
+ TranslateInfoBarDelegate::BEFORE_TRANSLATE,
+ TranslateInfoBarDelegate::AFTER_TRANSLATE,
+ TranslateInfoBarDelegate::TRANSLATING,
+ TranslateInfoBarDelegate::TRANSLATION_ERROR
};
class MockTranslateInfoBarDelegate : public TranslateInfoBarDelegate {
@@ -79,7 +79,7 @@ class TranslationInfoBarTest : public CocoaTest {
}
void CreateInfoBar() {
- CreateInfoBar(TranslateInfoBarDelegate::kBeforeTranslate);
+ CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE);
}
void CreateInfoBar(TranslateInfoBarDelegate::Type type) {
@@ -91,7 +91,7 @@ class TranslationInfoBarTest : public CocoaTest {
MSG_ROUTING_NONE,
NULL));
TranslateErrors::Type error = TranslateErrors::NONE;
- if (type == TranslateInfoBarDelegate::kTranslationError)
+ if (type == TranslateInfoBarDelegate::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(TranslateInfoBarDelegate::kTranslationError);
+ CreateInfoBar(TranslateInfoBarDelegate::TRANSLATION_ERROR);
EXPECT_CALL(*infobar_delegate, Translate()).Times(1);
@@ -227,7 +227,7 @@ TEST_F(TranslationInfoBarTest, TriggerShowAlwaysTranslateButton) {
for (int i = 0; i < 4; ++i) {
translate_prefs.IncrementTranslationAcceptedCount("en");
}
- CreateInfoBar(TranslateInfoBarDelegate::kBeforeTranslate);
+ CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE);
BeforeTranslateInfobarController* controller =
(BeforeTranslateInfobarController*)infobar_controller.get();
EXPECT_TRUE([[controller alwaysTranslateButton] superview] != nil);
@@ -242,7 +242,7 @@ TEST_F(TranslationInfoBarTest, TriggerShowNeverTranslateButton) {
for (int i = 0; i < 4; ++i) {
translate_prefs.IncrementTranslationDeniedCount("en");
}
- CreateInfoBar(TranslateInfoBarDelegate::kBeforeTranslate);
+ CreateInfoBar(TranslateInfoBarDelegate::BEFORE_TRANSLATE);
BeforeTranslateInfobarController* controller =
(BeforeTranslateInfobarController*)infobar_controller.get();
EXPECT_TRUE([[controller alwaysTranslateButton] superview] == nil);
diff --git a/chrome/browser/cocoa/translate/translate_message_infobar_controller.mm b/chrome/browser/cocoa/translate/translate_message_infobar_controller.mm
index db2f46f..5b4fcaf 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])) {
TranslateInfoBarDelegate* delegate = [self delegate];
if (delegate->IsError())
- state_ = TranslateInfoBarDelegate::kTranslationError;
+ state_ = TranslateInfoBarDelegate::TRANSLATION_ERROR;
else
- state_ = TranslateInfoBarDelegate::kTranslating;
+ state_ = TranslateInfoBarDelegate::TRANSLATING;
}
return self;
}
@@ -37,7 +37,7 @@ using TranslateInfoBarUtilities::MoveControl;
- (NSArray*)visibleControls {
NSMutableArray* visibleControls =
[NSMutableArray arrayWithObjects:label1_.get(), nil];
- if (state_ == TranslateInfoBarDelegate::kTranslationError)
+ if (state_ == TranslateInfoBarDelegate::TRANSLATION_ERROR)
[visibleControls addObject:tryAgainButton_];
return visibleControls;
}