OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "android_webview/browser/aw_browser_main_parts.h" | 5 #include "android_webview/browser/aw_browser_main_parts.h" |
6 | 6 |
7 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
8 #include "android_webview/browser/aw_result_codes.h" | 8 #include "android_webview/browser/aw_result_codes.h" |
9 #include "android_webview/native/aw_assets.h" | |
9 #include "base/android/build_info.h" | 10 #include "base/android/build_info.h" |
10 #include "base/android/memory_pressure_listener_android.h" | 11 #include "base/android/memory_pressure_listener_android.h" |
11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
13 #include "base/path_service.h" | 14 #include "base/path_service.h" |
14 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
15 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" |
16 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
17 #include "content/public/common/result_codes.h" | 18 #include "content/public/common/result_codes.h" |
18 #include "content/public/common/url_utils.h" | 19 #include "content/public/common/url_utils.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
44 base::MessageLoopForUI::current()->Start(); | 45 base::MessageLoopForUI::current()->Start(); |
45 } | 46 } |
46 | 47 |
47 int AwBrowserMainParts::PreCreateThreads() { | 48 int AwBrowserMainParts::PreCreateThreads() { |
48 ui::ResourceBundle::InitSharedInstanceLocaleOnly( | 49 ui::ResourceBundle::InitSharedInstanceLocaleOnly( |
49 l10n_util::GetDefaultLocale(), NULL); | 50 l10n_util::GetDefaultLocale(), NULL); |
50 | 51 |
51 base::FilePath pak_path; | 52 base::FilePath pak_path; |
52 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_path); | 53 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_path); |
53 | 54 |
54 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 55 int pak_fd = 0; |
55 pak_path.AppendASCII("webviewchromium.pak"), | 56 int64 pak_off = 0; |
56 ui::SCALE_FACTOR_NONE); | 57 int64 pak_len = 0; |
58 if (!AwAssets::OpenAsset( | |
59 "webviewchromium.pak", &pak_fd, &pak_off, &pak_len)) { | |
60 LOG(FATAL) << "Cannot load webviewchromium.pak assets from the apk"; | |
61 } else { | |
62 VLOG(0) << "Loading pak from FD: " << pak_fd << " OFF: " << pak_off | |
63 << " LEN: " << pak_len; | |
64 } | |
65 | |
66 // ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( | |
mkosiba (inactive)
2014/07/18 05:54:22
forgot to remove?
Primiano Tucci (use gerrit)
2014/07/18 19:01:04
Oh, yeah.
| |
67 // pak_path.AppendASCII("webviewchromium.pak"), | |
68 // ui::SCALE_FACTOR_NONE); | |
69 | |
70 base::File::Region region(pak_off, pak_len); | |
71 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( | |
72 base::File(pak_fd), region, ui::SCALE_FACTOR_NONE); | |
57 | 73 |
58 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback( | 74 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback( |
59 base::android::AttachCurrentThread()); | 75 base::android::AttachCurrentThread()); |
60 | 76 |
61 return content::RESULT_CODE_NORMAL_EXIT; | 77 return content::RESULT_CODE_NORMAL_EXIT; |
62 } | 78 } |
63 | 79 |
64 void AwBrowserMainParts::PreMainMessageLoopRun() { | 80 void AwBrowserMainParts::PreMainMessageLoopRun() { |
65 // TODO(boliu): Can't support accelerated 2d canvas and WebGL with ubercomp | 81 // TODO(boliu): Can't support accelerated 2d canvas and WebGL with ubercomp |
66 // yet: crbug.com/352424. | 82 // yet: crbug.com/352424. |
67 if (!gpu::gles2::MailboxSynchronizer::Initialize()) { | 83 if (!gpu::gles2::MailboxSynchronizer::Initialize()) { |
68 CommandLine* cl = CommandLine::ForCurrentProcess(); | 84 CommandLine* cl = CommandLine::ForCurrentProcess(); |
69 cl->AppendSwitch(switches::kDisableAccelerated2dCanvas); | 85 cl->AppendSwitch(switches::kDisableAccelerated2dCanvas); |
70 cl->AppendSwitch(switches::kDisableExperimentalWebGL); | 86 cl->AppendSwitch(switches::kDisableExperimentalWebGL); |
71 } | 87 } |
72 | 88 |
73 browser_context_->PreMainMessageLoopRun(); | 89 browser_context_->PreMainMessageLoopRun(); |
74 // This is needed for WebView Classic backwards compatibility | 90 // This is needed for WebView Classic backwards compatibility |
75 // See crbug.com/298495 | 91 // See crbug.com/298495 |
76 content::SetMaxURLChars(20 * 1024 * 1024); | 92 content::SetMaxURLChars(20 * 1024 * 1024); |
77 } | 93 } |
78 | 94 |
79 bool AwBrowserMainParts::MainMessageLoopRun(int* result_code) { | 95 bool AwBrowserMainParts::MainMessageLoopRun(int* result_code) { |
80 // Android WebView does not use default MessageLoop. It has its own | 96 // Android WebView does not use default MessageLoop. It has its own |
81 // Android specific MessageLoop. | 97 // Android specific MessageLoop. |
82 return true; | 98 return true; |
83 } | 99 } |
84 | 100 |
85 } // namespace android_webview | 101 } // namespace android_webview |
OLD | NEW |