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

Side by Side Diff: content/shell/app/shell_main_delegate.cc

Issue 1181953002: Load non-locale .pak files directly from the .apk on Android (rather than extracting on start-up). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@raw-paks
Patch Set: fix unused LoadMainAndroidPackFile Created 5 years, 6 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 unified diff | Download patch
OLDNEW
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 "content/shell/app/shell_main_delegate.h" 5 #include "content/shell/app/shell_main_delegate.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/cpu.h" 9 #include "base/cpu.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 #if defined(IPC_MESSAGE_LOG_ENABLED) 43 #if defined(IPC_MESSAGE_LOG_ENABLED)
44 #define IPC_MESSAGE_MACROS_LOG_ENABLED 44 #define IPC_MESSAGE_MACROS_LOG_ENABLED
45 #include "content/public/common/content_ipc_logging.h" 45 #include "content/public/common/content_ipc_logging.h"
46 #define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \ 46 #define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \
47 content::RegisterIPCLogger(msg_id, logger) 47 content::RegisterIPCLogger(msg_id, logger)
48 #include "content/shell/common/shell_messages.h" 48 #include "content/shell/common/shell_messages.h"
49 #endif 49 #endif
50 50
51 #if defined(OS_ANDROID) 51 #if defined(OS_ANDROID)
52 #include "base/android/apk_assets.h"
52 #include "base/posix/global_descriptors.h" 53 #include "base/posix/global_descriptors.h"
53 #include "content/shell/android/shell_descriptors.h" 54 #include "content/shell/android/shell_descriptors.h"
54 #endif 55 #endif
55 56
56 #if defined(OS_MACOSX) 57 #if defined(OS_MACOSX)
57 #include "base/mac/os_crash_dumps.h" 58 #include "base/mac/os_crash_dumps.h"
58 #include "components/crash/app/breakpad_mac.h" 59 #include "components/crash/app/breakpad_mac.h"
59 #include "content/shell/app/paths_mac.h" 60 #include "content/shell/app/paths_mac.h"
60 #include "content/shell/app/shell_main_delegate_mac.h" 61 #include "content/shell/app/shell_main_delegate_mac.h"
61 #endif // OS_MACOSX 62 #endif // OS_MACOSX
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 breakpad::InitCrashReporter(process_type); 292 breakpad::InitCrashReporter(process_type);
292 } 293 }
293 } 294 }
294 #endif 295 #endif
295 296
296 void ShellMainDelegate::InitializeResourceBundle() { 297 void ShellMainDelegate::InitializeResourceBundle() {
297 #if defined(OS_ANDROID) 298 #if defined(OS_ANDROID)
298 // In the Android case, the renderer runs with a different UID and can never 299 // In the Android case, the renderer runs with a different UID and can never
299 // access the file system. So we are passed a file descriptor to the 300 // access the file system. So we are passed a file descriptor to the
300 // ResourceBundle pak at launch time. 301 // ResourceBundle pak at launch time.
301 int pak_fd = 302 auto global_descriptors = base::GlobalDescriptors::GetInstance();
302 base::GlobalDescriptors::GetInstance()->MaybeGet(kShellPakDescriptor); 303 int pak_fd = global_descriptors->MaybeGet(kShellPakDescriptor);
304 base::MemoryMappedFile::Region pak_region;
303 if (pak_fd >= 0) { 305 if (pak_fd >= 0) {
306 pak_region = global_descriptors->GetRegion(kShellPakDescriptor);
304 // This is clearly wrong. See crbug.com/330930 307 // This is clearly wrong. See crbug.com/330930
305 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion( 308 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(base::File(pak_fd),
306 base::File(pak_fd), base::MemoryMappedFile::Region::kWholeFile); 309 pak_region);
307 ResourceBundle::GetSharedInstance().AddDataPackFromFile( 310 ui::ResourceBundle::GetSharedInstance().AddDataPackFromFileRegion(
308 base::File(pak_fd), ui::SCALE_FACTOR_100P); 311 base::File(pak_fd), pak_region, ui::SCALE_FACTOR_100P);
309 return; 312 } else {
313 pak_fd =
314 base::android::OpenApkAsset("assets/content_shell.pak", &pak_region);
Yaron 2015/06/17 14:12:28 Why does webview have to fallback to loading from
agrieve 2015/06/17 14:35:40 Likely for tests (where files are put there by iso
315 DCHECK_GE(pak_fd, 0);
316 global_descriptors->Set(kShellPakDescriptor, pak_fd, pak_region);
317 ui::ResourceBundle::InitSharedInstanceWithPakFileRegion(base::File(pak_fd),
318 pak_region);
310 } 319 }
311 #endif 320 #else
312
313 base::FilePath pak_file; 321 base::FilePath pak_file;
314 #if defined(OS_MACOSX) 322 #if defined(OS_MACOSX)
315 pak_file = GetResourcesPakFilePath(); 323 pak_file = GetResourcesPakFilePath();
316 #else 324 #else
317 base::FilePath pak_dir; 325 base::FilePath pak_dir;
318
319 #if defined(OS_ANDROID)
320 bool got_path = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_dir);
321 DCHECK(got_path);
322 pak_dir = pak_dir.Append(FILE_PATH_LITERAL("paks"));
323 #else
324 PathService::Get(base::DIR_MODULE, &pak_dir); 326 PathService::Get(base::DIR_MODULE, &pak_dir);
325 #endif
326
327 pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak")); 327 pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak"));
328 #endif 328 #endif // defined(OS_MACOSX)
329 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); 329 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
330 #endif // defined(OS_ANDROID)
330 } 331 }
331 332
332 ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() { 333 ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() {
333 browser_client_.reset(base::CommandLine::ForCurrentProcess()->HasSwitch( 334 browser_client_.reset(base::CommandLine::ForCurrentProcess()->HasSwitch(
334 switches::kRunLayoutTest) 335 switches::kRunLayoutTest)
335 ? new LayoutTestContentBrowserClient 336 ? new LayoutTestContentBrowserClient
336 : new ShellContentBrowserClient); 337 : new ShellContentBrowserClient);
337 338
338 return browser_client_.get(); 339 return browser_client_.get();
339 } 340 }
340 341
341 ContentRendererClient* ShellMainDelegate::CreateContentRendererClient() { 342 ContentRendererClient* ShellMainDelegate::CreateContentRendererClient() {
342 renderer_client_.reset(base::CommandLine::ForCurrentProcess()->HasSwitch( 343 renderer_client_.reset(base::CommandLine::ForCurrentProcess()->HasSwitch(
343 switches::kRunLayoutTest) 344 switches::kRunLayoutTest)
344 ? new LayoutTestContentRendererClient 345 ? new LayoutTestContentRendererClient
345 : new ShellContentRendererClient); 346 : new ShellContentRendererClient);
346 347
347 return renderer_client_.get(); 348 return renderer_client_.get();
348 } 349 }
349 350
350 ContentUtilityClient* ShellMainDelegate::CreateContentUtilityClient() { 351 ContentUtilityClient* ShellMainDelegate::CreateContentUtilityClient() {
351 utility_client_.reset(new ShellContentUtilityClient); 352 utility_client_.reset(new ShellContentUtilityClient);
352 return utility_client_.get(); 353 return utility_client_.get();
353 } 354 }
354 355
355 } // namespace content 356 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698