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