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

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

Issue 2894483003: Initialize ios/web_view translate with a system-wide URLRequestContext. (Closed)
Patch Set: Respond to comments. Created 3 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_SERVICE_H_
6 #define IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_SERVICE_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h"
10 #include "components/web_resource/resource_request_allowed_notifier.h"
11
12 namespace base {
13 template <typename T>
14 struct DefaultSingletonTraits;
15 }
16
17 namespace ios_web_view {
18
19 // Singleton managing the resources required for Translate.
20 class WebViewTranslateService {
21 public:
22 static WebViewTranslateService* GetInstance();
23
24 // Must be called before the Translate feature can be used.
25 void Initialize();
26
27 // Must be called to shut down the Translate feature.
28 void Shutdown();
29
30 private:
31 // Manages enabling translate requests only when resource requests are
32 // allowed.
33 // TODO(crbug.com/728776): Merge TranslateRequestsAllowedListener and
34 // WebViewTranslateService. They currently must be separate classes because
35 // the destructor of web_resource::ResourceRequestAllowedNotifier::Observer is
36 // not virtual.
37 class TranslateRequestsAllowedListener
38 : public web_resource::ResourceRequestAllowedNotifier::Observer {
39 public:
40 TranslateRequestsAllowedListener();
41 ~TranslateRequestsAllowedListener();
42
43 // ResourceRequestAllowedNotifier::Observer methods.
44 void OnResourceRequestsAllowed() override;
45
46 private:
47 // Notifier class to know if it's allowed to make network resource requests.
48 web_resource::ResourceRequestAllowedNotifier
49 resource_request_allowed_notifier_;
50
51 DISALLOW_COPY_AND_ASSIGN(TranslateRequestsAllowedListener);
52 };
53
54 WebViewTranslateService();
55 ~WebViewTranslateService();
56
57 friend struct base::DefaultSingletonTraits<WebViewTranslateService>;
58
59 // Listener which manages when translate requests can occur.
60 TranslateRequestsAllowedListener translate_requests_allowed_listener_;
61
62 DISALLOW_COPY_AND_ASSIGN(WebViewTranslateService);
63 };
64
65 } // namespace ios_web_view
66
67 #endif // IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_SERVICE_H_
OLDNEW
« no previous file with comments | « ios/web_view/internal/cwv_web_view_configuration.mm ('k') | ios/web_view/internal/translate/web_view_translate_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698