OLD | NEW |
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" | 8 #include "base/command_line.h" |
11 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "ios/web_view/internal/app/application_context_impl.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( |
| 21 const base::CommandLine& parsed_command_line) |
| 22 : parsed_command_line_(parsed_command_line) {} |
22 | 23 |
23 WebViewWebMainParts::~WebViewWebMainParts() = default; | 24 WebViewWebMainParts::~WebViewWebMainParts() = default; |
24 | 25 |
25 void WebViewWebMainParts::PreMainMessageLoopRun() { | 26 void WebViewWebMainParts::PreMainMessageLoopStart() { |
26 // Initialize resources. | |
27 l10n_util::OverrideLocaleWithCocoaLocale(); | 27 l10n_util::OverrideLocaleWithCocoaLocale(); |
28 ui::ResourceBundle::InitSharedInstanceWithLocale( | 28 ui::ResourceBundle::InitSharedInstanceWithLocale( |
29 std::string(), nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); | 29 std::string(), nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); |
| 30 |
30 base::FilePath pak_file; | 31 base::FilePath pak_file; |
31 PathService::Get(base::DIR_MODULE, &pak_file); | 32 PathService::Get(base::DIR_MODULE, &pak_file); |
32 pak_file = pak_file.Append(FILE_PATH_LITERAL("web_view_resources.pak")); | 33 pak_file = pak_file.Append(FILE_PATH_LITERAL("web_view_resources.pak")); |
33 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 34 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
34 pak_file, ui::SCALE_FACTOR_NONE); | 35 pak_file, ui::SCALE_FACTOR_NONE); |
35 } | 36 } |
36 | 37 |
| 38 void WebViewWebMainParts::PreCreateThreads() { |
| 39 application_context_.reset(new ApplicationContextImpl( |
| 40 parsed_command_line_, l10n_util::GetLocaleOverride())); |
| 41 DCHECK_EQ(application_context_.get(), GetApplicationContext()); |
| 42 |
| 43 // Initialize local state. |
| 44 DCHECK(application_context_->GetLocalState()); |
| 45 |
| 46 application_context_->PreCreateThreads(); |
| 47 } |
| 48 |
| 49 void WebViewWebMainParts::PostMainMessageLoopRun() { |
| 50 // TODO(crbug.com/723869): Shutdown translate. |
| 51 application_context_->SaveState(); |
| 52 } |
| 53 |
| 54 void WebViewWebMainParts::PostDestroyThreads() { |
| 55 application_context_->PostDestroyThreads(); |
| 56 } |
| 57 |
37 } // namespace ios_web_view | 58 } // namespace ios_web_view |
OLD | NEW |