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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <utility> |
| 10 |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
11 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
12 #include "chrome/browser/translate/chrome_translate_client.h" | 14 #include "chrome/browser/translate/chrome_translate_client.h" |
13 #import "chrome/browser/ui/cocoa/hover_close_button.h" | 15 #import "chrome/browser/ui/cocoa/hover_close_button.h" |
14 #include "chrome/browser/ui/cocoa/infobars/after_translate_infobar_controller.h" | 16 #include "chrome/browser/ui/cocoa/infobars/after_translate_infobar_controller.h" |
15 #import "chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.h" | 17 #import "chrome/browser/ui/cocoa/infobars/before_translate_infobar_controller.h" |
16 #include "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" | 18 #include "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" |
17 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 19 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
18 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" | 20 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" |
19 #import "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" | 21 #import "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" |
20 #import "chrome/browser/ui/cocoa/infobars/infobar_utilities.h" | 22 #import "chrome/browser/ui/cocoa/infobars/infobar_utilities.h" |
21 #include "chrome/browser/ui/cocoa/infobars/translate_message_infobar_controller.
h" | 23 #include "chrome/browser/ui/cocoa/infobars/translate_message_infobar_controller.
h" |
22 #include "components/translate/core/browser/translate_infobar_delegate.h" | 24 #include "components/translate/core/browser/translate_infobar_delegate.h" |
23 #include "grit/components_strings.h" | 25 #include "grit/components_strings.h" |
24 #include "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutT
weaker.h" | 26 #include "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutT
weaker.h" |
25 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
26 | 28 |
27 using InfoBarUtilities::MoveControl; | 29 using InfoBarUtilities::MoveControl; |
28 using InfoBarUtilities::VerticallyCenterView; | 30 using InfoBarUtilities::VerticallyCenterView; |
29 using InfoBarUtilities::VerifyControlOrderAndSpacing; | 31 using InfoBarUtilities::VerifyControlOrderAndSpacing; |
30 using InfoBarUtilities::CreateLabel; | 32 using InfoBarUtilities::CreateLabel; |
31 using InfoBarUtilities::AddMenuItem; | 33 using InfoBarUtilities::AddMenuItem; |
32 | 34 |
33 scoped_ptr<infobars::InfoBar> ChromeTranslateClient::CreateInfoBar( | 35 scoped_ptr<infobars::InfoBar> ChromeTranslateClient::CreateInfoBar( |
34 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) const { | 36 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) const { |
35 scoped_ptr<InfoBarCocoa> infobar(new InfoBarCocoa(delegate.Pass())); | 37 scoped_ptr<InfoBarCocoa> infobar(new InfoBarCocoa(std::move(delegate))); |
36 base::scoped_nsobject<TranslateInfoBarControllerBase> infobar_controller; | 38 base::scoped_nsobject<TranslateInfoBarControllerBase> infobar_controller; |
37 switch (infobar->delegate()->AsTranslateInfoBarDelegate()->translate_step()) { | 39 switch (infobar->delegate()->AsTranslateInfoBarDelegate()->translate_step()) { |
38 case translate::TRANSLATE_STEP_BEFORE_TRANSLATE: | 40 case translate::TRANSLATE_STEP_BEFORE_TRANSLATE: |
39 infobar_controller.reset([[BeforeTranslateInfobarController alloc] | 41 infobar_controller.reset([[BeforeTranslateInfobarController alloc] |
40 initWithInfoBar:infobar.get()]); | 42 initWithInfoBar:infobar.get()]); |
41 break; | 43 break; |
42 case translate::TRANSLATE_STEP_AFTER_TRANSLATE: | 44 case translate::TRANSLATE_STEP_AFTER_TRANSLATE: |
43 infobar_controller.reset([[AfterTranslateInfobarController alloc] | 45 infobar_controller.reset([[AfterTranslateInfobarController alloc] |
44 initWithInfoBar:infobar.get()]); | 46 initWithInfoBar:infobar.get()]); |
45 break; | 47 break; |
46 case translate::TRANSLATE_STEP_TRANSLATING: | 48 case translate::TRANSLATE_STEP_TRANSLATING: |
47 case translate::TRANSLATE_STEP_TRANSLATE_ERROR: | 49 case translate::TRANSLATE_STEP_TRANSLATE_ERROR: |
48 infobar_controller.reset([[TranslateMessageInfobarController alloc] | 50 infobar_controller.reset([[TranslateMessageInfobarController alloc] |
49 initWithInfoBar:infobar.get()]); | 51 initWithInfoBar:infobar.get()]); |
50 break; | 52 break; |
51 default: | 53 default: |
52 NOTREACHED(); | 54 NOTREACHED(); |
53 } | 55 } |
54 infobar->set_controller(infobar_controller); | 56 infobar->set_controller(infobar_controller); |
55 return infobar.Pass(); | 57 return std::move(infobar); |
56 } | 58 } |
57 | 59 |
58 @implementation TranslateInfoBarControllerBase (FrameChangeObserver) | 60 @implementation TranslateInfoBarControllerBase (FrameChangeObserver) |
59 | 61 |
60 // Triggered when the frame changes. This will figure out what size and | 62 // Triggered when the frame changes. This will figure out what size and |
61 // visibility the options popup should be. | 63 // visibility the options popup should be. |
62 - (void)didChangeFrame:(NSNotification*)notification { | 64 - (void)didChangeFrame:(NSNotification*)notification { |
63 [self adjustOptionsButtonSizeAndVisibilityForView: | 65 [self adjustOptionsButtonSizeAndVisibilityForView: |
64 [[self visibleControls] lastObject]]; | 66 [[self visibleControls] lastObject]]; |
65 } | 67 } |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 [[control description] UTF8String] <<[title UTF8String]; | 554 [[control description] UTF8String] <<[title UTF8String]; |
553 return false; | 555 return false; |
554 } | 556 } |
555 previousControl = control; | 557 previousControl = control; |
556 } | 558 } |
557 | 559 |
558 return true; | 560 return true; |
559 } | 561 } |
560 | 562 |
561 @end // TranslateInfoBarControllerBase (TestingAPI) | 563 @end // TranslateInfoBarControllerBase (TestingAPI) |
OLD | NEW |