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

Side by Side Diff: headless/lib/headless_content_main_delegate.cc

Issue 2576413002: chrome: Include headless resources (Closed)
Patch Set: Add TODO Created 4 years 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
« no previous file with comments | « headless/BUILD.gn ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "headless/lib/headless_content_main_delegate.h" 5 #include "headless/lib/headless_content_main_delegate.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_util.h"
8 #include "base/path_service.h" 9 #include "base/path_service.h"
9 #include "base/run_loop.h" 10 #include "base/run_loop.h"
10 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
11 #include "content/public/browser/browser_main_runner.h" 12 #include "content/public/browser/browser_main_runner.h"
12 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
13 #include "headless/lib/browser/headless_browser_impl.h" 14 #include "headless/lib/browser/headless_browser_impl.h"
14 #include "headless/lib/browser/headless_content_browser_client.h" 15 #include "headless/lib/browser/headless_content_browser_client.h"
15 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/switches.h" 17 #include "ui/gfx/switches.h"
17 #include "ui/gl/gl_switches.h" 18 #include "ui/gl/gl_switches.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // TODO(skyostil): Disable the zygote host. 103 // TODO(skyostil): Disable the zygote host.
103 } 104 }
104 105
105 // static 106 // static
106 HeadlessContentMainDelegate* HeadlessContentMainDelegate::GetInstance() { 107 HeadlessContentMainDelegate* HeadlessContentMainDelegate::GetInstance() {
107 return g_current_headless_content_main_delegate; 108 return g_current_headless_content_main_delegate;
108 } 109 }
109 110
110 // static 111 // static
111 void HeadlessContentMainDelegate::InitializeResourceBundle() { 112 void HeadlessContentMainDelegate::InitializeResourceBundle() {
113 base::FilePath dir_module;
112 base::FilePath pak_file; 114 base::FilePath pak_file;
113 bool result = PathService::Get(base::DIR_MODULE, &pak_file); 115 bool result = PathService::Get(base::DIR_MODULE, &dir_module);
114 DCHECK(result); 116 DCHECK(result);
115 pak_file = pak_file.Append(FILE_PATH_LITERAL("headless_lib.pak")); 117 // Try loading the headless library pak file first. If it doesn't exist (i.e.,
118 // when we're running with the --headless switch), fall back to the browser's
119 // resource pak.
120 pak_file = dir_module.Append(FILE_PATH_LITERAL("headless_lib.pak"));
121 if (!base::PathExists(pak_file))
122 pak_file = dir_module.Append(FILE_PATH_LITERAL("resources.pak"));
123 // TODO(skyostil): Use the locale-based loader instead.
116 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); 124 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
117 } 125 }
118 126
119 content::ContentBrowserClient* 127 content::ContentBrowserClient*
120 HeadlessContentMainDelegate::CreateContentBrowserClient() { 128 HeadlessContentMainDelegate::CreateContentBrowserClient() {
121 browser_client_.reset(new HeadlessContentBrowserClient(browser_.get())); 129 browser_client_.reset(new HeadlessContentBrowserClient(browser_.get()));
122 return browser_client_.get(); 130 return browser_client_.get();
123 } 131 }
124 132
125 } // namespace headless 133 } // namespace headless
OLDNEW
« no previous file with comments | « headless/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698