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

Side by Side Diff: ios/web_view/internal/web_view_web_main_parts.mm

Issue 2894483003: Initialize ios/web_view translate with a system-wide URLRequestContext. (Closed)
Patch Set: Cleanup. 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
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 #import "ios/web_view/internal/web_view_web_main_parts.h" 5 #import "ios/web_view/internal/web_view_web_main_parts.h"
6 6
7 #import <Foundation/Foundation.h>
8
9 #include "base/base_paths.h" 7 #include "base/base_paths.h"
10 #include "base/memory/ptr_util.h"
11 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "ios/web_view/internal/app/application_context.h"
10 #include "ios/web_view/internal/translate/web_view_translate_service.h"
12 #include "ui/base/l10n/l10n_util_mac.h" 11 #include "ui/base/l10n/l10n_util_mac.h"
13 #include "ui/base/resource/resource_bundle.h" 12 #include "ui/base/resource/resource_bundle.h"
14 13
15 #if !defined(__has_feature) || !__has_feature(objc_arc) 14 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support." 15 #error "This file requires ARC support."
17 #endif 16 #endif
18 17
19 namespace ios_web_view { 18 namespace ios_web_view {
20 19
21 WebViewWebMainParts::WebViewWebMainParts() {} 20 WebViewWebMainParts::WebViewWebMainParts() {}
22 21
23 WebViewWebMainParts::~WebViewWebMainParts() = default; 22 WebViewWebMainParts::~WebViewWebMainParts() = default;
24 23
25 void WebViewWebMainParts::PreMainMessageLoopRun() { 24 void WebViewWebMainParts::PreMainMessageLoopStart() {
26 // Initialize resources.
27 l10n_util::OverrideLocaleWithCocoaLocale(); 25 l10n_util::OverrideLocaleWithCocoaLocale();
28 ui::ResourceBundle::InitSharedInstanceWithLocale( 26 ui::ResourceBundle::InitSharedInstanceWithLocale(
29 std::string(), nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); 27 std::string(), nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
28
30 base::FilePath pak_file; 29 base::FilePath pak_file;
31 PathService::Get(base::DIR_MODULE, &pak_file); 30 PathService::Get(base::DIR_MODULE, &pak_file);
32 pak_file = pak_file.Append(FILE_PATH_LITERAL("web_view_resources.pak")); 31 pak_file = pak_file.Append(FILE_PATH_LITERAL("web_view_resources.pak"));
33 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( 32 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
34 pak_file, ui::SCALE_FACTOR_NONE); 33 pak_file, ui::SCALE_FACTOR_NONE);
35 } 34 }
36 35
36 void WebViewWebMainParts::PreCreateThreads() {
37 // Initialize local state.
38 DCHECK(ApplicationContext::GetInstance()->GetLocalState());
39
40 ApplicationContext::GetInstance()->PreCreateThreads();
41 }
42
43 void WebViewWebMainParts::PreMainMessageLoopRun() {
44 WebViewTranslateService::GetInstance()->Initialize();
45 }
46
47 void WebViewWebMainParts::PostMainMessageLoopRun() {
48 WebViewTranslateService::GetInstance()->Shutdown();
49 ApplicationContext::GetInstance()->SaveState();
50 }
51
52 void WebViewWebMainParts::PostDestroyThreads() {
53 ApplicationContext::GetInstance()->PostDestroyThreads();
54 }
55
37 } // namespace ios_web_view 56 } // namespace ios_web_view
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698