| OLD | NEW |
| 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 16 matching lines...) Expand all Loading... |
| 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) | 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 |
| 42 #if defined(OS_MACOSX) |
| 37 #include "components/crash/content/app/crashpad.h" | 43 #include "components/crash/content/app/crashpad.h" |
| 38 #endif | 44 #endif |
| 39 | 45 |
| 40 namespace headless { | 46 namespace headless { |
| 41 namespace { | 47 namespace { |
| 42 // Keep in sync with content/common/content_constants_internal.h. | 48 // Keep in sync with content/common/content_constants_internal.h. |
| 43 // TODO(skyostil): Add a tracing test for this. | 49 // TODO(skyostil): Add a tracing test for this. |
| 44 const int kTraceEventBrowserProcessSortIndex = -6; | 50 const int kTraceEventBrowserProcessSortIndex = -6; |
| 45 | 51 |
| 46 HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr; | 52 HeadlessContentMainDelegate* g_current_headless_content_main_delegate = nullptr; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 return g_current_headless_content_main_delegate; | 243 return g_current_headless_content_main_delegate; |
| 238 } | 244 } |
| 239 | 245 |
| 240 // static | 246 // static |
| 241 void HeadlessContentMainDelegate::InitializeResourceBundle() { | 247 void HeadlessContentMainDelegate::InitializeResourceBundle() { |
| 242 base::FilePath dir_module; | 248 base::FilePath dir_module; |
| 243 base::FilePath pak_file; | 249 base::FilePath pak_file; |
| 244 bool result = PathService::Get(base::DIR_MODULE, &dir_module); | 250 bool result = PathService::Get(base::DIR_MODULE, &dir_module); |
| 245 DCHECK(result); | 251 DCHECK(result); |
| 246 | 252 |
| 253 // Override locale pak dir to 'headless_locales'. |
| 254 base::FilePath locale_pak = |
| 255 dir_module.Append(FILE_PATH_LITERAL("headless_locales")); |
| 256 #if defined(OS_MACOSX) |
| 257 base::mac::SetOverrideFrameworkBundlePath(locale_pak); |
| 258 #else |
| 259 PathService::Override(ui::DIR_LOCALES, locale_pak); |
| 260 #endif |
| 261 |
| 247 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 262 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 248 const std::string locale = command_line->GetSwitchValueASCII(switches::kLang); | 263 const std::string locale = command_line->GetSwitchValueASCII(switches::kLang); |
| 249 ui::ResourceBundle::InitSharedInstanceWithLocale( | 264 ui::ResourceBundle::InitSharedInstanceWithLocale( |
| 250 locale, nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); | 265 locale, nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); |
| 251 | 266 |
| 252 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES | 267 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES |
| 253 ResourceBundle::GetSharedInstance().AddDataPackFromBuffer( | 268 ResourceBundle::GetSharedInstance().AddDataPackFromBuffer( |
| 254 base::StringPiece( | 269 base::StringPiece( |
| 255 reinterpret_cast<const char*>(kHeadlessResourcePak.contents), | 270 reinterpret_cast<const char*>(kHeadlessResourcePak.contents), |
| 256 kHeadlessResourcePak.length), | 271 kHeadlessResourcePak.length), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 280 return browser_client_.get(); | 295 return browser_client_.get(); |
| 281 } | 296 } |
| 282 | 297 |
| 283 content::ContentRendererClient* | 298 content::ContentRendererClient* |
| 284 HeadlessContentMainDelegate::CreateContentRendererClient() { | 299 HeadlessContentMainDelegate::CreateContentRendererClient() { |
| 285 renderer_client_ = base::MakeUnique<HeadlessContentRendererClient>(); | 300 renderer_client_ = base::MakeUnique<HeadlessContentRendererClient>(); |
| 286 return renderer_client_.get(); | 301 return renderer_client_.get(); |
| 287 } | 302 } |
| 288 | 303 |
| 289 } // namespace headless | 304 } // namespace headless |
| OLD | NEW |