2013-03-13 19:12:05 +00:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Copyright (c) 2013 Adam Roben <adam@roben.org>. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE-CHROMIUM file.
|
|
|
|
|
2017-05-18 23:53:12 +00:00
|
|
|
#import "brightray/common/main_delegate.h"
|
2013-03-13 19:12:05 +00:00
|
|
|
|
2013-07-17 15:04:45 +00:00
|
|
|
#include "base/command_line.h"
|
2013-03-13 19:12:05 +00:00
|
|
|
#include "base/mac/bundle_locations.h"
|
2017-05-18 22:29:22 +00:00
|
|
|
#include "base/mac/foundation_util.h"
|
2013-03-13 19:12:05 +00:00
|
|
|
#include "base/path_service.h"
|
2013-10-07 19:16:49 +00:00
|
|
|
#include "base/strings/stringprintf.h"
|
2013-07-17 15:04:45 +00:00
|
|
|
#include "base/strings/sys_string_conversions.h"
|
2017-05-18 22:58:12 +00:00
|
|
|
#include "brightray/common/application_info.h"
|
|
|
|
#include "brightray/common/mac/main_application_bundle.h"
|
2013-03-13 19:12:05 +00:00
|
|
|
#include "content/public/common/content_paths.h"
|
2013-07-17 15:04:45 +00:00
|
|
|
#include "content/public/common/content_switches.h"
|
2017-01-17 14:55:28 +00:00
|
|
|
#include "ui/base/resource/resource_bundle.h"
|
2013-03-13 19:12:05 +00:00
|
|
|
|
|
|
|
namespace brightray {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
base::FilePath GetFrameworksPath() {
|
2013-03-14 17:05:01 +00:00
|
|
|
return MainApplicationBundlePath().Append("Contents").Append("Frameworks");
|
2013-03-13 19:12:05 +00:00
|
|
|
}
|
|
|
|
|
2017-01-17 14:55:28 +00:00
|
|
|
base::FilePath GetResourcesPakFilePath(NSString* name) {
|
|
|
|
auto path = [base::mac::FrameworkBundle() pathForResource:name ofType:@"pak"];
|
2013-05-22 15:40:43 +00:00
|
|
|
return base::mac::NSStringToFilePath(path);
|
2013-03-14 13:03:50 +00:00
|
|
|
}
|
|
|
|
|
2017-02-01 14:55:33 +00:00
|
|
|
} // namespace
|
|
|
|
|
2017-01-17 14:55:28 +00:00
|
|
|
void LoadCommonResources() {
|
|
|
|
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
|
|
|
bundle.AddDataPackFromPath(GetResourcesPakFilePath(@"content_shell"),
|
|
|
|
ui::GetSupportedScaleFactors()[0]);
|
2018-03-15 13:57:06 +00:00
|
|
|
#if defined(ENABLE_PDF_VIEWER)
|
2017-01-17 14:55:28 +00:00
|
|
|
bundle.AddDataPackFromPath(GetResourcesPakFilePath(@"pdf_viewer_resources"),
|
|
|
|
ui::GetSupportedScaleFactors()[0]);
|
2018-03-15 13:57:06 +00:00
|
|
|
#endif // defined(ENABLE_PDF_VIEWER)
|
2017-01-17 14:55:28 +00:00
|
|
|
}
|
|
|
|
|
2013-03-13 19:12:05 +00:00
|
|
|
void MainDelegate::OverrideFrameworkBundlePath() {
|
2018-04-20 18:47:04 +00:00
|
|
|
base::FilePath helper_path =
|
|
|
|
GetFrameworksPath().Append(GetApplicationName() + " Framework.framework");
|
2013-03-13 19:12:05 +00:00
|
|
|
|
|
|
|
base::mac::SetOverrideFrameworkBundlePath(helper_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainDelegate::OverrideChildProcessPath() {
|
2018-04-20 18:47:04 +00:00
|
|
|
base::FilePath helper_path = GetFrameworksPath()
|
|
|
|
.Append(GetApplicationName() + " Helper.app")
|
|
|
|
.Append("Contents")
|
|
|
|
.Append("MacOS")
|
|
|
|
.Append(GetApplicationName() + " Helper");
|
2013-03-13 19:12:05 +00:00
|
|
|
|
|
|
|
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
|
|
|
|
}
|
|
|
|
|
2017-02-01 14:55:33 +00:00
|
|
|
} // namespace brightray
|