Fix build for use_aura=0
[chromium-blink-merge.git] / android_webview / browser / aw_browser_main_parts.cc
blobc018d1e8927e032fbe22db869ed84c6274c3b1a8
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "android_webview/browser/aw_browser_main_parts.h"
7 #include "android_webview/browser/aw_browser_context.h"
8 #include "android_webview/browser/aw_result_codes.h"
9 #include "base/android/build_info.h"
10 #include "base/android/memory_pressure_listener_android.h"
11 #include "base/files/file_path.h"
12 #include "base/path_service.h"
13 #include "content/public/browser/render_process_host.h"
14 #include "content/public/common/content_client.h"
15 #include "content/public/common/result_codes.h"
16 #include "content/public/common/url_utils.h"
17 #include "net/android/network_change_notifier_factory_android.h"
18 #include "net/base/network_change_notifier.h"
19 #include "ui/base/l10n/l10n_util_android.h"
20 #include "ui/base/layout.h"
21 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/base/ui_base_paths.h"
24 namespace android_webview {
26 AwBrowserMainParts::AwBrowserMainParts(AwBrowserContext* browser_context)
27 : browser_context_(browser_context) {
30 AwBrowserMainParts::~AwBrowserMainParts() {
33 void AwBrowserMainParts::PreEarlyInitialization() {
34 net::NetworkChangeNotifier::SetFactory(
35 new net::NetworkChangeNotifierFactoryAndroid());
37 // Android WebView does not use default MessageLoop. It has its own
38 // Android specific MessageLoop. Also see MainMessageLoopRun.
39 DCHECK(!main_message_loop_.get());
40 main_message_loop_.reset(new base::MessageLoopForUI);
41 base::MessageLoopForUI::current()->Start();
44 int AwBrowserMainParts::PreCreateThreads() {
45 ui::ResourceBundle::InitSharedInstanceLocaleOnly(
46 l10n_util::GetDefaultLocale(), NULL);
48 base::FilePath pak_path;
49 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_path);
51 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
52 pak_path.AppendASCII("webviewchromium.pak"),
53 ui::SCALE_FACTOR_NONE);
55 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback(
56 base::android::AttachCurrentThread());
58 return content::RESULT_CODE_NORMAL_EXIT;
61 void AwBrowserMainParts::PreMainMessageLoopRun() {
62 browser_context_->PreMainMessageLoopRun();
63 // This is needed for WebView Classic backwards compatibility
64 // See crbug.com/298495
65 content::SetMaxURLChars(20 * 1024 * 1024);
68 bool AwBrowserMainParts::MainMessageLoopRun(int* result_code) {
69 // Android WebView does not use default MessageLoop. It has its own
70 // Android specific MessageLoop.
71 return true;
74 } // namespace android_webview