cast_main_delegate.cc revision 03b57e008b61dfcb1fbad3aea950ae0e001748b0
1// Copyright 2014 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 "chromecast/shell/app/cast_main_delegate.h"
6
7#include "base/logging.h"
8#include "base/path_service.h"
9#include "chromecast/common/cast_paths.h"
10#include "chromecast/common/cast_resource_delegate.h"
11#include "chromecast/shell/browser/cast_content_browser_client.h"
12#include "chromecast/shell/renderer/cast_content_renderer_client.h"
13#include "content/public/common/content_switches.h"
14#include "ui/base/resource/resource_bundle.h"
15
16namespace chromecast {
17namespace shell {
18
19CastMainDelegate::CastMainDelegate() {
20}
21
22CastMainDelegate::~CastMainDelegate() {
23}
24
25bool CastMainDelegate::BasicStartupComplete(int* exit_code) {
26  logging::LoggingSettings settings;
27  settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
28  logging::InitLogging(settings);
29  // Time, process, and thread ID are available through logcat.
30  logging::SetLogItems(true, true, false, false);
31
32  RegisterPathProvider();
33
34  content::SetContentClient(&content_client_);
35  return false;
36}
37
38void CastMainDelegate::PreSandboxStartup() {
39  InitializeResourceBundle();
40}
41
42void CastMainDelegate::ZygoteForked() {
43}
44
45void CastMainDelegate::InitializeResourceBundle() {
46  resource_delegate_.reset(new CastResourceDelegate());
47  // TODO(gunsch): Use LOAD_COMMON_RESOURCES once ResourceBundle no longer
48  // hardcodes resource file names.
49  ui::ResourceBundle::InitSharedInstanceWithLocale(
50      "en-US",
51      resource_delegate_.get(),
52      ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
53
54  base::FilePath pak_file;
55  CHECK(PathService::Get(FILE_CAST_PAK, &pak_file));
56  ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
57      pak_file,
58      ui::SCALE_FACTOR_NONE);
59}
60
61content::ContentBrowserClient* CastMainDelegate::CreateContentBrowserClient() {
62  browser_client_.reset(new CastContentBrowserClient);
63  return browser_client_.get();
64}
65
66content::ContentRendererClient*
67CastMainDelegate::CreateContentRendererClient() {
68  renderer_client_.reset(new CastContentRendererClient);
69  return renderer_client_.get();
70}
71
72}  // namespace shell
73}  // namespace chromecast
74