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