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

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

Issue 151893002: Reorganize apps/shell into app, browser and common directories (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (subdirs) Created 6 years, 10 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 | « apps/shell/shell_main_delegate.h ('k') | apps/shell/web_view_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "apps/shell/shell_main_delegate.h"
6
7 #include "apps/shell/renderer/shell_content_renderer_client.h"
8 #include "apps/shell/shell_content_browser_client.h"
9 #include "apps/shell/shell_content_client.h"
10 #include "base/command_line.h"
11 #include "base/files/file_path.h"
12 #include "base/logging.h"
13 #include "base/path_service.h"
14 #include "chrome/common/chrome_paths.h"
15 #include "content/public/browser/browser_main_runner.h"
16 #include "content/public/common/content_switches.h"
17 #include "extensions/common/extension_paths.h"
18 #include "ui/base/resource/resource_bundle.h"
19
20 #if defined(OS_CHROMEOS)
21 #include "chromeos/chromeos_paths.h"
22 #endif
23
24 namespace {
25
26 void InitLogging() {
27 base::FilePath log_filename;
28 PathService::Get(base::DIR_EXE, &log_filename);
29 log_filename = log_filename.AppendASCII("app_shell.log");
30 logging::LoggingSettings settings;
31 settings.logging_dest = logging::LOG_TO_ALL;
32 settings.log_file = log_filename.value().c_str();
33 settings.delete_old = logging::DELETE_OLD_LOG_FILE;
34 logging::InitLogging(settings);
35 logging::SetLogItems(true, true, true, true);
36 }
37
38 } // namespace
39
40 namespace apps {
41
42 ShellMainDelegate::ShellMainDelegate() {
43 }
44
45 ShellMainDelegate::~ShellMainDelegate() {
46 }
47
48 bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
49 InitLogging();
50 content_client_.reset(new ShellContentClient);
51 SetContentClient(content_client_.get());
52
53 chrome::RegisterPathProvider();
54 #if defined(OS_CHROMEOS)
55 chromeos::RegisterPathProvider();
56 #endif
57 extensions::RegisterPathProvider();
58 return false;
59 }
60
61 void ShellMainDelegate::PreSandboxStartup() {
62 std::string process_type =
63 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
64 switches::kProcessType);
65 if (ProcessNeedsResourceBundle(process_type))
66 InitializeResourceBundle();
67 }
68
69 content::ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() {
70 browser_client_.reset(new apps::ShellContentBrowserClient);
71 return browser_client_.get();
72 }
73
74 content::ContentRendererClient*
75 ShellMainDelegate::CreateContentRendererClient() {
76 renderer_client_.reset(new ShellContentRendererClient);
77 return renderer_client_.get();
78 }
79
80 // static
81 bool ShellMainDelegate::ProcessNeedsResourceBundle(
82 const std::string& process_type) {
83 // The browser process has no process type flag, but needs resources.
84 // On Linux the zygote process opens the resources for the renderers.
85 return process_type.empty() ||
86 process_type == switches::kZygoteProcess ||
87 process_type == switches::kRendererProcess ||
88 process_type == switches::kUtilityProcess;
89 }
90
91 void ShellMainDelegate::InitializeResourceBundle() {
92 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL);
93
94 // The extensions system needs manifest data from the Chrome PAK file.
95 // TODO(jamescook): app_shell needs its own manifest data file.
96 base::FilePath resources_pack_path;
97 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path);
98 ResourceBundle::GetSharedInstance().AddDataPackFromPath(
99 resources_pack_path, ui::SCALE_FACTOR_NONE);
100 }
101
102 } // namespace apps
OLDNEW
« no previous file with comments | « apps/shell/shell_main_delegate.h ('k') | apps/shell/web_view_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698