OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef IOS_WEB_VIEW_PUBLIC_CWV_TRANSLATION_CONTROLLER_H | 5 #ifndef IOS_WEB_VIEW_PUBLIC_CWV_TRANSLATION_CONTROLLER_H |
6 #define IOS_WEB_VIEW_PUBLIC_CWV_TRANSLATION_CONTROLLER_H | 6 #define IOS_WEB_VIEW_PUBLIC_CWV_TRANSLATION_CONTROLLER_H |
7 | 7 |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 | 9 |
10 #import "cwv_export.h" | 10 #import "cwv_export.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 @interface CWVTranslationController : NSObject | 45 @interface CWVTranslationController : NSObject |
46 | 46 |
47 // Delegate to receive translation callbacks. | 47 // Delegate to receive translation callbacks. |
48 @property(nullable, nonatomic, weak) id<CWVTranslationControllerDelegate> | 48 @property(nullable, nonatomic, weak) id<CWVTranslationControllerDelegate> |
49 delegate; | 49 delegate; |
50 | 50 |
51 // The set of supported languages for translation. | 51 // The set of supported languages for translation. |
52 @property(nonatomic, readonly) | 52 @property(nonatomic, readonly) |
53 NSSet<CWVTranslationLanguage*>* supportedLanguages; | 53 NSSet<CWVTranslationLanguage*>* supportedLanguages; |
54 | 54 |
| 55 // Resets all translation policies to default (CWVTranslationPolicyAsk). |
| 56 // Only resets non-incognito settings. |
| 57 + (void)resetTranslationPolicies; |
| 58 |
55 // Begins translation on the current page from |sourceLanguage| to | 59 // Begins translation on the current page from |sourceLanguage| to |
56 // |targetLanguage|. These language parameters must be chosen from | 60 // |targetLanguage|. These language parameters must be chosen from |
57 // |supportedLanguages|. Set |userInitiated| to YES if translation | 61 // |supportedLanguages|. Set |userInitiated| to YES if translation |
58 // is a result of explicit user action. |userInitiated| will be | 62 // is a result of explicit user action. |userInitiated| will be |
59 // passed along to the CWVTranslationControllerDelegate methods. | 63 // passed along to the CWVTranslationControllerDelegate methods. |
60 // Results in a No-op if there is no current page. | 64 // Results in a No-op if there is no current page. |
61 - (void)translatePageFromLanguage:(CWVTranslationLanguage*)sourceLanguage | 65 - (void)translatePageFromLanguage:(CWVTranslationLanguage*)sourceLanguage |
62 toLanguage:(CWVTranslationLanguage*)targetLanguage | 66 toLanguage:(CWVTranslationLanguage*)targetLanguage |
63 userInitiated:(BOOL)userInitiated; | 67 userInitiated:(BOOL)userInitiated; |
64 | 68 |
65 // Reverts any translations done back to the original page language. | 69 // Reverts any translations done back to the original page language. |
66 // Note that the original page language may be different from |sourceLanguage| | 70 // Note that the original page language may be different from |sourceLanguage| |
67 // passed to |translatePageFromLanguage:toLanguage:userInitiated:| above. | 71 // passed to |translatePageFromLanguage:toLanguage:userInitiated:| above. |
68 // Results in No-op if the page was never translated. | 72 // Results in No-op if the page was never translated. |
69 - (void)revertTranslation; | 73 - (void)revertTranslation; |
70 | 74 |
71 // Sets or retrieves translation policies associated with a specified language. | 75 // Sets or retrieves translation policies associated with a specified language. |
72 // |pageLanguage| should be the language code of the language. | 76 // |pageLanguage| should be the language code of the language. |
| 77 // Not supported in incognito mode. |
73 - (void)setTranslationPolicy:(CWVTranslationPolicy*)policy | 78 - (void)setTranslationPolicy:(CWVTranslationPolicy*)policy |
74 forPageLanguage:(CWVTranslationLanguage*)pageLanguage; | 79 forPageLanguage:(CWVTranslationLanguage*)pageLanguage; |
75 - (CWVTranslationPolicy*)translationPolicyForPageLanguage: | 80 - (CWVTranslationPolicy*)translationPolicyForPageLanguage: |
76 (CWVTranslationLanguage*)pageLanguage; | 81 (CWVTranslationLanguage*)pageLanguage; |
77 | 82 |
78 // Sets or retrieves translation policies associated with a specified page. | 83 // Sets or retrieves translation policies associated with a specified page. |
79 // |pageHost| should be the hostname of the website. Must not be empty. | 84 // |pageHost| should be the hostname of the website. Must not be empty. |
| 85 // Not supported in incognito mode. |
80 - (void)setTranslationPolicy:(CWVTranslationPolicy*)policy | 86 - (void)setTranslationPolicy:(CWVTranslationPolicy*)policy |
81 forPageHost:(NSString*)pageHost; | 87 forPageHost:(NSString*)pageHost; |
82 - (CWVTranslationPolicy*)translationPolicyForPageHost:(NSString*)pageHost; | 88 - (CWVTranslationPolicy*)translationPolicyForPageHost:(NSString*)pageHost; |
83 | 89 |
84 @end | 90 @end |
85 | 91 |
86 NS_ASSUME_NONNULL_END | 92 NS_ASSUME_NONNULL_END |
87 | 93 |
88 #endif // IOS_WEB_VIEW_PUBLIC_CWV_TRANSLATION_CONTROLLER_H | 94 #endif // IOS_WEB_VIEW_PUBLIC_CWV_TRANSLATION_CONTROLLER_H |
OLD | NEW |