Skip to content

Commit

Permalink
refactor: eliminate brightray
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak committed Oct 23, 2018
1 parent 465dee2 commit c855466
Show file tree
Hide file tree
Showing 47 changed files with 179 additions and 235 deletions.
7 changes: 0 additions & 7 deletions .gitignore
Expand Up @@ -16,13 +16,6 @@
*.vcxproj.user
*.xcodeproj
/.idea/
/brightray/brightray.opensdf
/brightray/brightray.sdf
/brightray/brightray.sln
/brightray/brightray.suo
/brightray/brightray.v12.suo
/brightray/brightray.vcxproj*
/brightray/brightray.xcodeproj/
/dist/
/external_binaries/
/out/
Expand Down
7 changes: 6 additions & 1 deletion BUILD.gn
Expand Up @@ -4,6 +4,7 @@ import("buildflags/buildflags.gni")
import("electron_paks.gni")
import("filenames.gni")
import("//build/config/locales.gni")
import("//build/config/ui.gni")
import("//build/config/win/manifest.gni")
import("//pdf/features.gni")
import("//services/service_manager/public/service_manifest.gni")
Expand Down Expand Up @@ -201,11 +202,11 @@ static_library("electron_lib") {

deps = [
":atom_js2c",
"brightray",
"buildflags",
"chromium_src:chrome",
"native_mate",
"//base",
"//base:base_static",
"//base:i18n",
"//chrome/common",
"//components/certificate_transparency",
Expand All @@ -214,11 +215,15 @@ static_library("electron_lib") {
"//components/prefs",
"//components/viz/service",
"//content/public/app:both",
"//content/public/browser",
"//content/public/child",
"//content/public/common:service_names",
"//content/shell:copy_shell_resources",
"//gin",
"//media/mojo/interfaces",
"//net:extras",
"//net:net_resources",
"//net:net_with_v8",
"//ppapi/host",
"//ppapi/proxy",
"//ppapi/shared_impl",
Expand Down
4 changes: 2 additions & 2 deletions atom/app/atom_library_main.mm
Expand Up @@ -7,11 +7,11 @@
#include "atom/app/atom_main_delegate.h"
#include "atom/app/node_main.h"
#include "atom/common/atom_command_line.h"
#include "atom/common/mac/main_application_bundle.h"
#include "base/at_exit.h"
#include "base/i18n/icu_util.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "brightray/common/mac/main_application_bundle.h"
#include "content/public/app/content_main.h"

int AtomMain(int argc, char* argv[]) {
Expand All @@ -28,7 +28,7 @@ int AtomInitializeICUandStartNode(int argc, char* argv[]) {
base::AtExitManager atexit_manager;
base::mac::ScopedNSAutoreleasePool pool;
base::mac::SetOverrideFrameworkBundlePath(
brightray::MainApplicationBundlePath()
atom::MainApplicationBundlePath()
.Append("Contents")
.Append("Frameworks")
.Append(ATOM_PRODUCT_NAME " Framework.framework"));
Expand Down
13 changes: 5 additions & 8 deletions atom/app/atom_main_delegate_mac.mm
Expand Up @@ -5,25 +5,23 @@
#include "atom/app/atom_main_delegate.h"

#include "atom/browser/mac/atom_application.h"
#include "atom/common/application_info.h"
#include "atom/common/mac/main_application_bundle.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/path_service.h"
#include "base/strings/sys_string_conversions.h"
#include "brightray/common/application_info.h"
#include "brightray/common/mac/main_application_bundle.h"
#include "content/public/common/content_paths.h"

namespace atom {

namespace {

base::FilePath GetFrameworksPath() {
return brightray::MainApplicationBundlePath()
.Append("Contents")
.Append("Frameworks");
return MainApplicationBundlePath().Append("Contents").Append("Frameworks");
}

base::FilePath GetHelperAppPath(const base::FilePath& frameworks_path,
Expand All @@ -46,16 +44,15 @@
base::FilePath helper_path =
GetHelperAppPath(frameworks_path, ATOM_PRODUCT_NAME);
if (!base::PathExists(helper_path))
helper_path =
GetHelperAppPath(frameworks_path, brightray::GetApplicationName());
helper_path = GetHelperAppPath(frameworks_path, GetApplicationName());
if (!base::PathExists(helper_path))
LOG(FATAL) << "Unable to find helper app";
base::PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
}

void AtomMainDelegate::SetUpBundleOverrides() {
base::mac::ScopedNSAutoreleasePool pool;
NSBundle* bundle = brightray::MainApplicationBundle();
NSBundle* bundle = MainApplicationBundle();
std::string base_bundle_id =
base::SysNSStringToUTF8([bundle bundleIdentifier]);
NSString* team_id = [bundle objectForInfoDictionaryKey:@"ElectronTeamID"];
Expand Down
14 changes: 7 additions & 7 deletions atom/browser/api/atom_api_app.cc
Expand Up @@ -13,6 +13,7 @@
#include "atom/browser/api/gpuinfo_manager.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/atom_paths.h"
#include "atom/browser/login_handler.h"
#include "atom/browser/relauncher.h"
#include "atom/common/atom_command_line.h"
Expand All @@ -31,7 +32,6 @@
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/sys_info.h"
#include "brightray/browser/brightray_paths.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/icon_manager.h"
#include "chrome/common/chrome_paths.h"
Expand Down Expand Up @@ -395,15 +395,15 @@ IconLoader::IconSize GetIconSizeByString(const std::string& size) {
// Return the path constant from string.
int GetPathConstant(const std::string& name) {
if (name == "appData")
return brightray::DIR_APP_DATA;
return DIR_APP_DATA;
else if (name == "userData")
return brightray::DIR_USER_DATA;
return DIR_USER_DATA;
else if (name == "cache")
return brightray::DIR_CACHE;
return DIR_CACHE;
else if (name == "userCache")
return brightray::DIR_USER_CACHE;
return DIR_USER_CACHE;
else if (name == "logs")
return brightray::DIR_APP_LOGS;
return DIR_APP_LOGS;
else if (name == "home")
return base::DIR_HOME;
else if (name == "temp")
Expand Down Expand Up @@ -898,7 +898,7 @@ bool App::RequestSingleInstanceLock() {
return true;

base::FilePath user_dir;
base::PathService::Get(brightray::DIR_USER_DATA, &user_dir);
base::PathService::Get(DIR_USER_DATA, &user_dir);

auto cb = base::Bind(&App::OnSecondInstance, base::Unretained(this));

Expand Down
13 changes: 6 additions & 7 deletions atom/browser/atom_browser_context.cc
Expand Up @@ -9,6 +9,7 @@
#include "atom/browser/atom_blob_reader.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/atom_download_manager_delegate.h"
#include "atom/browser/atom_paths.h"
#include "atom/browser/atom_permission_manager.h"
#include "atom/browser/browser.h"
#include "atom/browser/cookie_change_notifier.h"
Expand All @@ -18,6 +19,7 @@
#include "atom/browser/ui/inspectable_web_contents_impl.h"
#include "atom/browser/web_view_manager.h"
#include "atom/browser/zoom_level_delegate.h"
#include "atom/common/application_info.h"
#include "atom/common/atom_version.h"
#include "atom/common/chrome_version.h"
#include "atom/common/options_switches.h"
Expand All @@ -28,8 +30,6 @@
#include "base/strings/stringprintf.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread_restrictions.h"
#include "brightray/browser/brightray_paths.h"
#include "brightray/common/application_info.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
Expand Down Expand Up @@ -100,11 +100,10 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
base::StringToInt(command_line->GetSwitchValueASCII(switches::kDiskCacheSize),
&max_cache_size_);

if (!base::PathService::Get(brightray::DIR_USER_DATA, &path_)) {
base::PathService::Get(brightray::DIR_APP_DATA, &path_);
path_ = path_.Append(
base::FilePath::FromUTF8Unsafe(brightray::GetApplicationName()));
base::PathService::Override(brightray::DIR_USER_DATA, path_);
if (!base::PathService::Get(DIR_USER_DATA, &path_)) {
base::PathService::Get(DIR_APP_DATA, &path_);
path_ = path_.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName()));
base::PathService::Override(DIR_USER_DATA, path_);
}

if (!in_memory && !partition.empty())
Expand Down
15 changes: 7 additions & 8 deletions atom/browser/atom_browser_main_parts.cc
Expand Up @@ -15,6 +15,7 @@
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_paths.h"
#include "atom/browser/atom_web_ui_controller_factory.h"
#include "atom/browser/browser.h"
#include "atom/browser/io_thread.h"
Expand All @@ -23,6 +24,7 @@
#include "atom/browser/node_debugger.h"
#include "atom/browser/ui/devtools_manager_delegate.h"
#include "atom/common/api/atom_bindings.h"
#include "atom/common/application_info.h"
#include "atom/common/asar/asar_util.h"
#include "atom/common/node_bindings.h"
#include "base/base_switches.h"
Expand All @@ -32,8 +34,6 @@
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "brightray/browser/brightray_paths.h"
#include "brightray/common/application_info.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/icon_manager.h"
#include "chrome/browser/net/chrome_net_log_helper.h"
Expand Down Expand Up @@ -139,12 +139,12 @@ const int kWaitForUIThreadSeconds = 10;

void OverrideLinuxAppDataPath() {
base::FilePath path;
if (base::PathService::Get(brightray::DIR_APP_DATA, &path))
if (base::PathService::Get(DIR_APP_DATA, &path))
return;
std::unique_ptr<base::Environment> env(base::Environment::Create());
path = base::nix::GetXDGDirectory(env.get(), base::nix::kXdgConfigHomeEnvVar,
base::nix::kDotConfigDir);
base::PathService::Override(brightray::DIR_APP_DATA, path);
base::PathService::Override(DIR_APP_DATA, path);
}

int BrowserX11ErrorHandler(Display* d, XErrorEvent* error) {
Expand Down Expand Up @@ -224,11 +224,10 @@ void AtomBrowserMainParts::InitializeFeatureList() {
#if !defined(OS_MACOSX)
void AtomBrowserMainParts::OverrideAppLogsPath() {
base::FilePath path;
if (base::PathService::Get(brightray::DIR_APP_DATA, &path)) {
path = path.Append(
base::FilePath::FromUTF8Unsafe(brightray::GetApplicationName()));
if (base::PathService::Get(DIR_APP_DATA, &path)) {
path = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName()));
path = path.Append(base::FilePath::FromUTF8Unsafe("logs"));
base::PathService::Override(brightray::DIR_APP_LOGS, path);
base::PathService::Override(DIR_APP_LOGS, path);
}
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions atom/browser/atom_browser_main_parts_mac.mm
Expand Up @@ -4,11 +4,11 @@

#include "atom/browser/atom_browser_main_parts.h"

#include "atom/browser/atom_paths.h"
#include "atom/browser/mac/atom_application_delegate.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/foundation_util.h"
#include "base/path_service.h"
#include "brightray/browser/brightray_paths.h"
#include "ui/base/l10n/l10n_util_mac.h"

namespace atom {
Expand Down Expand Up @@ -41,7 +41,7 @@
NSString* libraryPath =
[NSHomeDirectory() stringByAppendingPathComponent:logsPath];

base::PathService::Override(brightray::DIR_APP_LOGS,
base::PathService::Override(DIR_APP_LOGS,
base::FilePath([libraryPath UTF8String]));
}

Expand Down
Expand Up @@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BRIGHTRAY_BROWSER_BRIGHTRAY_PATHS_H_
#define BRIGHTRAY_BROWSER_BRIGHTRAY_PATHS_H_
#ifndef ATOM_BROWSER_ATOM_PATHS_H_
#define ATOM_BROWSER_ATOM_PATHS_H_

#include "base/base_paths.h"

#if defined(OS_WIN)
#include "base/base_paths_win.h"
Expand All @@ -15,7 +17,7 @@
#include "base/base_paths_posix.h"
#endif

namespace brightray {
namespace atom {

enum {
PATH_START = 11000,
Expand All @@ -39,6 +41,6 @@ enum {
PATH_END
};

} // namespace brightray
} // namespace atom

#endif // BRIGHTRAY_BROWSER_BRIGHTRAY_PATHS_H_
#endif // ATOM_BROWSER_ATOM_PATHS_H_
14 changes: 7 additions & 7 deletions atom/browser/browser.cc
Expand Up @@ -9,19 +9,19 @@
#include <utility>

#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/atom_paths.h"
#include "atom/browser/browser_observer.h"
#include "atom/browser/login_handler.h"
#include "atom/browser/native_window.h"
#include "atom/browser/window_list.h"
#include "atom/common/application_info.h"
#include "base/files/file_util.h"
#include "base/message_loop/message_loop.h"
#include "base/no_destructor.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "brightray/browser/brightray_paths.h"
#include "brightray/common/application_info.h"

namespace atom {

Expand Down Expand Up @@ -104,25 +104,25 @@ void Browser::Shutdown() {
}

std::string Browser::GetVersion() const {
std::string ret = brightray::GetOverriddenApplicationVersion();
std::string ret = GetOverriddenApplicationVersion();
if (ret.empty())
ret = GetExecutableFileVersion();
return ret;
}

void Browser::SetVersion(const std::string& version) {
brightray::OverrideApplicationVersion(version);
OverrideApplicationVersion(version);
}

std::string Browser::GetName() const {
std::string ret = brightray::GetOverriddenApplicationName();
std::string ret = GetOverriddenApplicationName();
if (ret.empty())
ret = GetExecutableFileProductName();
return ret;
}

void Browser::SetName(const std::string& name) {
brightray::OverrideApplicationName(name);
OverrideApplicationName(name);
}

int Browser::GetBadgeCount() {
Expand Down Expand Up @@ -156,7 +156,7 @@ void Browser::DidFinishLaunching(const base::DictionaryValue& launch_info) {
// Make sure the userData directory is created.
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::FilePath user_data;
if (base::PathService::Get(brightray::DIR_USER_DATA, &user_data))
if (base::PathService::Get(DIR_USER_DATA, &user_data))
base::CreateDirectoryAndGetError(user_data, nullptr);

is_ready_ = true;
Expand Down

0 comments on commit c855466

Please sign in to comment.