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

Unified Diff: ios/web_view/internal/cwv_web_view_configuration.mm

Issue 2894483003: Initialize ios/web_view translate with a system-wide URLRequestContext. (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ios/web_view/internal/cwv_web_view_configuration.mm
diff --git a/ios/web_view/internal/cwv_web_view_configuration.mm b/ios/web_view/internal/cwv_web_view_configuration.mm
index bd677f49a2b86c7fd42172b5fcd52758f9a42243..49ab5cf643b4c4d20bf3f1740f30c31b606c14c8 100644
--- a/ios/web_view/internal/cwv_web_view_configuration.mm
+++ b/ios/web_view/internal/cwv_web_view_configuration.mm
@@ -9,11 +9,11 @@
#include "base/threading/thread_restrictions.h"
#include "components/translate/core/browser/translate_download_manager.h"
#include "ios/web/public/app/web_main.h"
+#include "ios/web_view/internal/app/application_context.h"
#import "ios/web_view/internal/cwv_user_content_controller_internal.h"
#import "ios/web_view/internal/web_view_browser_state.h"
#import "ios/web_view/internal/web_view_web_client.h"
#import "ios/web_view/internal/web_view_web_main_delegate.h"
-#include "ui/base/l10n/l10n_util_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
@@ -60,6 +60,15 @@
webMainDelegate = base::MakeUnique<ios_web_view::WebViewWebMainDelegate>();
web::WebMainParams params(webMainDelegate.get());
webMain = base::MakeUnique<web::WebMain>(params);
+
+ // Initialize translate.
Eugene But (OOO till 7-30) 2017/05/18 23:54:55 Is this something that can be deferred? Can this a
michaeldo 2017/05/19 22:02:36 This could affect startup performance depending on
Eugene But (OOO till 7-30) 2017/05/19 23:32:05 Can we measure how much time does it take to execu
michaeldo 2017/05/23 22:38:36 On my iPhone 7 this code takes about half a millis
+ translate::TranslateDownloadManager* downloadManager =
+ translate::TranslateDownloadManager::GetInstance();
+ downloadManager->set_request_context(
+ GetApplicationContext()->GetSystemURLRequestContext());
+ downloadManager->set_application_locale(
+ GetApplicationContext()->GetApplicationLocale());
+ downloadManager->language_list()->SetResourceRequestsAllowed(true);
});
}
@@ -69,15 +78,6 @@
if (self) {
_browserState = std::move(browserState);
- // Initialize translate.
- translate::TranslateDownloadManager* downloadManager =
- translate::TranslateDownloadManager::GetInstance();
- // TODO(crbug.com/710948): Use global request context here.
- downloadManager->set_request_context(_browserState->GetRequestContext());
- // TODO(crbug.com/679895): Bring up application locale correctly.
- downloadManager->set_application_locale(l10n_util::GetLocaleOverride());
- downloadManager->language_list()->SetResourceRequestsAllowed(true);
-
_userContentController =
[[CWVUserContentController alloc] initWithConfiguration:self];
}

Powered by Google App Engine
This is Rietveld 408576698