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

Side by Side Diff: components/translate/ios/browser/translate_controller.h

Issue 2645603002: [ObjC ARC] Converts components/translate/ios/browser:browser to ARC. (Closed)
Patch Set: move include 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 2014 The Chromium Authors. All rights reserved. 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 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 COMPONENTS_TRANSLATE_IOS_BROWSER_TRANSLATE_CONTROLLER_H_ 5 #ifndef COMPONENTS_TRANSLATE_IOS_BROWSER_TRANSLATE_CONTROLLER_H_
6 #define COMPONENTS_TRANSLATE_IOS_BROWSER_TRANSLATE_CONTROLLER_H_ 6 #define COMPONENTS_TRANSLATE_IOS_BROWSER_TRANSLATE_CONTROLLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/mac/scoped_nsobject.h"
12 #include "base/macros.h" 11 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #import "components/translate/ios/browser/js_translate_manager.h"
noyau (Ping after 24h) 2017/01/19 14:35:26 I believe this include is not needed, the @class s
stkhapugin 2017/01/19 14:47:59 Done.
14 #include "ios/web/public/web_state/web_state_observer.h" 14 #include "ios/web/public/web_state/web_state_observer.h"
15 15
16 @class JsTranslateManager;
17 class GURL; 16 class GURL;
18 17
19 namespace base { 18 namespace base {
20 class DictionaryValue; 19 class DictionaryValue;
21 } 20 }
22 21
23 namespace web { 22 namespace web {
24 class WebState; 23 class WebState;
25 } 24 }
26 25
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 void StartTranslation(const std::string& source_language, 61 void StartTranslation(const std::string& source_language,
63 const std::string& target_language); 62 const std::string& target_language);
64 63
65 // Checks the translation status and calls the observer when it is done. 64 // Checks the translation status and calls the observer when it is done.
66 // This method must be called after StartTranslation(). 65 // This method must be called after StartTranslation().
67 void CheckTranslateStatus(); 66 void CheckTranslateStatus();
68 67
69 // Changes the JsTranslateManager used by this TranslateController. 68 // Changes the JsTranslateManager used by this TranslateController.
70 // Only used for testing. 69 // Only used for testing.
71 void SetJsTranslateManagerForTesting(JsTranslateManager* manager) { 70 void SetJsTranslateManagerForTesting(JsTranslateManager* manager) {
72 js_manager_.reset([manager retain]); 71 js_manager_ = manager;
73 } 72 }
74 73
75 private: 74 private:
76 FRIEND_TEST_ALL_PREFIXES(TranslateControllerTest, 75 FRIEND_TEST_ALL_PREFIXES(TranslateControllerTest,
77 OnJavascriptCommandReceived); 76 OnJavascriptCommandReceived);
78 FRIEND_TEST_ALL_PREFIXES(TranslateControllerTest, 77 FRIEND_TEST_ALL_PREFIXES(TranslateControllerTest,
79 OnTranslateScriptReadyTimeoutCalled); 78 OnTranslateScriptReadyTimeoutCalled);
80 FRIEND_TEST_ALL_PREFIXES(TranslateControllerTest, 79 FRIEND_TEST_ALL_PREFIXES(TranslateControllerTest,
81 OnTranslateScriptReadyCalled); 80 OnTranslateScriptReadyCalled);
82 FRIEND_TEST_ALL_PREFIXES(TranslateControllerTest, TranslationSuccess); 81 FRIEND_TEST_ALL_PREFIXES(TranslateControllerTest, TranslationSuccess);
83 FRIEND_TEST_ALL_PREFIXES(TranslateControllerTest, TranslationFailure); 82 FRIEND_TEST_ALL_PREFIXES(TranslateControllerTest, TranslationFailure);
84 83
85 // Called when a JavaScript command is received. 84 // Called when a JavaScript command is received.
86 bool OnJavascriptCommandReceived(const base::DictionaryValue& command, 85 bool OnJavascriptCommandReceived(const base::DictionaryValue& command,
87 const GURL& url, 86 const GURL& url,
88 bool interacting); 87 bool interacting);
89 // Methods to handle specific JavaScript commands. 88 // Methods to handle specific JavaScript commands.
90 // Return false if the command is invalid. 89 // Return false if the command is invalid.
91 bool OnTranslateReady(const base::DictionaryValue& command); 90 bool OnTranslateReady(const base::DictionaryValue& command);
92 bool OnTranslateComplete(const base::DictionaryValue& command); 91 bool OnTranslateComplete(const base::DictionaryValue& command);
93 92
94 // web::WebStateObserver implementation: 93 // web::WebStateObserver implementation:
95 void WebStateDestroyed() override; 94 void WebStateDestroyed() override;
96 95
97 Observer* observer_; 96 Observer* observer_;
98 base::scoped_nsobject<JsTranslateManager> js_manager_; 97 JsTranslateManager* js_manager_;
99 base::WeakPtrFactory<TranslateController> weak_method_factory_; 98 base::WeakPtrFactory<TranslateController> weak_method_factory_;
100 99
101 DISALLOW_COPY_AND_ASSIGN(TranslateController); 100 DISALLOW_COPY_AND_ASSIGN(TranslateController);
102 }; 101 };
103 102
104 } // namespace translate 103 } // namespace translate
105 104
106 #endif // COMPONENTS_TRANSLATE_IOS_BROWSER_TRANSLATE_CONTROLLER_H_ 105 #endif // COMPONENTS_TRANSLATE_IOS_BROWSER_TRANSLATE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698