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.
|
|
|
|
|
2013-03-14 13:03:50 +00:00
|
|
|
#include "browser/browser_main_parts.h"
|
2013-03-13 19:12:05 +00:00
|
|
|
|
2013-03-14 13:03:50 +00:00
|
|
|
#include "browser/browser_context.h"
|
2013-05-14 06:45:34 +00:00
|
|
|
#include "browser/web_ui_controller_factory.h"
|
2013-12-05 10:56:28 +00:00
|
|
|
#include "net/proxy/proxy_resolver_v8.h"
|
2013-03-14 13:03:50 +00:00
|
|
|
|
2014-07-03 09:04:03 +00:00
|
|
|
#if defined(USE_AURA)
|
2014-07-03 16:12:05 +00:00
|
|
|
#include "ui/aura/env.h"
|
2014-07-03 09:04:03 +00:00
|
|
|
#include "ui/gfx/screen.h"
|
|
|
|
#include "ui/views/widget/desktop_aura/desktop_screen.h"
|
|
|
|
#endif
|
|
|
|
|
2014-07-03 08:28:14 +00:00
|
|
|
#if defined(USE_AURA) && defined(USE_X11)
|
|
|
|
#include "chrome/browser/ui/libgtk2ui/gtk2_ui.h"
|
|
|
|
#include "ui/views/linux_ui/linux_ui.h"
|
2014-07-09 12:05:02 +00:00
|
|
|
#include "ui/wm/core/wm_state.h"
|
2014-07-03 08:28:14 +00:00
|
|
|
#endif
|
|
|
|
|
2014-07-03 08:44:58 +00:00
|
|
|
#if defined(TOOLKIT_VIEWS)
|
|
|
|
#include "browser/views/views_delegate.h"
|
|
|
|
#endif
|
|
|
|
|
2014-07-12 11:46:26 +00:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
#include "ui/base/l10n/l10n_util.h"
|
|
|
|
#include "ui/base/l10n/l10n_util_win.h"
|
|
|
|
#include "ui/gfx/platform_font_win.h"
|
|
|
|
#endif
|
|
|
|
|
2013-03-13 19:12:05 +00:00
|
|
|
namespace brightray {
|
|
|
|
|
2014-07-12 11:46:26 +00:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// gfx::Font callbacks
|
|
|
|
void AdjustUIFont(LOGFONT* logfont) {
|
|
|
|
l10n_util::AdjustUIFont(logfont);
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetMinimumFontSize() {
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
#endif
|
|
|
|
|
2013-03-13 19:12:05 +00:00
|
|
|
BrowserMainParts::BrowserMainParts() {
|
|
|
|
}
|
|
|
|
|
|
|
|
BrowserMainParts::~BrowserMainParts() {
|
|
|
|
}
|
|
|
|
|
2014-07-03 08:12:12 +00:00
|
|
|
void BrowserMainParts::PreEarlyInitialization() {
|
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
IncreaseFileDescriptorLimit();
|
|
|
|
#endif
|
2014-07-03 08:28:14 +00:00
|
|
|
|
|
|
|
#if defined(USE_AURA) && defined(USE_X11)
|
|
|
|
views::LinuxUI::SetInstance(BuildGtk2UI());
|
|
|
|
#endif
|
2014-07-03 08:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserMainParts::ToolkitInitialized() {
|
2014-07-03 08:28:14 +00:00
|
|
|
#if defined(USE_AURA) && defined(USE_X11)
|
|
|
|
views::LinuxUI::instance()->Initialize();
|
2014-07-09 12:05:02 +00:00
|
|
|
wm_state_.reset(new wm::WMState);
|
2014-07-03 08:28:14 +00:00
|
|
|
#endif
|
2014-07-03 08:44:58 +00:00
|
|
|
|
|
|
|
#if defined(TOOLKIT_VIEWS)
|
2014-07-04 13:41:22 +00:00
|
|
|
views_delegate_.reset(new ViewsDelegate);
|
2014-07-03 08:44:58 +00:00
|
|
|
#endif
|
2014-07-12 11:46:26 +00:00
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
gfx::PlatformFontWin::adjust_font_callback = &AdjustUIFont;
|
|
|
|
gfx::PlatformFontWin::get_minimum_font_size_callback = &GetMinimumFontSize;
|
|
|
|
#endif
|
2014-07-03 08:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserMainParts::PreMainMessageLoopStart() {
|
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
InitializeMainNib();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-03-13 19:12:05 +00:00
|
|
|
void BrowserMainParts::PreMainMessageLoopRun() {
|
2013-04-02 00:10:00 +00:00
|
|
|
browser_context_.reset(CreateBrowserContext());
|
2013-08-15 20:07:14 +00:00
|
|
|
browser_context_->Initialize();
|
2013-03-14 13:03:50 +00:00
|
|
|
|
2013-11-17 22:51:19 +00:00
|
|
|
web_ui_controller_factory_.reset(
|
|
|
|
new WebUIControllerFactory(browser_context_.get()));
|
|
|
|
content::WebUIControllerFactory::RegisterFactory(
|
|
|
|
web_ui_controller_factory_.get());
|
2013-03-13 19:12:05 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 16:13:24 +00:00
|
|
|
void BrowserMainParts::PostMainMessageLoopRun() {
|
|
|
|
browser_context_.reset();
|
2014-07-03 16:12:05 +00:00
|
|
|
#if defined(USE_AURA)
|
|
|
|
aura::Env::DeleteInstance();
|
|
|
|
#endif
|
2013-10-23 16:13:24 +00:00
|
|
|
}
|
|
|
|
|
2013-12-05 10:56:28 +00:00
|
|
|
int BrowserMainParts::PreCreateThreads() {
|
2014-07-03 09:04:03 +00:00
|
|
|
#if defined(USE_AURA)
|
2014-07-03 16:12:05 +00:00
|
|
|
aura::Env::CreateInstance();
|
2014-07-03 09:04:03 +00:00
|
|
|
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE,
|
|
|
|
views::CreateDesktopScreen());
|
|
|
|
#endif
|
|
|
|
|
2014-07-03 09:18:24 +00:00
|
|
|
InitProxyResolverV8();
|
2013-12-05 10:56:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-02 00:10:00 +00:00
|
|
|
BrowserContext* BrowserMainParts::CreateBrowserContext() {
|
|
|
|
return new BrowserContext;
|
|
|
|
}
|
|
|
|
|
2014-07-03 09:18:24 +00:00
|
|
|
void BrowserMainParts::InitProxyResolverV8() {
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
net::ProxyResolverV8::CreateIsolate();
|
|
|
|
#else
|
|
|
|
net::ProxyResolverV8::RememberDefaultIsolate();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-11-17 22:51:19 +00:00
|
|
|
} // namespace brightray
|