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

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

Issue 10693157: Add pak file support for content shell and android apks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « content/shell/shell_content_browser_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/shell_main_delegate.h" 5 #include "content/shell/shell_main_delegate.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "content/public/browser/browser_main_runner.h" 11 #include "content/public/browser/browser_main_runner.h"
12 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
13 #include "content/public/common/url_constants.h" 13 #include "content/public/common/url_constants.h"
14 #include "content/shell/shell_browser_main.h" 14 #include "content/shell/shell_browser_main.h"
15 #include "content/shell/shell_content_browser_client.h" 15 #include "content/shell/shell_content_browser_client.h"
16 #include "content/shell/shell_content_renderer_client.h" 16 #include "content/shell/shell_content_renderer_client.h"
17 #include "content/shell/shell_switches.h" 17 #include "content/shell/shell_switches.h"
18 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/base/ui_base_paths.h" 19 #include "ui/base/ui_base_paths.h"
20 20
21 #if defined(OS_ANDROID)
22 #include "base/global_descriptors_posix.h"
23 #include "content/shell/android/shell_descriptors.h"
24 #endif
25
21 #if defined(OS_MACOSX) 26 #if defined(OS_MACOSX)
22 #include "content/shell/paths_mac.h" 27 #include "content/shell/paths_mac.h"
23 #endif // OS_MACOSX 28 #endif // OS_MACOSX
24 29
25 namespace { 30 namespace {
26 31
27 void InitLogging() { 32 void InitLogging() {
28 FilePath log_filename; 33 FilePath log_filename;
29 PathService::Get(base::DIR_EXE, &log_filename); 34 PathService::Get(base::DIR_EXE, &log_filename);
30 log_filename = log_filename.AppendASCII("content_shell.log"); 35 log_filename = log_filename.AppendASCII("content_shell.log");
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 browser_runner_.reset(content::BrowserMainRunner::Create()); 86 browser_runner_.reset(content::BrowserMainRunner::Create());
82 int exit_code = browser_runner_->Initialize(main_function_params); 87 int exit_code = browser_runner_->Initialize(main_function_params);
83 DCHECK(exit_code < 0) 88 DCHECK(exit_code < 0)
84 << "BrowserRunner::Initialize failed in ShellMainDelegate"; 89 << "BrowserRunner::Initialize failed in ShellMainDelegate";
85 90
86 return exit_code; 91 return exit_code;
87 #endif 92 #endif
88 } 93 }
89 94
90 void ShellMainDelegate::InitializeResourceBundle() { 95 void ShellMainDelegate::InitializeResourceBundle() {
96 #if defined(OS_ANDROID)
97 // In the Android case, the renderer runs with a different UID and can never
98 // access the file system. So we are passed a file descriptor to the
99 // ResourceBundle pak at launch time.
100 int pak_fd =
101 base::GlobalDescriptors::GetInstance()->MaybeGet(kShellPakDescriptor);
102 if (pak_fd != base::kInvalidPlatformFileValue) {
103 ui::ResourceBundle::InitSharedInstanceWithPakFile(pak_fd, false);
104 ResourceBundle::GetSharedInstance().AddDataPackFromFile(
105 pak_fd, ui::SCALE_FACTOR_100P);
106 return;
107 }
108 #endif
109
91 FilePath pak_file; 110 FilePath pak_file;
92 #if defined(OS_MACOSX) 111 #if defined(OS_MACOSX)
93 pak_file = GetResourcesPakFilePath(); 112 pak_file = GetResourcesPakFilePath();
94 #else 113 #else
95 FilePath pak_dir; 114 FilePath pak_dir;
96 115
97 #if defined(OS_ANDROID) 116 #if defined(OS_ANDROID)
98 bool got_path = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_dir); 117 bool got_path = PathService::Get(base::DIR_ANDROID_APP_DATA, &pak_dir);
99 DCHECK(got_path); 118 DCHECK(got_path);
100 pak_dir = pak_dir.Append(FILE_PATH_LITERAL("paks")); 119 pak_dir = pak_dir.Append(FILE_PATH_LITERAL("paks"));
101 #else 120 #else
102 PathService::Get(base::DIR_MODULE, &pak_dir); 121 PathService::Get(base::DIR_MODULE, &pak_dir);
103 #endif 122 #endif
104 123
105 pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak")); 124 pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak"));
106 #endif 125 #endif
107 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); 126 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
108 } 127 }
109 128
110 content::ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() { 129 content::ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() {
111 browser_client_.reset(new content::ShellContentBrowserClient); 130 browser_client_.reset(new content::ShellContentBrowserClient);
112 return browser_client_.get(); 131 return browser_client_.get();
113 } 132 }
114 133
115 content::ContentRendererClient* 134 content::ContentRendererClient*
116 ShellMainDelegate::CreateContentRendererClient() { 135 ShellMainDelegate::CreateContentRendererClient() {
117 renderer_client_.reset(new content::ShellContentRendererClient); 136 renderer_client_.reset(new content::ShellContentRendererClient);
118 return renderer_client_.get(); 137 return renderer_client_.get();
119 } 138 }
OLDNEW
« no previous file with comments | « content/shell/shell_content_browser_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698