electron/brightray/common/main_delegate.cc

61 lines
1.6 KiB
C++
Raw Normal View History

2013-03-13 19:12:05 +00:00
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-CHROMIUM file.
#include "common/main_delegate.h"
#include "browser/browser_client.h"
#include "common/content_client.h"
2013-03-13 19:12:05 +00:00
#include "base/command_line.h"
2013-05-22 15:40:43 +00:00
#include "base/path_service.h"
2013-03-13 19:12:05 +00:00
#include "content/public/common/content_switches.h"
2013-05-22 15:40:43 +00:00
#include "ui/base/resource/resource_bundle.h"
2013-03-13 19:12:05 +00:00
namespace brightray {
MainDelegate::MainDelegate() {
2013-03-13 19:12:05 +00:00
}
MainDelegate::~MainDelegate() {
}
scoped_ptr<ContentClient> MainDelegate::CreateContentClient() {
return make_scoped_ptr(new ContentClient).Pass();
}
bool MainDelegate::BasicStartupComplete(int* exit_code) {
content_client_ = CreateContentClient().Pass();
SetContentClient(content_client_.get());
return false;
}
2013-03-13 19:12:05 +00:00
void MainDelegate::PreSandboxStartup() {
#if defined(OS_MACOSX)
OverrideChildProcessPath();
OverrideFrameworkBundlePath();
SetProcessName();
2013-05-22 15:40:43 +00:00
#endif
InitializeResourceBundle();
2013-05-22 15:40:43 +00:00
}
void MainDelegate::InitializeResourceBundle() {
base::FilePath path;
#if defined(OS_MACOSX)
path = GetResourcesPakFilePath();
#else
base::FilePath pak_dir;
PathService::Get(base::DIR_MODULE, &pak_dir);
path = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak"));
#endif
2013-05-22 15:40:43 +00:00
ui::ResourceBundle::InitSharedInstanceWithPakPath(path);
std::vector<base::FilePath> pak_paths;
AddPakPaths(&pak_paths);
for (auto it = pak_paths.begin(), end = pak_paths.end(); it != end; ++it)
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(*it, ui::SCALE_FACTOR_NONE);
2013-03-13 19:12:05 +00:00
}
}