Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: chrome/browser/cocoa/translate/translate_infobar_base.mm

Issue 3034013: Fetch the translate script regularly (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Synced Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/cocoa/translate/translate_infobar_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 #import "chrome/browser/cocoa/translate/translate_infobar_base.h" 6 #import "chrome/browser/cocoa/translate/translate_infobar_base.h"
7 7
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "base/histogram.h" 9 #include "base/histogram.h"
10 #include "base/logging.h" // for NOTREACHED() 10 #include "base/logging.h" // for NOTREACHED()
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (!enabled) 95 if (!enabled)
96 [item setEnabled:NO]; 96 [item setEnabled:NO];
97 } 97 }
98 98
99 } // namespace TranslateInfoBarUtilities 99 } // namespace TranslateInfoBarUtilities
100 100
101 // TranslateInfoBarDelegate views specific method: 101 // TranslateInfoBarDelegate views specific method:
102 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { 102 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() {
103 TranslateInfoBarControllerBase* infobar_controller = NULL; 103 TranslateInfoBarControllerBase* infobar_controller = NULL;
104 switch (type_) { 104 switch (type_) {
105 case kBeforeTranslate: 105 case BEFORE_TRANSLATE:
106 infobar_controller = 106 infobar_controller =
107 [[BeforeTranslateInfobarController alloc] initWithDelegate:this]; 107 [[BeforeTranslateInfobarController alloc] initWithDelegate:this];
108 break; 108 break;
109 case kAfterTranslate: 109 case AFTER_TRANSLATE:
110 infobar_controller = 110 infobar_controller =
111 [[AfterTranslateInfobarController alloc] initWithDelegate:this]; 111 [[AfterTranslateInfobarController alloc] initWithDelegate:this];
112 break; 112 break;
113 case kTranslating: 113 case TRANSLATING:
114 case kTranslationError: 114 case TRANSLATION_ERROR:
115 infobar_controller = 115 infobar_controller =
116 [[TranslateMessageInfobarController alloc] initWithDelegate:this]; 116 [[TranslateMessageInfobarController alloc] initWithDelegate:this];
117 break; 117 break;
118 default: 118 default:
119 NOTREACHED(); 119 NOTREACHED();
120 } 120 }
121 return new InfoBar(infobar_controller); 121 return new InfoBar(infobar_controller);
122 } 122 }
123 123
124 @implementation TranslateInfoBarControllerBase (FrameChangeObserver) 124 @implementation TranslateInfoBarControllerBase (FrameChangeObserver)
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 object:infoBarView_]; 464 object:infoBarView_];
465 // Show and place GUI elements. 465 // Show and place GUI elements.
466 [self updateState]; 466 [self updateState];
467 } 467 }
468 468
469 - (void)adjustOptionsButtonSizeAndVisibilityForView:(NSView*)lastView { 469 - (void)adjustOptionsButtonSizeAndVisibilityForView:(NSView*)lastView {
470 [optionsPopUp_ setHidden:NO]; 470 [optionsPopUp_ setHidden:NO];
471 [self rebuildOptionsMenu:NO]; 471 [self rebuildOptionsMenu:NO];
472 [[optionsPopUp_ cell] setArrowPosition:NSPopUpArrowAtBottom]; 472 [[optionsPopUp_ cell] setArrowPosition:NSPopUpArrowAtBottom];
473 [optionsPopUp_ sizeToFit]; 473 [optionsPopUp_ sizeToFit];
474 474
475 MoveControl(closeButton_, optionsPopUp_, spaceBetweenControls_, false); 475 MoveControl(closeButton_, optionsPopUp_, spaceBetweenControls_, false);
476 if (!VerifyControlOrderAndSpacing(lastView, optionsPopUp_)) { 476 if (!VerifyControlOrderAndSpacing(lastView, optionsPopUp_)) {
477 [self rebuildOptionsMenu:YES]; 477 [self rebuildOptionsMenu:YES];
478 NSRect oldFrame = [optionsPopUp_ frame]; 478 NSRect oldFrame = [optionsPopUp_ frame];
479 oldFrame.size.width = NSHeight(oldFrame); 479 oldFrame.size.width = NSHeight(oldFrame);
480 [optionsPopUp_ setFrame:oldFrame]; 480 [optionsPopUp_ setFrame:oldFrame];
481 [[optionsPopUp_ cell] setArrowPosition:NSPopUpArrowAtCenter]; 481 [[optionsPopUp_ cell] setArrowPosition:NSPopUpArrowAtCenter];
482 MoveControl(closeButton_, optionsPopUp_, spaceBetweenControls_, false); 482 MoveControl(closeButton_, optionsPopUp_, spaceBetweenControls_, false);
483 if (!VerifyControlOrderAndSpacing(lastView, optionsPopUp_)) { 483 if (!VerifyControlOrderAndSpacing(lastView, optionsPopUp_)) {
484 [optionsPopUp_ setHidden:YES]; 484 [optionsPopUp_ setHidden:YES];
485 } 485 }
486 } 486 }
487 } 487 }
488 488
489 // Called when "Translate" button is clicked. 489 // Called when "Translate" button is clicked.
490 - (IBAction)ok:(id)sender { 490 - (IBAction)ok:(id)sender {
491 TranslateInfoBarDelegate* delegate = [self delegate]; 491 TranslateInfoBarDelegate* delegate = [self delegate];
492 TranslateInfoBarDelegate::Type state = delegate->type(); 492 TranslateInfoBarDelegate::Type state = delegate->type();
493 DCHECK(state == TranslateInfoBarDelegate::kBeforeTranslate || 493 DCHECK(state == TranslateInfoBarDelegate::BEFORE_TRANSLATE ||
494 state == TranslateInfoBarDelegate::kTranslationError); 494 state == TranslateInfoBarDelegate::TRANSLATION_ERROR);
495 delegate->Translate(); 495 delegate->Translate();
496 UMA_HISTOGRAM_COUNTS("Translate.Translate", 1); 496 UMA_HISTOGRAM_COUNTS("Translate.Translate", 1);
497 } 497 }
498 498
499 // Called when someone clicks on the "Nope" button. 499 // Called when someone clicks on the "Nope" button.
500 - (IBAction)cancel:(id)sender { 500 - (IBAction)cancel:(id)sender {
501 DCHECK( 501 DCHECK(
502 [self delegate]->type() == TranslateInfoBarDelegate::kBeforeTranslate); 502 [self delegate]->type() == TranslateInfoBarDelegate::BEFORE_TRANSLATE);
503 [self delegate]->TranslationDeclined(); 503 [self delegate]->TranslationDeclined();
504 UMA_HISTOGRAM_COUNTS("Translate.DeclineTranslate", 1); 504 UMA_HISTOGRAM_COUNTS("Translate.DeclineTranslate", 1);
505 [super dismiss:nil]; 505 [super dismiss:nil];
506 } 506 }
507 507
508 - (IBAction)showOriginal:(id)sender { 508 - (IBAction)showOriginal:(id)sender {
509 [self delegate]->RevertTranslation(); 509 [self delegate]->RevertTranslation();
510 } 510 }
511 511
512 // Called when any of the language drop down menus are changed. 512 // Called when any of the language drop down menus are changed.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 return false; 621 return false;
622 } 622 }
623 previousControl = control; 623 previousControl = control;
624 } 624 }
625 625
626 return true; 626 return true;
627 } 627 }
628 628
629 @end // TranslateInfoBarControllerBase (TestingAPI) 629 @end // TranslateInfoBarControllerBase (TestingAPI)
630 630
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/cocoa/translate/translate_infobar_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698