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 "android_webview/native/public/aw_assets_utils.h" |
10 #include "base/android/build_info.h" | 10 #include "base/android/build_info.h" |
11 #include "base/android/locale_utils.h" | 11 #include "base/android/locale_utils.h" |
12 #include "base/android/memory_pressure_listener_android.h" | 12 #include "base/android/memory_pressure_listener_android.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
16 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" |
17 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
18 #include "content/public/common/result_codes.h" | 18 #include "content/public/common/result_codes.h" |
19 #include "content/public/common/url_utils.h" | 19 #include "content/public/common/url_utils.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // TODO(primiano, mkosiba): GetApplicationLocale requires a ResourceBundle | 52 // TODO(primiano, mkosiba): GetApplicationLocale requires a ResourceBundle |
53 // instance to be present to work correctly so we call this (knowing it will | 53 // instance to be present to work correctly so we call this (knowing it will |
54 // fail) just to create the ResourceBundle instance. We should refactor | 54 // fail) just to create the ResourceBundle instance. We should refactor |
55 // ResourceBundle/GetApplicationLocale to not require an instance to be | 55 // ResourceBundle/GetApplicationLocale to not require an instance to be |
56 // initialized. | 56 // initialized. |
57 ui::ResourceBundle::InitSharedInstanceWithLocale( | 57 ui::ResourceBundle::InitSharedInstanceWithLocale( |
58 base::android::GetDefaultLocale(), | 58 base::android::GetDefaultLocale(), |
59 NULL, | 59 NULL, |
60 ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); | 60 ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); |
61 std::string locale = l10n_util::GetApplicationLocale(std::string()) + ".pak"; | 61 std::string locale = l10n_util::GetApplicationLocale(std::string()) + ".pak"; |
62 if (AwAssets::OpenAsset(locale, &pak_fd, &pak_off, &pak_len)) { | 62 if (AwAssetsUtils::OpenAsset(locale, &pak_fd, &pak_off, &pak_len)) { |
63 VLOG(0) << "Load from apk succesful, fd=" << pak_fd << " off=" << pak_off | 63 VLOG(0) << "Load from apk succesful, fd=" << pak_fd << " off=" << pak_off |
64 << " len=" << pak_len; | 64 << " len=" << pak_len; |
65 ui::ResourceBundle::CleanupSharedInstance(); | 65 ui::ResourceBundle::CleanupSharedInstance(); |
66 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion( | 66 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion( |
67 base::File(pak_fd), base::MemoryMappedFile::Region(pak_off, pak_len)); | 67 base::File(pak_fd), base::MemoryMappedFile::Region(pak_off, pak_len)); |
68 } else { | 68 } else { |
69 LOG(WARNING) << "Failed to load " << locale << ".pak from the apk too. " | 69 LOG(WARNING) << "Failed to load " << locale << ".pak from the apk too. " |
70 "Bringing up WebView without any locale"; | 70 "Bringing up WebView without any locale"; |
71 } | 71 } |
72 | 72 |
73 // Try to directly mmap the webviewchromium.pak from the apk. Fall back to | 73 // Try to directly mmap the webviewchromium.pak from the apk. Fall back to |
74 // load from file, using PATH_SERVICE, otherwise. | 74 // load from file, using PATH_SERVICE, otherwise. |
75 if (AwAssets::OpenAsset("webviewchromium.pak", &pak_fd, &pak_off, &pak_len)) { | 75 if (AwAssetsUtils::OpenAsset("webviewchromium.pak", &pak_fd, &pak_off, |
| 76 &pak_len)) { |
76 VLOG(0) << "Loading webviewchromium.pak from, fd:" << pak_fd | 77 VLOG(0) << "Loading webviewchromium.pak from, fd:" << pak_fd |
77 << " off:" << pak_off << " len:" << pak_len; | 78 << " off:" << pak_off << " len:" << pak_len; |
78 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( | 79 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( |
79 base::File(pak_fd), | 80 base::File(pak_fd), |
80 base::MemoryMappedFile::Region(pak_off, pak_len), | 81 base::MemoryMappedFile::Region(pak_off, pak_len), |
81 ui::SCALE_FACTOR_NONE); | 82 ui::SCALE_FACTOR_NONE); |
82 } else { | 83 } else { |
83 base::FilePath pak_path; | 84 base::FilePath pak_path; |
84 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_path); | 85 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_path); |
85 LOG(WARNING) << "Cannot load webviewchromium.pak assets from the apk. " | 86 LOG(WARNING) << "Cannot load webviewchromium.pak assets from the apk. " |
(...skipping 15 matching lines...) Expand all Loading... |
101 content::SetMaxURLChars(20 * 1024 * 1024); | 102 content::SetMaxURLChars(20 * 1024 * 1024); |
102 } | 103 } |
103 | 104 |
104 bool AwBrowserMainParts::MainMessageLoopRun(int* result_code) { | 105 bool AwBrowserMainParts::MainMessageLoopRun(int* result_code) { |
105 // Android WebView does not use default MessageLoop. It has its own | 106 // Android WebView does not use default MessageLoop. It has its own |
106 // Android specific MessageLoop. | 107 // Android specific MessageLoop. |
107 return true; | 108 return true; |
108 } | 109 } |
109 | 110 |
110 } // namespace android_webview | 111 } // namespace android_webview |
OLD | NEW |