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