| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/cocoa/infobars/translate_infobar_base.h" | 5 #import "chrome/browser/ui/cocoa/infobars/translate_infobar_base.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/translate/chrome_translate_client.h" | 10 #include "chrome/browser/translate/chrome_translate_client.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 24 | 24 |
| 25 using InfoBarUtilities::MoveControl; | 25 using InfoBarUtilities::MoveControl; |
| 26 using InfoBarUtilities::VerticallyCenterView; | 26 using InfoBarUtilities::VerticallyCenterView; |
| 27 using InfoBarUtilities::VerifyControlOrderAndSpacing; | 27 using InfoBarUtilities::VerifyControlOrderAndSpacing; |
| 28 using InfoBarUtilities::CreateLabel; | 28 using InfoBarUtilities::CreateLabel; |
| 29 using InfoBarUtilities::AddMenuItem; | 29 using InfoBarUtilities::AddMenuItem; |
| 30 | 30 |
| 31 scoped_ptr<infobars::InfoBar> ChromeTranslateClient::CreateInfoBar( | 31 scoped_ptr<infobars::InfoBar> ChromeTranslateClient::CreateInfoBar( |
| 32 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) const { | 32 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) const { |
| 33 scoped_ptr<InfoBarCocoa> infobar( | 33 scoped_ptr<InfoBarCocoa> infobar(new InfoBarCocoa(delegate.Pass())); |
| 34 new InfoBarCocoa(delegate.PassAs<infobars::InfoBarDelegate>())); | |
| 35 base::scoped_nsobject<TranslateInfoBarControllerBase> infobar_controller; | 34 base::scoped_nsobject<TranslateInfoBarControllerBase> infobar_controller; |
| 36 switch (infobar->delegate()->AsTranslateInfoBarDelegate()->translate_step()) { | 35 switch (infobar->delegate()->AsTranslateInfoBarDelegate()->translate_step()) { |
| 37 case translate::TRANSLATE_STEP_BEFORE_TRANSLATE: | 36 case translate::TRANSLATE_STEP_BEFORE_TRANSLATE: |
| 38 infobar_controller.reset([[BeforeTranslateInfobarController alloc] | 37 infobar_controller.reset([[BeforeTranslateInfobarController alloc] |
| 39 initWithInfoBar:infobar.get()]); | 38 initWithInfoBar:infobar.get()]); |
| 40 break; | 39 break; |
| 41 case translate::TRANSLATE_STEP_AFTER_TRANSLATE: | 40 case translate::TRANSLATE_STEP_AFTER_TRANSLATE: |
| 42 infobar_controller.reset([[AfterTranslateInfobarController alloc] | 41 infobar_controller.reset([[AfterTranslateInfobarController alloc] |
| 43 initWithInfoBar:infobar.get()]); | 42 initWithInfoBar:infobar.get()]); |
| 44 break; | 43 break; |
| 45 case translate::TRANSLATE_STEP_TRANSLATING: | 44 case translate::TRANSLATE_STEP_TRANSLATING: |
| 46 case translate::TRANSLATE_STEP_TRANSLATE_ERROR: | 45 case translate::TRANSLATE_STEP_TRANSLATE_ERROR: |
| 47 infobar_controller.reset([[TranslateMessageInfobarController alloc] | 46 infobar_controller.reset([[TranslateMessageInfobarController alloc] |
| 48 initWithInfoBar:infobar.get()]); | 47 initWithInfoBar:infobar.get()]); |
| 49 break; | 48 break; |
| 50 default: | 49 default: |
| 51 NOTREACHED(); | 50 NOTREACHED(); |
| 52 } | 51 } |
| 53 infobar->set_controller(infobar_controller); | 52 infobar->set_controller(infobar_controller); |
| 54 return infobar.PassAs<infobars::InfoBar>(); | 53 return infobar.Pass(); |
| 55 } | 54 } |
| 56 | 55 |
| 57 @implementation TranslateInfoBarControllerBase (FrameChangeObserver) | 56 @implementation TranslateInfoBarControllerBase (FrameChangeObserver) |
| 58 | 57 |
| 59 // Triggered when the frame changes. This will figure out what size and | 58 // Triggered when the frame changes. This will figure out what size and |
| 60 // visibility the options popup should be. | 59 // visibility the options popup should be. |
| 61 - (void)didChangeFrame:(NSNotification*)notification { | 60 - (void)didChangeFrame:(NSNotification*)notification { |
| 62 [self adjustOptionsButtonSizeAndVisibilityForView: | 61 [self adjustOptionsButtonSizeAndVisibilityForView: |
| 63 [[self visibleControls] lastObject]]; | 62 [[self visibleControls] lastObject]]; |
| 64 } | 63 } |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 [[control description] UTF8String] <<[title UTF8String]; | 546 [[control description] UTF8String] <<[title UTF8String]; |
| 548 return false; | 547 return false; |
| 549 } | 548 } |
| 550 previousControl = control; | 549 previousControl = control; |
| 551 } | 550 } |
| 552 | 551 |
| 553 return true; | 552 return true; |
| 554 } | 553 } |
| 555 | 554 |
| 556 @end // TranslateInfoBarControllerBase (TestingAPI) | 555 @end // TranslateInfoBarControllerBase (TestingAPI) |
| OLD | NEW |