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_dev_tools_discovery_provider.h" | 8 #include "android_webview/browser/aw_dev_tools_discovery_provider.h" |
9 #include "android_webview/browser/aw_media_client_android.h" | 9 #include "android_webview/browser/aw_media_client_android.h" |
10 #include "android_webview/browser/aw_result_codes.h" | 10 #include "android_webview/browser/aw_result_codes.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 // TODO(primiano, mkosiba): GetApplicationLocale requires a ResourceBundle | 55 // TODO(primiano, mkosiba): GetApplicationLocale requires a ResourceBundle |
56 // instance to be present to work correctly so we call this (knowing it will | 56 // instance to be present to work correctly so we call this (knowing it will |
57 // fail) just to create the ResourceBundle instance. We should refactor | 57 // fail) just to create the ResourceBundle instance. We should refactor |
58 // ResourceBundle/GetApplicationLocale to not require an instance to be | 58 // ResourceBundle/GetApplicationLocale to not require an instance to be |
59 // initialized. | 59 // initialized. |
60 ui::ResourceBundle::InitSharedInstanceWithLocale( | 60 ui::ResourceBundle::InitSharedInstanceWithLocale( |
61 base::android::GetDefaultLocale(), | 61 base::android::GetDefaultLocale(), |
62 NULL, | 62 NULL, |
63 ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); | 63 ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); |
64 std::string locale = l10n_util::GetApplicationLocale(std::string()) + ".pak"; | 64 std::string locale = |
| 65 "assets/" + l10n_util::GetApplicationLocale(std::string()) + ".pak"; |
65 int pak_fd = base::android::OpenApkAsset(locale, &pak_region); | 66 int pak_fd = base::android::OpenApkAsset(locale, &pak_region); |
66 if (pak_fd != -1) { | 67 if (pak_fd != -1) { |
67 ui::ResourceBundle::CleanupSharedInstance(); | 68 ui::ResourceBundle::CleanupSharedInstance(); |
68 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion( | 69 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion( |
69 base::File(pak_fd), pak_region); | 70 base::File(pak_fd), pak_region); |
70 } else { | 71 } else { |
71 LOG(WARNING) << "Failed to load " << locale << ".pak from the apk too. " | 72 LOG(WARNING) << "Failed to load " << locale << ".pak from the apk too. " |
72 "Bringing up WebView without any locale"; | 73 "Bringing up WebView without any locale"; |
73 } | 74 } |
74 | 75 |
75 // Try to directly mmap the webviewchromium.pak from the apk. Fall back to | 76 // Try to directly mmap the webviewchromium.pak from the apk. Fall back to |
76 // load from file, using PATH_SERVICE, otherwise. | 77 // load from file, using PATH_SERVICE, otherwise. |
77 pak_fd = base::android::OpenApkAsset("webviewchromium.pak", &pak_region); | 78 pak_fd = base::android::OpenApkAsset("assets/webviewchromium.pak", |
| 79 &pak_region); |
78 if (pak_fd != -1) { | 80 if (pak_fd != -1) { |
79 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( | 81 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion( |
80 base::File(pak_fd), pak_region, ui::SCALE_FACTOR_NONE); | 82 base::File(pak_fd), pak_region, ui::SCALE_FACTOR_NONE); |
81 } else { | 83 } else { |
82 base::FilePath pak_path; | 84 base::FilePath pak_path; |
83 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_path); | 85 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_path); |
84 LOG(WARNING) << "Cannot load webviewchromium.pak assets from the apk. " | 86 LOG(WARNING) << "Cannot load webviewchromium.pak assets from the apk. " |
85 "Falling back loading it from " << pak_path.MaybeAsASCII(); | 87 "Falling back loading it from " << pak_path.MaybeAsASCII(); |
86 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 88 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
87 pak_path.AppendASCII("webviewchromium.pak"), ui::SCALE_FACTOR_NONE); | 89 pak_path.AppendASCII("webviewchromium.pak"), ui::SCALE_FACTOR_NONE); |
(...skipping 18 matching lines...) Expand all Loading... |
106 content::SetMaxURLChars(20 * 1024 * 1024); | 108 content::SetMaxURLChars(20 * 1024 * 1024); |
107 } | 109 } |
108 | 110 |
109 bool AwBrowserMainParts::MainMessageLoopRun(int* result_code) { | 111 bool AwBrowserMainParts::MainMessageLoopRun(int* result_code) { |
110 // Android WebView does not use default MessageLoop. It has its own | 112 // Android WebView does not use default MessageLoop. It has its own |
111 // Android specific MessageLoop. | 113 // Android specific MessageLoop. |
112 return true; | 114 return true; |
113 } | 115 } |
114 | 116 |
115 } // namespace android_webview | 117 } // namespace android_webview |
OLD | NEW |