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

Side by Side Diff: ios/chrome/browser/translate/after_translate_infobar_controller.mm

Issue 2592113002: Remove legacy InfoBarViewProtocol. (Closed)
Patch Set: Rebase. Created 3 years, 11 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "ios/chrome/browser/translate/after_translate_infobar_controller.h" 5 #include "ios/chrome/browser/translate/after_translate_infobar_controller.h"
6 6
7 #include "base/mac/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/strings/grit/components_strings.h" 10 #include "components/strings/grit/components_strings.h"
11 #include "components/translate/core/browser/translate_infobar_delegate.h" 11 #include "components/translate/core/browser/translate_infobar_delegate.h"
12 #include "ios/chrome/browser/translate/translate_infobar_tags.h" 12 #include "ios/chrome/browser/translate/translate_infobar_tags.h"
13 #import "ios/chrome/browser/ui/infobars/infobar_view.h" 13 #import "ios/chrome/browser/ui/infobars/infobar_view.h"
14 #import "ios/chrome/browser/ui/infobars/infobar_view_delegate.h" 14 #import "ios/chrome/browser/ui/infobars/infobar_view_delegate.h"
15 #import "ios/chrome/browser/ui/infobars/infobar_view_protocol.h"
16 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
18 17
19 @interface AfterTranslateInfoBarController () { 18 @interface AfterTranslateInfoBarController () {
20 translate::TranslateInfoBarDelegate* _translateInfoBarDelegate; // weak 19 translate::TranslateInfoBarDelegate* _translateInfoBarDelegate; // weak
21 } 20 }
22 21
23 // Action for any of the user defined buttons. 22 // Action for any of the user defined buttons.
24 - (void)infoBarButtonDidPress:(id)sender; 23 - (void)infoBarButtonDidPress:(id)sender;
25 24
26 @end 25 @end
27 26
28 @implementation AfterTranslateInfoBarController 27 @implementation AfterTranslateInfoBarController
29 28
30 #pragma mark - 29 #pragma mark -
31 #pragma mark InfoBarControllerProtocol 30 #pragma mark InfoBarControllerProtocol
32 31
33 - (UIView<InfoBarViewProtocol>*)viewForDelegate: 32 - (InfoBarView*)viewForDelegate:(infobars::InfoBarDelegate*)delegate
34 (infobars::InfoBarDelegate*)delegate 33 frame:(CGRect)frame {
35 frame:(CGRect)frame { 34 base::scoped_nsobject<InfoBarView> infoBarView;
36 base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView;
37 _translateInfoBarDelegate = delegate->AsTranslateInfoBarDelegate(); 35 _translateInfoBarDelegate = delegate->AsTranslateInfoBarDelegate();
38 DCHECK(_translateInfoBarDelegate); 36 DCHECK(_translateInfoBarDelegate);
39 infoBarView.reset( 37 infoBarView.reset(
40 [[InfoBarView alloc] initWithFrame:frame delegate:self.delegate]); 38 [[InfoBarView alloc] initWithFrame:frame delegate:self.delegate]);
41 // Icon 39 // Icon
42 gfx::Image icon = _translateInfoBarDelegate->GetIcon(); 40 gfx::Image icon = _translateInfoBarDelegate->GetIcon();
43 if (!icon.IsEmpty()) 41 if (!icon.IsEmpty())
44 [infoBarView addLeftIcon:icon.ToUIImage()]; 42 [infoBarView addLeftIcon:icon.ToUIImage()];
45 // Main text. 43 // Main text.
46 const bool autodeterminedSourceLanguage = 44 const bool autodeterminedSourceLanguage =
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 113 }
116 114
117 - (void)infoBarSwitchDidPress:(id)sender { 115 - (void)infoBarSwitchDidPress:(id)sender {
118 DCHECK_EQ(TranslateInfoBarIOSTag::ALWAYS_TRANSLATE_SWITCH, [sender tag]); 116 DCHECK_EQ(TranslateInfoBarIOSTag::ALWAYS_TRANSLATE_SWITCH, [sender tag]);
119 DCHECK([sender respondsToSelector:@selector(isOn)]); 117 DCHECK([sender respondsToSelector:@selector(isOn)]);
120 if (_translateInfoBarDelegate->ShouldAlwaysTranslate() != [sender isOn]) 118 if (_translateInfoBarDelegate->ShouldAlwaysTranslate() != [sender isOn])
121 _translateInfoBarDelegate->ToggleAlwaysTranslate(); 119 _translateInfoBarDelegate->ToggleAlwaysTranslate();
122 } 120 }
123 121
124 @end 122 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698