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-07-31 18:08:45 +00:00
|
|
|
#include "browser/browser_client.h"
|
2013-03-13 19:12:05 +00:00
|
|
|
|
2013-07-31 18:08:45 +00:00
|
|
|
#include "browser/browser_context.h"
|
|
|
|
#include "browser/browser_main_parts.h"
|
|
|
|
#include "browser/media/media_capture_devices_dispatcher.h"
|
|
|
|
#include "browser/notification_presenter.h"
|
2013-03-13 19:12:05 +00:00
|
|
|
|
|
|
|
namespace brightray {
|
|
|
|
|
2013-04-18 03:27:53 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
BrowserClient* g_browser_client;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
BrowserClient* BrowserClient::Get() {
|
|
|
|
return g_browser_client;
|
|
|
|
}
|
|
|
|
|
2013-04-24 14:54:53 +00:00
|
|
|
BrowserClient::BrowserClient()
|
|
|
|
: browser_main_parts_() {
|
2013-04-18 03:27:53 +00:00
|
|
|
DCHECK(!g_browser_client);
|
|
|
|
g_browser_client = this;
|
2013-03-13 19:12:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BrowserClient::~BrowserClient() {
|
|
|
|
}
|
|
|
|
|
|
|
|
BrowserContext* BrowserClient::browser_context() {
|
|
|
|
return browser_main_parts_->browser_context();
|
|
|
|
}
|
|
|
|
|
2013-03-28 21:49:29 +00:00
|
|
|
NotificationPresenter* BrowserClient::notification_presenter() {
|
2013-05-21 15:39:25 +00:00
|
|
|
#if defined(OS_MACOSX)
|
2013-03-28 21:49:29 +00:00
|
|
|
if (!notification_presenter_)
|
2013-03-28 22:03:58 +00:00
|
|
|
notification_presenter_.reset(NotificationPresenter::Create());
|
2013-05-21 15:39:25 +00:00
|
|
|
#endif
|
2013-03-28 21:49:29 +00:00
|
|
|
return notification_presenter_.get();
|
|
|
|
}
|
|
|
|
|
2013-03-13 19:12:05 +00:00
|
|
|
BrowserMainParts* BrowserClient::OverrideCreateBrowserMainParts(const content::MainFunctionParams&) {
|
|
|
|
return new BrowserMainParts;
|
|
|
|
}
|
|
|
|
|
|
|
|
content::BrowserMainParts* BrowserClient::CreateBrowserMainParts(const content::MainFunctionParams& parameters) {
|
2013-03-27 12:54:19 +00:00
|
|
|
DCHECK(!browser_main_parts_);
|
|
|
|
browser_main_parts_ = OverrideCreateBrowserMainParts(parameters);
|
|
|
|
return browser_main_parts_;
|
2013-03-13 19:12:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
net::URLRequestContextGetter* BrowserClient::CreateRequestContext(content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers) {
|
|
|
|
return static_cast<BrowserContext*>(browser_context)->CreateRequestContext(protocol_handlers);
|
|
|
|
}
|
|
|
|
|
2013-03-28 21:49:29 +00:00
|
|
|
void BrowserClient::ShowDesktopNotification(
|
|
|
|
const content::ShowDesktopNotificationHostMsgParams& params,
|
|
|
|
int render_process_id,
|
|
|
|
int render_view_id,
|
|
|
|
bool worker) {
|
2013-05-31 12:05:14 +00:00
|
|
|
auto presenter = notification_presenter();
|
|
|
|
if (!presenter)
|
|
|
|
return;
|
|
|
|
presenter->ShowNotification(params, render_process_id, render_view_id);
|
2013-03-28 21:49:29 +00:00
|
|
|
}
|
|
|
|
|
2013-03-29 13:36:07 +00:00
|
|
|
void BrowserClient::CancelDesktopNotification(
|
|
|
|
int render_process_id,
|
|
|
|
int render_view_id,
|
|
|
|
int notification_id) {
|
2013-05-31 12:05:14 +00:00
|
|
|
auto presenter = notification_presenter();
|
|
|
|
if (!presenter)
|
|
|
|
return;
|
|
|
|
presenter->CancelNotification(render_process_id, render_view_id, notification_id);
|
2013-03-29 13:36:07 +00:00
|
|
|
}
|
|
|
|
|
2013-07-31 18:08:45 +00:00
|
|
|
content::MediaObserver* BrowserClient::GetMediaObserver() {
|
|
|
|
return MediaCaptureDevicesDispatcher::GetInstance();
|
|
|
|
}
|
|
|
|
|
2013-03-13 19:12:05 +00:00
|
|
|
}
|