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

Side by Side Diff: ios/web_view/shell/translate_controller.mm

Issue 2653083002: Cleanup ios/web_view. (Closed)
Patch Set: Respond to more comments. Created 3 years, 10 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 | « ios/web_view/shell/translate_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "ios/web_view/shell/translate_controller.h"
6
7 #import <UIKit/UIKit.h>
8
9 #include "base/logging.h"
10 #import "base/mac/scoped_nsobject.h"
11 #import "ios/web_view/public/criwv_translate_manager.h"
12
13 @interface TranslateController () {
14 base::scoped_nsobject<UIAlertController> _beforeTranslateActionSheet;
15 base::scoped_nsprotocol<id<CRIWVTranslateManager>> _translateManager;
16 }
17 @end
18
19 @implementation TranslateController
20
21 - (void)dealloc {
22 [_beforeTranslateActionSheet dismissViewControllerAnimated:YES
23 completion:nil];
24 [super dealloc];
25 }
26
27 #pragma mark CRIWVTranslateDelegate methods
28
29 - (void)translateStepChanged:(ios_web_view::CRIWVTransateStep)step
30 manager:(id<CRIWVTranslateManager>)manager {
31 if (step == ios_web_view::CRIWVTransateStepBeforeTranslate) {
32 DCHECK(!_translateManager);
33 DCHECK(!_beforeTranslateActionSheet);
34 _translateManager.reset([manager retain]);
35 _beforeTranslateActionSheet.reset([[UIAlertController
36 alertControllerWithTitle:nil
37 message:@"Translate?"
38 preferredStyle:UIAlertControllerStyleActionSheet] retain]);
39 UIAlertAction* cancelAction =
40 [UIAlertAction actionWithTitle:@"Nope."
41 style:UIAlertActionStyleCancel
42 handler:^(UIAlertAction* action) {
43 DCHECK(_beforeTranslateActionSheet);
44 _beforeTranslateActionSheet.reset();
45 DCHECK(_translateManager);
46 _translateManager.reset();
47 }];
48 [_beforeTranslateActionSheet addAction:cancelAction];
49
50 UIAlertAction* translateAction =
51 [UIAlertAction actionWithTitle:@"Yes!"
52 style:UIAlertActionStyleDefault
53 handler:^(UIAlertAction* action) {
54 DCHECK(_beforeTranslateActionSheet);
55 _beforeTranslateActionSheet.reset();
56 DCHECK(_translateManager);
57 [_translateManager translate];
58 _translateManager.reset();
59 }];
60 [_beforeTranslateActionSheet addAction:translateAction];
61
62 [[UIApplication sharedApplication].keyWindow.rootViewController
63 presentViewController:_beforeTranslateActionSheet
64 animated:YES
65 completion:nil];
66 }
67 }
68
69 @end
OLDNEW
« no previous file with comments | « ios/web_view/shell/translate_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698