| 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> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "components/translate/core/browser/translate_download_manager.h" | |
| 13 #include "ios/web_view/internal/web_view_browser_state.h" | |
| 14 #include "ui/base/l10n/l10n_util_mac.h" | 12 #include "ui/base/l10n/l10n_util_mac.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 16 | 14 |
| 17 #if !defined(__has_feature) || !__has_feature(objc_arc) | 15 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 18 #error "This file requires ARC support." | 16 #error "This file requires ARC support." |
| 19 #endif | 17 #endif |
| 20 | 18 |
| 21 namespace ios_web_view { | 19 namespace ios_web_view { |
| 22 | 20 |
| 23 WebViewWebMainParts::WebViewWebMainParts() {} | 21 WebViewWebMainParts::WebViewWebMainParts() {} |
| 24 | 22 |
| 25 WebViewWebMainParts::~WebViewWebMainParts() = default; | 23 WebViewWebMainParts::~WebViewWebMainParts() = default; |
| 26 | 24 |
| 27 void WebViewWebMainParts::PreMainMessageLoopRun() { | 25 void WebViewWebMainParts::PreMainMessageLoopRun() { |
| 28 // Initialize resources. | 26 // Initialize resources. |
| 29 l10n_util::OverrideLocaleWithCocoaLocale(); | 27 l10n_util::OverrideLocaleWithCocoaLocale(); |
| 30 ui::ResourceBundle::InitSharedInstanceWithLocale( | 28 ui::ResourceBundle::InitSharedInstanceWithLocale( |
| 31 std::string(), nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); | 29 std::string(), nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); |
| 32 base::FilePath pak_file; | 30 base::FilePath pak_file; |
| 33 PathService::Get(base::DIR_MODULE, &pak_file); | 31 PathService::Get(base::DIR_MODULE, &pak_file); |
| 34 pak_file = pak_file.Append(FILE_PATH_LITERAL("web_view_resources.pak")); | 32 pak_file = pak_file.Append(FILE_PATH_LITERAL("web_view_resources.pak")); |
| 35 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 33 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| 36 pak_file, ui::SCALE_FACTOR_NONE); | 34 pak_file, ui::SCALE_FACTOR_NONE); |
| 37 | |
| 38 browser_state_ = base::MakeUnique<WebViewBrowserState>(false); | |
| 39 off_the_record_browser_state_ = base::MakeUnique<WebViewBrowserState>(true); | |
| 40 | |
| 41 // Initialize translate. | |
| 42 translate::TranslateDownloadManager* download_manager = | |
| 43 translate::TranslateDownloadManager::GetInstance(); | |
| 44 // TODO(crbug.com/679895): See if we need the system request context here. | |
| 45 download_manager->set_request_context(browser_state_->GetRequestContext()); | |
| 46 // TODO(crbug.com/679895): Bring up application locale correctly. | |
| 47 download_manager->set_application_locale(l10n_util::GetLocaleOverride()); | |
| 48 download_manager->language_list()->SetResourceRequestsAllowed(true); | |
| 49 } | 35 } |
| 50 | 36 |
| 51 } // namespace ios_web_view | 37 } // namespace ios_web_view |
| OLD | NEW |