| 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 "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 ui::ResourceBundle::InitSharedInstanceWithLocale( | 243 ui::ResourceBundle::InitSharedInstanceWithLocale( |
| 244 locale, nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); | 244 locale, nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES); |
| 245 | 245 |
| 246 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES | 246 #ifdef HEADLESS_USE_EMBEDDED_RESOURCES |
| 247 ResourceBundle::GetSharedInstance().AddDataPackFromBuffer( | 247 ResourceBundle::GetSharedInstance().AddDataPackFromBuffer( |
| 248 base::StringPiece( | 248 base::StringPiece( |
| 249 reinterpret_cast<const char*>(kHeadlessResourcePak.contents), | 249 reinterpret_cast<const char*>(kHeadlessResourcePak.contents), |
| 250 kHeadlessResourcePak.length), | 250 kHeadlessResourcePak.length), |
| 251 ui::SCALE_FACTOR_NONE); | 251 ui::SCALE_FACTOR_NONE); |
| 252 #else | 252 #else |
| 253 #if defined(OS_MACOSX) && !defined(COMPONENT_BUILD) | |
| 254 dir_module = dir_module.Append(FILE_PATH_LITERAL("Resources/")); | |
| 255 #endif | |
| 256 // Try loading the headless library pak file first. If it doesn't exist (i.e., | 253 // Try loading the headless library pak file first. If it doesn't exist (i.e., |
| 257 // when we're running with the --headless switch), fall back to the browser's | 254 // when we're running with the --headless switch), fall back to the browser's |
| 258 // resource pak. | 255 // resource pak. |
| 259 pak_file = dir_module.Append(FILE_PATH_LITERAL("headless_lib.pak")); | 256 pak_file = dir_module.Append(FILE_PATH_LITERAL("headless_lib.pak")); |
| 260 if (!base::PathExists(pak_file)) | 257 if (!base::PathExists(pak_file)) |
| 261 pak_file = dir_module.Append(FILE_PATH_LITERAL("resources.pak")); | 258 pak_file = dir_module.Append(FILE_PATH_LITERAL("resources.pak")); |
| 259 #if defined(OS_MACOSX) && !defined(COMPONENT_BUILD) |
| 260 // In non component builds, check if fall back in Resources/ folder is |
| 261 // available. |
| 262 if (!base::PathExists(pak_file)) |
| 263 pak_file = dir_module.Append(FILE_PATH_LITERAL("Resources/resources.pak")); |
| 264 #endif |
| 262 ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 265 ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| 263 pak_file, ui::SCALE_FACTOR_NONE); | 266 pak_file, ui::SCALE_FACTOR_NONE); |
| 264 #endif | 267 #endif |
| 265 } | 268 } |
| 266 | 269 |
| 267 content::ContentBrowserClient* | 270 content::ContentBrowserClient* |
| 268 HeadlessContentMainDelegate::CreateContentBrowserClient() { | 271 HeadlessContentMainDelegate::CreateContentBrowserClient() { |
| 269 browser_client_.reset(new HeadlessContentBrowserClient(browser_.get())); | 272 browser_client_.reset(new HeadlessContentBrowserClient(browser_.get())); |
| 270 return browser_client_.get(); | 273 return browser_client_.get(); |
| 271 } | 274 } |
| 272 | 275 |
| 273 } // namespace headless | 276 } // namespace headless |
| OLD | NEW |