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

Side by Side Diff: ios/web_view/internal/translate/web_view_translate_client.h

Issue 2762023003: Enable ARC for //ios/web_view/internal/translate/*.m. (Closed)
Patch Set: Created 3 years, 9 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 IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_CLIENT_H_ 5 #ifndef IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_CLIENT_H_
6 #define IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_CLIENT_H_ 6 #define IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_CLIENT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 19 matching lines...) Expand all
30 30
31 namespace ios_web_view { 31 namespace ios_web_view {
32 32
33 class WebViewTranslateClient 33 class WebViewTranslateClient
34 : public translate::TranslateClient, 34 : public translate::TranslateClient,
35 public web::WebStateObserver, 35 public web::WebStateObserver,
36 public web::WebStateUserData<WebViewTranslateClient> { 36 public web::WebStateUserData<WebViewTranslateClient> {
37 public: 37 public:
38 // Sets the delegate passed by the embedder. 38 // Sets the delegate passed by the embedder.
39 // |delegate| is assumed to outlive this WebViewTranslateClient. 39 // |delegate| is assumed to outlive this WebViewTranslateClient.
40 void set_translate_delegate(id<CWVTranslateDelegate> delegate) { 40 void set_translate_delegate(__weak id<CWVTranslateDelegate> delegate) {
41 delegate_ = delegate; 41 delegate_ = delegate;
42 } 42 }
43 43
44 private: 44 private:
45 friend class web::WebStateUserData<WebViewTranslateClient>; 45 friend class web::WebStateUserData<WebViewTranslateClient>;
46 46
47 // The lifetime of WebViewTranslateClient is managed by WebStateUserData. 47 // The lifetime of WebViewTranslateClient is managed by WebStateUserData.
48 explicit WebViewTranslateClient(web::WebState* web_state); 48 explicit WebViewTranslateClient(web::WebState* web_state);
49 ~WebViewTranslateClient() override; 49 ~WebViewTranslateClient() override;
50 50
(...skipping 14 matching lines...) Expand all
65 bool IsTranslatableURL(const GURL& url) override; 65 bool IsTranslatableURL(const GURL& url) override;
66 void ShowReportLanguageDetectionErrorUI(const GURL& report_url) override; 66 void ShowReportLanguageDetectionErrorUI(const GURL& report_url) override;
67 67
68 // web::WebStateObserver implementation. 68 // web::WebStateObserver implementation.
69 void WebStateDestroyed() override; 69 void WebStateDestroyed() override;
70 70
71 std::unique_ptr<translate::TranslateManager> translate_manager_; 71 std::unique_ptr<translate::TranslateManager> translate_manager_;
72 translate::IOSTranslateDriver translate_driver_; 72 translate::IOSTranslateDriver translate_driver_;
73 73
74 // Delegate provided by the embedder. 74 // Delegate provided by the embedder.
75 id<CWVTranslateDelegate> delegate_; // Weak. 75 __weak id<CWVTranslateDelegate> delegate_;
michaeldo 2017/03/21 16:29:18 Please use base::WeakNSProtocol<id<CWVTranslateDel
Hiroshi Ichikawa 2017/03/22 01:32:15 Done. Just curious, what is advantage of using Wea
michaeldo 2017/03/22 02:13:46 Good question, I don't have all the details, but i
76 76
77 DISALLOW_COPY_AND_ASSIGN(WebViewTranslateClient); 77 DISALLOW_COPY_AND_ASSIGN(WebViewTranslateClient);
78 }; 78 };
79 79
80 } // namespace ios_web_view 80 } // namespace ios_web_view
81 81
82 #endif // IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_CLIENT_H_ 82 #endif // IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698