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

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

Issue 2829973002: add customized printing setting for headless (Closed)
Patch Set: nit change Created 3 years, 8 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 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 <utility> 7 #include <utility>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 15 matching lines...) Expand all
26 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/base/ui_base_switches.h" 27 #include "ui/base/ui_base_switches.h"
28 #include "ui/gfx/switches.h" 28 #include "ui/gfx/switches.h"
29 #include "ui/gl/gl_switches.h" 29 #include "ui/gl/gl_switches.h"
30 #include "ui/ozone/public/ozone_switches.h" 30 #include "ui/ozone/public/ozone_switches.h"
31 31
32 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES 32 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES
33 #include "headless/embedded_resource_pak.h" 33 #include "headless/embedded_resource_pak.h"
34 #endif 34 #endif
35 35
36 #if defined(OS_MACOSX)
37 #include "base/mac/bundle_locations.h"
38 #else
39 #include "ui/base/ui_base_paths.h"
40 #endif
41
36 namespace headless { 42 namespace headless {
37 namespace { 43 namespace {
38 // Keep in sync with content/common/content_constants_internal.h. 44 // Keep in sync with content/common/content_constants_internal.h.
39 // TODO(skyostil): Add a tracing test for this. 45 // TODO(skyostil): Add a tracing test for this.
40 const int kTraceEventBrowserProcessSortIndex = -6; 46 const int kTraceEventBrowserProcessSortIndex = -6;
41 47
42 HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr; 48 HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr;
43 49
44 base::LazyInstance<HeadlessCrashReporterClient>::Leaky g_headless_crash_client = 50 base::LazyInstance<HeadlessCrashReporterClient>::Leaky g_headless_crash_client =
45 LAZY_INSTANCE_INITIALIZER; 51 LAZY_INSTANCE_INITIALIZER;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 return g_current_headless_content_main_delegate; 240 return g_current_headless_content_main_delegate;
235 } 241 }
236 242
237 // static 243 // static
238 void HeadlessContentMainDelegate::InitializeResourceBundle() { 244 void HeadlessContentMainDelegate::InitializeResourceBundle() {
239 base::FilePath dir_module; 245 base::FilePath dir_module;
240 base::FilePath pak_file; 246 base::FilePath pak_file;
241 bool result = PathService::Get(base::DIR_MODULE, &dir_module); 247 bool result = PathService::Get(base::DIR_MODULE, &dir_module);
242 DCHECK(result); 248 DCHECK(result);
243 249
250 // Override locale pak dir to 'headless_locales'.
251 base::FilePath locale_pak =
252 dir_module.AppendASCII(FILE_PATH_LITERAL("headless_locales"));
Lei Zhang 2017/04/20 08:35:58 AppendASCII and FILE_PATH_LITERAL should never be
jzfeng 2017/04/27 06:56:07 Done. Headless chrome is about to be enabled on Wi
253 #if defined(OS_MACOSX)
254 base::mac::SetOverrideFrameworkBundlePath(locale_pak);
255 #else
256 PathService::Override(ui::DIR_LOCALES, locale_pak);
257 #endif
258
244 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 259 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
245 const std::string locale = command_line->GetSwitchValueASCII(switches::kLang); 260 const std::string locale = command_line->GetSwitchValueASCII(switches::kLang);
246 ui::ResourceBundle::InitSharedInstanceWithLocale( 261 ui::ResourceBundle::InitSharedInstanceWithLocale(
247 locale, nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); 262 locale, nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
248 263
249 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES 264 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES
250 ResourceBundle::GetSharedInstance().AddDataPackFromBuffer( 265 ResourceBundle::GetSharedInstance().AddDataPackFromBuffer(
251 base::StringPiece( 266 base::StringPiece(
252 reinterpret_cast<const char*>(kHeadlessResourcePak.contents), 267 reinterpret_cast<const char*>(kHeadlessResourcePak.contents),
253 kHeadlessResourcePak.length), 268 kHeadlessResourcePak.length),
(...skipping 23 matching lines...) Expand all
277 return browser_client_.get(); 292 return browser_client_.get();
278 } 293 }
279 294
280 content::ContentRendererClient* 295 content::ContentRendererClient*
281 HeadlessContentMainDelegate::CreateContentRendererClient() { 296 HeadlessContentMainDelegate::CreateContentRendererClient() {
282 renderer_client_ = base::MakeUnique<HeadlessContentRendererClient>(); 297 renderer_client_ = base::MakeUnique<HeadlessContentRendererClient>();
283 return renderer_client_.get(); 298 return renderer_client_.get();
284 } 299 }
285 300
286 } // namespace headless 301 } // namespace headless
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698