format previously missed chromium_src .cc files

This commit is contained in:
Shelley Vohr 2018-04-17 21:57:05 -04:00
parent 8cc81509d7
commit f7d4437b3f
No known key found for this signature in database
GPG key ID: F13993A75599653C
58 changed files with 688 additions and 898 deletions

View file

@ -68,28 +68,23 @@ net::NSSCertDatabase* GetNSSCertDatabaseForResourceContext(
// callback
// static
void CertificateManagerModel::Create(
content::BrowserContext* browser_context,
const CreationCallback& callback) {
void CertificateManagerModel::Create(content::BrowserContext* browser_context,
const CreationCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
BrowserThread::IO, FROM_HERE,
base::Bind(&CertificateManagerModel::GetCertDBOnIOThread,
browser_context->GetResourceContext(),
callback));
browser_context->GetResourceContext(), callback));
}
CertificateManagerModel::CertificateManagerModel(
net::NSSCertDatabase* nss_cert_database,
bool is_user_db_available)
: cert_db_(nss_cert_database),
is_user_db_available_(is_user_db_available) {
: cert_db_(nss_cert_database), is_user_db_available_(is_user_db_available) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
CertificateManagerModel::~CertificateManagerModel() {
}
CertificateManagerModel::~CertificateManagerModel() {}
int CertificateManagerModel::ImportFromPKCS12(
PK11SlotInfo* slot_info,
@ -97,8 +92,8 @@ int CertificateManagerModel::ImportFromPKCS12(
const base::string16& password,
bool is_extractable,
net::ScopedCERTCertificateList* imported_certs) {
return cert_db_->ImportFromPKCS12(slot_info, data, password,
is_extractable, imported_certs);
return cert_db_->ImportFromPKCS12(slot_info, data, password, is_extractable,
imported_certs);
}
int CertificateManagerModel::ImportUserCert(const std::string& data) {
@ -116,8 +111,7 @@ bool CertificateManagerModel::ImportServerCert(
const net::ScopedCERTCertificateList& certificates,
net::NSSCertDatabase::TrustBits trust_bits,
net::NSSCertDatabase::ImportCertFailureList* not_imported) {
return cert_db_->ImportServerCert(certificates, trust_bits,
not_imported);
return cert_db_->ImportServerCert(certificates, trust_bits, not_imported);
}
bool CertificateManagerModel::SetCertTrust(
@ -138,8 +132,8 @@ void CertificateManagerModel::DidGetCertDBOnUIThread(
const CreationCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::unique_ptr<CertificateManagerModel> model(new CertificateManagerModel(
cert_db, is_user_db_available));
std::unique_ptr<CertificateManagerModel> model(
new CertificateManagerModel(cert_db, is_user_db_available));
callback.Run(std::move(model));
}
@ -151,12 +145,9 @@ void CertificateManagerModel::DidGetCertDBOnIOThread(
bool is_user_db_available = !!cert_db->GetPublicSlot();
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(&CertificateManagerModel::DidGetCertDBOnUIThread,
cert_db,
is_user_db_available,
callback));
BrowserThread::UI, FROM_HERE,
base::Bind(&CertificateManagerModel::DidGetCertDBOnUIThread, cert_db,
is_user_db_available, callback));
}
// static
@ -166,8 +157,7 @@ void CertificateManagerModel::GetCertDBOnIOThread(
DCHECK_CURRENTLY_ON(BrowserThread::IO);
net::NSSCertDatabase* cert_db = GetNSSCertDatabaseForResourceContext(
context,
base::Bind(&CertificateManagerModel::DidGetCertDBOnIOThread,
callback));
base::Bind(&CertificateManagerModel::DidGetCertDBOnIOThread, callback));
if (cert_db)
DidGetCertDBOnIOThread(callback, cert_db);
}

View file

@ -21,7 +21,6 @@
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
namespace {
int timeout_in_milliseconds = 20 * 1000;

View file

@ -23,7 +23,8 @@ GlobalShortcutListener::~GlobalShortcutListener() {
}
bool GlobalShortcutListener::RegisterAccelerator(
const ui::Accelerator& accelerator, Observer* observer) {
const ui::Accelerator& accelerator,
Observer* observer) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (IsShortcutHandlingSuspended())
return false;
@ -48,7 +49,8 @@ bool GlobalShortcutListener::RegisterAccelerator(
}
void GlobalShortcutListener::UnregisterAccelerator(
const ui::Accelerator& accelerator, Observer* observer) {
const ui::Accelerator& accelerator,
Observer* observer) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (IsShortcutHandlingSuspended())
return;
@ -88,8 +90,7 @@ void GlobalShortcutListener::SetShortcutHandlingSuspended(bool suspended) {
shortcut_handling_suspended_ = suspended;
for (AcceleratorMap::iterator it = accelerator_map_.begin();
it != accelerator_map_.end();
++it) {
it != accelerator_map_.end(); ++it) {
// On Linux, when shortcut handling is suspended we cannot simply early
// return in NotifyKeyPressed (similar to what we do for non-global
// shortcuts) because we'd eat the keyboard event thereby preventing the

View file

@ -20,13 +20,11 @@ namespace extensions {
// static
GlobalShortcutListener* GlobalShortcutListener::GetInstance() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
static GlobalShortcutListenerWin* instance =
new GlobalShortcutListenerWin();
static GlobalShortcutListenerWin* instance = new GlobalShortcutListenerWin();
return instance;
}
GlobalShortcutListenerWin::GlobalShortcutListenerWin()
: is_listening_(false) {
GlobalShortcutListenerWin::GlobalShortcutListenerWin() : is_listening_(false) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
@ -36,17 +34,16 @@ GlobalShortcutListenerWin::~GlobalShortcutListenerWin() {
}
void GlobalShortcutListenerWin::StartListening() {
DCHECK(!is_listening_); // Don't start twice.
DCHECK(!is_listening_); // Don't start twice.
DCHECK(!hotkey_ids_.empty()); // Also don't start if no hotkey is registered.
singleton_hwnd_observer_.reset(new gfx::SingletonHwndObserver(
base::Bind(
&GlobalShortcutListenerWin::OnWndProc, base::Unretained(this))));
singleton_hwnd_observer_.reset(new gfx::SingletonHwndObserver(base::Bind(
&GlobalShortcutListenerWin::OnWndProc, base::Unretained(this))));
is_listening_ = true;
}
void GlobalShortcutListenerWin::StopListening() {
DCHECK(is_listening_); // No point if we are not already listening.
DCHECK(is_listening_); // No point if we are not already listening.
DCHECK(hotkey_ids_.empty()); // Make sure the map is clean before ending.
singleton_hwnd_observer_.reset(nullptr);
is_listening_ = false;
@ -66,8 +63,8 @@ void GlobalShortcutListenerWin::OnWndProc(HWND hwnd,
modifiers |= (LOWORD(lparam) & MOD_CONTROL) ? ui::EF_CONTROL_DOWN : 0;
modifiers |= (LOWORD(lparam) & MOD_WIN) ? ui::EF_COMMAND_DOWN : 0;
ui::Accelerator accelerator(
ui::KeyboardCodeForWindowsKeyCode(key_code), modifiers);
ui::Accelerator accelerator(ui::KeyboardCodeForWindowsKeyCode(key_code),
modifiers);
NotifyKeyPressed(accelerator);
}
@ -83,11 +80,8 @@ bool GlobalShortcutListenerWin::RegisterAcceleratorImpl(
modifiers |= accelerator.IsCmdDown() ? MOD_WIN : 0;
static int hotkey_id = 0;
bool success = !!RegisterHotKey(
gfx::SingletonHwnd::GetInstance()->hwnd(),
hotkey_id,
modifiers,
accelerator.key_code());
bool success = !!RegisterHotKey(gfx::SingletonHwnd::GetInstance()->hwnd(),
hotkey_id, modifiers, accelerator.key_code());
if (!success) {
// Most likely error: 1409 (Hotkey already registered).
@ -103,8 +97,8 @@ void GlobalShortcutListenerWin::UnregisterAcceleratorImpl(
HotkeyIdMap::iterator it = hotkey_ids_.find(accelerator);
DCHECK(it != hotkey_ids_.end());
bool success = !!UnregisterHotKey(
gfx::SingletonHwnd::GetInstance()->hwnd(), it->second);
bool success =
!!UnregisterHotKey(gfx::SingletonHwnd::GetInstance()->hwnd(), it->second);
// This call should always succeed, as long as we pass in the right HWND and
// an id we've used to register before.
DCHECK(success);

View file

@ -22,16 +22,14 @@ namespace {
// exact modifiers, we need to grab all key combination including zero or more
// of the following: Num lock, Caps lock and Scroll lock. So that we can make
// sure the behavior of global shortcuts is consistent on all platforms.
const unsigned int kModifiersMasks[] = {
0, // No additional modifier.
Mod2Mask, // Num lock
LockMask, // Caps lock
Mod5Mask, // Scroll lock
Mod2Mask | LockMask,
Mod2Mask | Mod5Mask,
LockMask | Mod5Mask,
Mod2Mask | LockMask | Mod5Mask
};
const unsigned int kModifiersMasks[] = {0, // No additional modifier.
Mod2Mask, // Num lock
LockMask, // Caps lock
Mod5Mask, // Scroll lock
Mod2Mask | LockMask,
Mod2Mask | Mod5Mask,
LockMask | Mod5Mask,
Mod2Mask | LockMask | Mod5Mask};
int GetNativeModifiers(const ui::Accelerator& accelerator) {
int modifiers = 0;
@ -50,8 +48,7 @@ namespace extensions {
// static
GlobalShortcutListener* GlobalShortcutListener::GetInstance() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
static GlobalShortcutListenerX11* instance =
new GlobalShortcutListenerX11();
static GlobalShortcutListenerX11* instance = new GlobalShortcutListenerX11();
return instance;
}
@ -68,7 +65,7 @@ GlobalShortcutListenerX11::~GlobalShortcutListenerX11() {
}
void GlobalShortcutListenerX11::StartListening() {
DCHECK(!is_listening_); // Don't start twice.
DCHECK(!is_listening_); // Don't start twice.
DCHECK(!registered_hot_keys_.empty()); // Also don't start if no hotkey is
// registered.
@ -105,8 +102,8 @@ bool GlobalShortcutListenerX11::RegisterAcceleratorImpl(
DCHECK(registered_hot_keys_.find(accelerator) == registered_hot_keys_.end());
int modifiers = GetNativeModifiers(accelerator);
KeyCode keycode = XKeysymToKeycode(x_display_,
XKeysymForWindowsKeyCode(accelerator.key_code(), false));
KeyCode keycode = XKeysymToKeycode(
x_display_, XKeysymForWindowsKeyCode(accelerator.key_code(), false));
gfx::X11ErrorTracker err_tracker;
// Because XGrabKey only works on the exact modifiers mask, we should register
@ -136,8 +133,8 @@ void GlobalShortcutListenerX11::UnregisterAcceleratorImpl(
DCHECK(registered_hot_keys_.find(accelerator) != registered_hot_keys_.end());
int modifiers = GetNativeModifiers(accelerator);
KeyCode keycode = XKeysymToKeycode(x_display_,
XKeysymForWindowsKeyCode(accelerator.key_code(), false));
KeyCode keycode = XKeysymToKeycode(
x_display_, XKeysymForWindowsKeyCode(accelerator.key_code(), false));
for (size_t i = 0; i < arraysize(kModifiersMasks); ++i) {
XUngrabKey(x_display_, keycode, modifiers | kModifiersMasks[i],
@ -152,10 +149,10 @@ void GlobalShortcutListenerX11::OnXKeyPressEvent(::XEvent* x_event) {
modifiers |= (x_event->xkey.state & ShiftMask) ? ui::EF_SHIFT_DOWN : 0;
modifiers |= (x_event->xkey.state & ControlMask) ? ui::EF_CONTROL_DOWN : 0;
modifiers |= (x_event->xkey.state & Mod1Mask) ? ui::EF_ALT_DOWN : 0;
modifiers |= (x_event->xkey.state & Mod4Mask) ? ui::EF_COMMAND_DOWN: 0;
modifiers |= (x_event->xkey.state & Mod4Mask) ? ui::EF_COMMAND_DOWN : 0;
ui::Accelerator accelerator(
ui::KeyboardCodeFromXKeyEvent(x_event), modifiers);
ui::Accelerator accelerator(ui::KeyboardCodeFromXKeyEvent(x_event),
modifiers);
if (registered_hot_keys_.find(accelerator) != registered_hot_keys_.end())
NotifyKeyPressed(accelerator);
}

View file

@ -4,11 +4,11 @@
#include <utility>
#include "chrome/browser/icon_loader.h"
#include "base/bind.h"
#include "base/task_scheduler/post_task.h"
#include "base/task_scheduler/task_traits.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/icon_loader.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;

View file

@ -20,7 +20,7 @@ scoped_refptr<base::TaskRunner> IconLoader::GetReadIconTaskRunner() {
// ReadIcon() calls into views::LinuxUI and GTK2 code, so it must be on the UI
// thread.
return content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI);
content::BrowserThread::UI);
}
void IconLoader::ReadIcon() {

View file

@ -4,8 +4,8 @@
#include "chrome/browser/icon_loader.h"
#include <windows.h>
#include <shellapi.h>
#include <windows.h>
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
@ -54,15 +54,15 @@ void IconLoader::ReadIcon() {
std::unique_ptr<gfx::Image> image;
SHFILEINFO file_info = { 0 };
SHFILEINFO file_info = {0};
if (SHGetFileInfo(group_.c_str(), FILE_ATTRIBUTE_NORMAL, &file_info,
sizeof(SHFILEINFO),
SHGFI_ICON | size | SHGFI_USEFILEATTRIBUTES)) {
sizeof(SHFILEINFO),
SHGFI_ICON | size | SHGFI_USEFILEATTRIBUTES)) {
std::unique_ptr<SkBitmap> bitmap(
IconUtil::CreateSkBitmapFromHICON(file_info.hIcon));
if (bitmap.get()) {
gfx::ImageSkia image_skia(gfx::ImageSkiaRep(*bitmap,
display::win::GetDPIScale()));
gfx::ImageSkia image_skia(
gfx::ImageSkiaRep(*bitmap, display::win::GetDPIScale()));
image_skia.MakeThreadSafe();
image = std::make_unique<gfx::Image>(image_skia);
DestroyIcon(file_info.hIcon);

View file

@ -27,8 +27,7 @@ void RunCallbackIfNotCanceled(
IconManager::IconManager() : weak_factory_(this) {}
IconManager::~IconManager() {
}
IconManager::~IconManager() {}
gfx::Image* IconManager::LookupIconFromFilepath(const base::FilePath& file_path,
IconLoader::IconSize size) {
@ -52,8 +51,8 @@ base::CancelableTaskTracker::TaskId IconManager::LoadIcon(
base::CancelableTaskTracker::IsCanceledCallback is_canceled;
base::CancelableTaskTracker::TaskId id =
tracker->NewTrackedTaskId(&is_canceled);
IconRequestCallback callback_runner = base::Bind(
&RunCallbackIfNotCanceled, is_canceled, callback);
IconRequestCallback callback_runner =
base::Bind(&RunCallbackIfNotCanceled, is_canceled, callback);
IconLoader* loader = IconLoader::Create(
file_path, size,
@ -88,6 +87,6 @@ IconManager::CacheKey::CacheKey(const IconLoader::IconGroup& group,
IconLoader::IconSize size)
: group(group), size(size) {}
bool IconManager::CacheKey::operator<(const CacheKey &other) const {
bool IconManager::CacheKey::operator<(const CacheKey& other) const {
return std::tie(group, size) < std::tie(other.group, other.size);
}

View file

@ -20,8 +20,8 @@ using base::PlatformThreadRef;
#include "media/base/video_util.h"
#include "third_party/libyuv/include/libyuv/scale_argb.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/skia_util.h"
@ -50,9 +50,8 @@ gfx::ImageSkia ScaleDesktopFrame(std::unique_ptr<webrtc::DesktopFrame> frame,
result.allocN32Pixels(scaled_rect.width(), scaled_rect.height(), true);
uint8* pixels_data = reinterpret_cast<uint8*>(result.getPixels());
libyuv::ARGBScale(frame->data(), frame->stride(),
frame->size().width(), frame->size().height(),
pixels_data, result.rowBytes(),
libyuv::ARGBScale(frame->data(), frame->stride(), frame->size().width(),
frame->size().height(), pixels_data, result.rowBytes(),
scaled_rect.width(), scaled_rect.height(),
libyuv::kFilterBilinear);
@ -76,9 +75,7 @@ gfx::ImageSkia ScaleDesktopFrame(std::unique_ptr<webrtc::DesktopFrame> frame,
NativeDesktopMediaList::SourceDescription::SourceDescription(
DesktopMediaID id,
const base::string16& name)
: id(id),
name(name) {
}
: id(id), name(name) {}
class NativeDesktopMediaList::Worker
: public webrtc::DesktopCapturer::Callback {
@ -137,12 +134,12 @@ void NativeDesktopMediaList::Worker::Refresh(
base::string16 title;
for (size_t i = 0; i < screens.size(); ++i) {
if (mutiple_screens) {
title = base::UTF8ToUTF16("Screen " + base::IntToString(i+1));
title = base::UTF8ToUTF16("Screen " + base::IntToString(i + 1));
} else {
title = base::UTF8ToUTF16("Entire screen");
}
sources.push_back(SourceDescription(DesktopMediaID(
DesktopMediaID::TYPE_SCREEN, screens[i].id), title));
sources.push_back(SourceDescription(
DesktopMediaID(DesktopMediaID::TYPE_SCREEN, screens[i].id), title));
}
}
}
@ -163,8 +160,7 @@ void NativeDesktopMediaList::Worker::Refresh(
// Update list of windows before updating thumbnails.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&NativeDesktopMediaList::OnSourcesList,
media_list_, sources));
base::Bind(&NativeDesktopMediaList::OnSourcesList, media_list_, sources));
ImageHashesMap new_image_hashes;
@ -202,8 +198,8 @@ void NativeDesktopMediaList::Worker::Refresh(
ScaleDesktopFrame(std::move(current_frame_), thumbnail_size);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&NativeDesktopMediaList::OnSourceThumbnail,
media_list_, i, thumbnail));
base::Bind(&NativeDesktopMediaList::OnSourceThumbnail, media_list_,
i, thumbnail));
}
}
}
@ -248,8 +244,7 @@ void NativeDesktopMediaList::SetUpdatePeriod(base::TimeDelta period) {
update_period_ = period;
}
void NativeDesktopMediaList::SetThumbnailSize(
const gfx::Size& thumbnail_size) {
void NativeDesktopMediaList::SetThumbnailSize(const gfx::Size& thumbnail_size) {
thumbnail_size_ = thumbnail_size;
}
@ -279,7 +274,8 @@ const DesktopMediaList::Source& NativeDesktopMediaList::GetSource(
return sources_[index];
}
std::vector<DesktopMediaList::Source> NativeDesktopMediaList::GetSources() const {
std::vector<DesktopMediaList::Source> NativeDesktopMediaList::GetSources()
const {
return sources_;
}
@ -351,9 +347,8 @@ void NativeDesktopMediaList::OnSourcesList(
}
}
void NativeDesktopMediaList::OnSourceThumbnail(
int index,
const gfx::ImageSkia& image) {
void NativeDesktopMediaList::OnSourceThumbnail(int index,
const gfx::ImageSkia& image) {
DCHECK_LT(index, static_cast<int>(sources_.size()));
sources_[index].thumbnail = image;
observer_->OnSourceThumbnailChanged(index);
@ -363,10 +358,9 @@ void NativeDesktopMediaList::OnRefreshFinished() {
// Give a chance to the observer to stop the refresh work.
bool is_continue = observer_->OnRefreshFinished();
if (is_continue) {
BrowserThread::PostDelayedTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&NativeDesktopMediaList::Refresh,
weak_factory_.GetWeakPtr()),
update_period_);
BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE,
base::Bind(&NativeDesktopMediaList::Refresh,
weak_factory_.GetWeakPtr()),
update_period_);
}
}

View file

@ -223,8 +223,8 @@ class PdfConverterUtilityProcessHostClient
std::unique_ptr<MetafilePlayer>
PdfConverterUtilityProcessHostClient::GetFileFromTemp(
std::unique_ptr<base::File, content::BrowserThread::DeleteOnFileThread>
temp_file) {
std::unique_ptr<base::File, content::BrowserThread::DeleteOnFileThread>
temp_file) {
if (settings_.mode == PdfRenderSettings::Mode::POSTSCRIPT_LEVEL2 ||
settings_.mode == PdfRenderSettings::Mode::POSTSCRIPT_LEVEL3) {
return std::make_unique<PostScriptMetaFile>(temp_dir_,
@ -278,12 +278,10 @@ ScopedTempFile CreateTempFile(scoped_refptr<RefCountedTempDir>* temp_dir) {
<< (*temp_dir)->GetPath().value();
return file;
}
file.reset(new base::File(path,
base::File::FLAG_CREATE_ALWAYS |
base::File::FLAG_WRITE |
base::File::FLAG_READ |
base::File::FLAG_DELETE_ON_CLOSE |
base::File::FLAG_TEMPORARY));
file.reset(new base::File(
path, base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE |
base::File::FLAG_READ | base::File::FLAG_DELETE_ON_CLOSE |
base::File::FLAG_TEMPORARY));
if (!file->IsValid()) {
PLOG(ERROR) << "Failed to create " << path.value();
file.reset();
@ -344,8 +342,7 @@ bool LazyEmf::LoadEmf(Emf* emf) const {
return emf->InitFromData(data.data(), data.size());
}
PostScriptMetaFile::~PostScriptMetaFile() {
}
PostScriptMetaFile::~PostScriptMetaFile() {}
bool PostScriptMetaFile::SafePlayback(HDC hdc) const {
// TODO(thestig): Fix destruction of metafiles. For some reasons
@ -526,7 +523,6 @@ void PdfConverterUtilityProcessHostClient::OnFailed() {
utility_process_host_.reset();
}
void PdfConverterUtilityProcessHostClient::OnPreCacheFontCharacters(
const LOGFONT& font,
const base::string16& str) {
@ -603,12 +599,12 @@ PdfConverterImpl::~PdfConverterImpl() {
}
void PdfConverterImpl::Start(
const scoped_refptr<PdfConverterUtilityProcessHostClient>& utility_client,
const scoped_refptr<base::RefCountedMemory>& data,
const StartCallback& start_callback) {
DCHECK(!utility_client_);
utility_client_ = utility_client;
utility_client_->Start(data, start_callback);
const scoped_refptr<PdfConverterUtilityProcessHostClient>& utility_client,
const scoped_refptr<base::RefCountedMemory>& data,
const StartCallback& start_callback) {
DCHECK(!utility_client_);
utility_client_ = utility_client;
utility_client_->Start(data, start_callback);
}
void PdfConverterImpl::GetPage(int page_number,
@ -632,10 +628,9 @@ std::unique_ptr<PdfConverter> PdfConverter::StartPdfConverter(
const StartCallback& start_callback) {
std::unique_ptr<PdfConverterImpl> converter =
std::make_unique<PdfConverterImpl>();
converter->Start(
new PdfConverterUtilityProcessHostClient(converter->GetWeakPtr(),
conversion_settings),
data, start_callback);
converter->Start(new PdfConverterUtilityProcessHostClient(
converter->GetWeakPtr(), conversion_settings),
data, start_callback);
return std::move(converter);
}

View file

@ -12,8 +12,8 @@
#include "base/location.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/task_scheduler/post_task.h"
#include "base/single_thread_task_runner.h"
#include "base/task_scheduler/post_task.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
@ -44,9 +44,7 @@ void HoldRefCallback(const scoped_refptr<PrintJobWorkerOwner>& owner,
} // namespace
PrintJob::PrintJob()
: is_job_pending_(false),
is_canceling_(false),
quit_factory_(this) {
: is_job_pending_(false), is_canceling_(false), quit_factory_(this) {
// This is normally a UI message loop, but in unit tests, the message loop is
// of the 'default' type.
DCHECK(base::MessageLoopForUI::IsCurrent() ||
@ -133,8 +131,7 @@ void PrintJob::StartPrinting() {
scoped_refptr<JobEventDetails> details(
new JobEventDetails(JobEventDetails::NEW_DOC, document_.get(), nullptr));
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(this),
chrome::NOTIFICATION_PRINT_JOB_EVENT, content::Source<PrintJob>(this),
content::Details<JobEventDetails>(details.get()));
}
@ -178,8 +175,7 @@ void PrintJob::Cancel() {
scoped_refptr<JobEventDetails> details(
new JobEventDetails(JobEventDetails::FAILED, nullptr, nullptr));
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(this),
chrome::NOTIFICATION_PRINT_JOB_EVENT, content::Source<PrintJob>(this),
content::Details<JobEventDetails>(details.get()));
Stop();
is_canceling_ = false;
@ -221,8 +217,8 @@ class PrintJob::PdfConversionState {
void Start(const scoped_refptr<base::RefCountedMemory>& data,
const PdfRenderSettings& conversion_settings,
const PdfConverter::StartCallback& start_callback) {
converter_ = PdfConverter::StartPdfConverter(
data, conversion_settings, start_callback);
converter_ = PdfConverter::StartPdfConverter(data, conversion_settings,
start_callback);
}
void GetMorePages(const PdfConverter::GetPageCallback& get_page_callback) {
@ -313,8 +309,8 @@ void PrintJob::StartPdfToPostScriptConversion(
const gfx::Point& physical_offsets,
bool ps_level2) {
DCHECK(!pdf_conversion_state_);
pdf_conversion_state_ = std::make_unique<PdfConversionState>(
gfx::Size(), gfx::Rect());
pdf_conversion_state_ =
std::make_unique<PdfConversionState>(gfx::Size(), gfx::Rect());
const int kPrinterDpi = settings().dpi();
PdfRenderSettings settings(
content_area, physical_offsets, kPrinterDpi, true /* autorotate? */,
@ -399,8 +395,7 @@ void PrintJob::OnDocumentDone() {
scoped_refptr<JobEventDetails> details(
new JobEventDetails(JobEventDetails::JOB_DONE, document_.get(), nullptr));
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PRINT_JOB_EVENT,
content::Source<PrintJob>(this),
chrome::NOTIFICATION_PRINT_JOB_EVENT, content::Source<PrintJob>(this),
content::Details<JobEventDetails>(details.get()));
}
@ -431,7 +426,6 @@ void PrintJob::ControlledWorkerShutdown() {
}
#endif
// Now make sure the thread object is cleaned up. Do this on a worker
// thread because it may block.
base::PostTaskAndReply(
@ -444,8 +438,7 @@ void PrintJob::ControlledWorkerShutdown() {
UpdatePrintedDocument(nullptr);
}
void PrintJob::HoldUntilStopIsCalled() {
}
void PrintJob::HoldUntilStopIsCalled() {}
void PrintJob::Quit() {
base::RunLoop::QuitCurrentWhenIdleDeprecated();
@ -455,16 +448,16 @@ void PrintJob::Quit() {
JobEventDetails::JobEventDetails(Type type,
PrintedDocument* document,
PrintedPage* page)
: document_(document),
page_(page),
type_(type) {
: document_(document), page_(page), type_(type) {}
JobEventDetails::~JobEventDetails() {}
PrintedDocument* JobEventDetails::document() const {
return document_.get();
}
JobEventDetails::~JobEventDetails() {
PrintedPage* JobEventDetails::page() const {
return page_.get();
}
PrintedDocument* JobEventDetails::document() const { return document_.get(); }
PrintedPage* JobEventDetails::page() const { return page_.get(); }
} // namespace printing

View file

@ -14,8 +14,7 @@
namespace printing {
PrintQueriesQueue::PrintQueriesQueue() {
}
PrintQueriesQueue::PrintQueriesQueue() {}
PrintQueriesQueue::~PrintQueriesQueue() {
base::AutoLock lock(lock_);
@ -47,8 +46,7 @@ scoped_refptr<PrinterQuery> PrintQueriesQueue::PopPrinterQuery(
scoped_refptr<PrinterQuery> PrintQueriesQueue::CreatePrinterQuery(
int render_process_id,
int render_frame_id) {
return WrapRefCounted(
new PrinterQuery(render_process_id, render_frame_id));
return WrapRefCounted(new PrinterQuery(render_process_id, render_frame_id));
}
void PrintQueriesQueue::Shutdown() {
@ -71,8 +69,7 @@ PrintJobManager::PrintJobManager() : is_shutdown_(false) {
content::NotificationService::AllSources());
}
PrintJobManager::~PrintJobManager() {
}
PrintJobManager::~PrintJobManager() {}
scoped_refptr<PrintQueriesQueue> PrintJobManager::queue() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@ -117,9 +114,8 @@ void PrintJobManager::Observe(int type,
*content::Details<JobEventDetails>(details).ptr());
}
void PrintJobManager::OnPrintJobEvent(
PrintJob* print_job,
const JobEventDetails& event_details) {
void PrintJobManager::OnPrintJobEvent(PrintJob* print_job,
const JobEventDetails& event_details) {
switch (event_details.type()) {
case JobEventDetails::NEW_DOC: {
DCHECK(current_jobs_.end() == current_jobs_.find(print_job));

View file

@ -57,11 +57,14 @@ void HoldRefCallback(const scoped_refptr<PrintJobWorkerOwner>& owner,
void SetCustomMarginsToJobSettings(const PageSizeMargins& page_size_margins,
base::DictionaryValue* settings) {
std::unique_ptr<base::DictionaryValue> custom_margins(new base::DictionaryValue());
std::unique_ptr<base::DictionaryValue> custom_margins(
new base::DictionaryValue());
custom_margins->SetDouble(kSettingMarginTop, page_size_margins.margin_top);
custom_margins->SetDouble(kSettingMarginBottom, page_size_margins.margin_bottom);
custom_margins->SetDouble(kSettingMarginBottom,
page_size_margins.margin_bottom);
custom_margins->SetDouble(kSettingMarginLeft, page_size_margins.margin_left);
custom_margins->SetDouble(kSettingMarginRight, page_size_margins.margin_right);
custom_margins->SetDouble(kSettingMarginRight,
page_size_margins.margin_right);
settings->Set(kSettingMarginsCustom, std::move(custom_margins));
}
@ -83,7 +86,8 @@ void PrintSettingsToJobSettings(const PrintSettings& settings,
auto margin_type = settings.margin_type();
job_settings->SetInteger(kSettingMarginsType, settings.margin_type());
if (margin_type == CUSTOM_MARGINS) {
const auto& margins_in_points = settings.requested_custom_margins_in_points();
const auto& margins_in_points =
settings.requested_custom_margins_in_points();
PageSizeMargins page_size_margins;
@ -130,7 +134,6 @@ void PrintSettingsToJobSettings(const PrintSettings& settings,
job_settings->SetInteger(kSettingPreviewPageCount, 1);
}
class PrintingContextDelegate : public PrintingContext::Delegate {
public:
PrintingContextDelegate(int render_process_id, int render_frame_id);
@ -152,8 +155,7 @@ PrintingContextDelegate::PrintingContextDelegate(int render_process_id,
: render_process_id_(render_process_id),
render_frame_id_(render_frame_id) {}
PrintingContextDelegate::~PrintingContextDelegate() {
}
PrintingContextDelegate::~PrintingContextDelegate() {}
gfx::NativeView PrintingContextDelegate::GetParentView() {
content::WebContents* wc = GetWebContents();
@ -243,17 +245,14 @@ void PrintJobWorker::GetSettings(bool ask_user_for_settings,
BrowserThread::UI, FROM_HERE,
base::Bind(&HoldRefCallback, WrapRefCounted(owner_),
base::Bind(&PrintJobWorker::GetSettingsWithUI,
base::Unretained(this),
document_page_count,
has_selection,
is_scripted)));
base::Unretained(this), document_page_count,
has_selection, is_scripted)));
} else if (!device_name.empty()) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&HoldRefCallback, WrapRefCounted(owner_),
base::Bind(&PrintJobWorker::InitWithDeviceName,
base::Unretained(this),
device_name)));
base::Unretained(this), device_name)));
} else {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
@ -268,13 +267,11 @@ void PrintJobWorker::SetSettings(
DCHECK(task_runner_->RunsTasksInCurrentSequence());
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(&HoldRefCallback,
WrapRefCounted(owner_),
base::Bind(&PrintJobWorker::UpdatePrintSettings,
base::Unretained(this),
base::Passed(&new_settings))));
BrowserThread::UI, FROM_HERE,
base::Bind(
&HoldRefCallback, WrapRefCounted(owner_),
base::Bind(&PrintJobWorker::UpdatePrintSettings,
base::Unretained(this), base::Passed(&new_settings))));
}
void PrintJobWorker::UpdatePrintSettings(
@ -296,17 +293,15 @@ void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) {
// We can't use OnFailure() here since owner_ may not support notifications.
// PrintJob will create the new PrintedDocument.
owner_->PostTask(FROM_HERE,
base::Bind(&PrintJobWorkerOwner::GetSettingsDone,
WrapRefCounted(owner_),
printing_context_->settings(),
result));
owner_->PostTask(
FROM_HERE,
base::Bind(&PrintJobWorkerOwner::GetSettingsDone, WrapRefCounted(owner_),
printing_context_->settings(), result));
}
void PrintJobWorker::GetSettingsWithUI(
int document_page_count,
bool has_selection,
bool is_scripted) {
void PrintJobWorker::GetSettingsWithUI(int document_page_count,
bool has_selection,
bool is_scripted) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// weak_factory_ creates pointers valid only on owner_ thread.

View file

@ -13,8 +13,7 @@ namespace printing {
PrintJobWorkerOwner::PrintJobWorkerOwner()
: task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
PrintJobWorkerOwner::~PrintJobWorkerOwner() {
}
PrintJobWorkerOwner::~PrintJobWorkerOwner() {}
bool PrintJobWorkerOwner::RunsTasksInCurrentSequence() const {
return task_runner_->RunsTasksInCurrentSequence();

View file

@ -15,8 +15,8 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "printing/page_size_margins.h"
#include "printing/print_job_constants.h"
#include "printing/pdf_metafile_skia.h"
#include "printing/print_job_constants.h"
#include "atom/common/node_includes.h"
@ -35,9 +35,9 @@ void StopWorker(int document_cookie) {
scoped_refptr<printing::PrinterQuery> printer_query =
queue->PopPrinterQuery(document_cookie);
if (printer_query.get()) {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&printing::PrinterQuery::StopWorker,
printer_query));
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&printing::PrinterQuery::StopWorker, printer_query));
}
}
@ -61,15 +61,13 @@ void FreeNodeBufferData(char* data, void* hint) {
namespace printing {
PrintPreviewMessageHandler::PrintPreviewMessageHandler(
WebContents* web_contents)
: content::WebContentsObserver(web_contents) {
DCHECK(web_contents);
}
PrintPreviewMessageHandler::~PrintPreviewMessageHandler() {
}
PrintPreviewMessageHandler::~PrintPreviewMessageHandler() {}
void PrintPreviewMessageHandler::OnMetafileReadyForPrinting(
const PrintHostMsg_DidPreviewDocument_Params& params) {
@ -82,12 +80,9 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting(
}
BrowserThread::PostTaskAndReplyWithResult(
BrowserThread::IO,
FROM_HERE,
base::Bind(&CopyPDFDataOnIOThread, params),
BrowserThread::IO, FROM_HERE, base::Bind(&CopyPDFDataOnIOThread, params),
base::Bind(&PrintPreviewMessageHandler::RunPrintToPDFCallback,
base::Unretained(this),
params.preview_request_id,
base::Unretained(this), params.preview_request_id,
params.data_size));
}
@ -104,8 +99,7 @@ bool PrintPreviewMessageHandler::OnMessageReceived(
IPC_BEGIN_MESSAGE_MAP(PrintPreviewMessageHandler, message)
IPC_MESSAGE_HANDLER(PrintHostMsg_MetafileReadyForPrinting,
OnMetafileReadyForPrinting)
IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewFailed,
OnPrintPreviewFailed)
IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewFailed, OnPrintPreviewFailed)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@ -122,21 +116,23 @@ void PrintPreviewMessageHandler::PrintToPDF(
rfh->Send(new PrintMsg_PrintPreview(rfh->GetRoutingID(), options));
}
void PrintPreviewMessageHandler::RunPrintToPDFCallback(
int request_id, uint32_t data_size, char* data) {
void PrintPreviewMessageHandler::RunPrintToPDFCallback(int request_id,
uint32_t data_size,
char* data) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
if (data) {
v8::Local<v8::Value> buffer = node::Buffer::New(isolate,
data, static_cast<size_t>(data_size), &FreeNodeBufferData, nullptr)
.ToLocalChecked();
v8::Local<v8::Value> buffer =
node::Buffer::New(isolate, data, static_cast<size_t>(data_size),
&FreeNodeBufferData, nullptr)
.ToLocalChecked();
print_to_pdf_callback_map_[request_id].Run(v8::Null(isolate), buffer);
} else {
v8::Local<v8::String> error_message = v8::String::NewFromUtf8(isolate,
"Failed to generate PDF");
v8::Local<v8::String> error_message =
v8::String::NewFromUtf8(isolate, "Failed to generate PDF");
print_to_pdf_callback_map_[request_id].Run(
v8::Exception::Error(error_message), v8::Null(isolate));
}

View file

@ -12,7 +12,6 @@
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/timer/timer.h"
#include "components/prefs/pref_service.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/printing/print_job.h"
@ -22,6 +21,7 @@
#include "chrome/browser/ui/simple_message_box.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/print_messages.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
@ -42,9 +42,7 @@ using content::BrowserThread;
namespace printing {
namespace {
} // namespace
namespace {} // namespace
PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
@ -67,12 +65,12 @@ PrintViewManagerBase::~PrintViewManagerBase() {
#if !defined(DISABLE_BASIC_PRINTING)
bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh,
bool silent, bool print_background,
bool silent,
bool print_background,
const base::string16& device_name) {
int32_t id = rfh->GetRoutingID();
return PrintNowInternal(
rfh,
std::make_unique<PrintMsg_PrintPages>(id, silent, print_background, device_name));
return PrintNowInternal(rfh, std::make_unique<PrintMsg_PrintPages>(
id, silent, print_background, device_name));
}
#endif // !DISABLE_BASIC_PRINTING
@ -114,7 +112,7 @@ void PrintViewManagerBase::OnDidGetDocumentCookie(int cookie) {
}
void PrintViewManagerBase::OnDidPrintPage(
const PrintHostMsg_DidPrintPage_Params& params) {
const PrintHostMsg_DidPrintPage_Params& params) {
if (!OpportunisticallyCreatePrintJob(params.document_cookie))
return;
@ -153,18 +151,15 @@ void PrintViewManagerBase::OnDidPrintPage(
#if !defined(OS_WIN)
// Update the rendered document. It will send notifications to the listener.
document->SetPage(params.page_number,
std::move(metafile),
params.page_size,
document->SetPage(params.page_number, std::move(metafile), params.page_size,
params.content_area);
ShouldQuitFromInnerMessageLoop();
#else
print_job_->AppendPrintedPage(params.page_number);
if (metafile_must_be_valid) {
bool print_text_with_gdi =
document->settings().print_text_with_gdi() &&
!document->settings().printer_is_xps();
bool print_text_with_gdi = document->settings().print_text_with_gdi() &&
!document->settings().printer_is_xps();
scoped_refptr<base::RefCountedBytes> bytes = new base::RefCountedBytes(
reinterpret_cast<const unsigned char*>(shared_buf.memory()),
@ -172,8 +167,7 @@ void PrintViewManagerBase::OnDidPrintPage(
document->DebugDumpData(bytes.get(), FILE_PATH_LITERAL(".pdf"));
print_job_->StartPdfToEmfConversion(
bytes, params.page_size, params.content_area,
print_text_with_gdi);
bytes, params.page_size, params.content_area, print_text_with_gdi);
}
#endif // !OS_WIN
}
@ -284,8 +278,7 @@ bool PrintViewManagerBase::RenderAllMissingPagesNow() {
return false;
// We can't print if there is no renderer.
if (!web_contents() ||
!web_contents()->GetRenderViewHost() ||
if (!web_contents() || !web_contents()->GetRenderViewHost() ||
!web_contents()->GetRenderViewHost()->IsRenderViewLive()) {
return false;
}
@ -318,8 +311,7 @@ bool PrintViewManagerBase::RenderAllMissingPagesNow() {
void PrintViewManagerBase::ShouldQuitFromInnerMessageLoop() {
// Look at the reason.
DCHECK(print_job_->document());
if (print_job_->document() &&
print_job_->document()->IsComplete() &&
if (print_job_->document() && print_job_->document()->IsComplete() &&
inside_inner_message_loop_) {
// We are in a message loop created by RenderAllMissingPagesNow. Quit from
// it.
@ -361,8 +353,7 @@ void PrintViewManagerBase::DisconnectFromCurrentPrintJob() {
bool result = RenderAllMissingPagesNow();
// Verify that assertion.
if (print_job_.get() &&
print_job_->document() &&
if (print_job_.get() && print_job_->document() &&
!print_job_->document()->IsComplete()) {
DCHECK(!result);
// That failed.

View file

@ -15,11 +15,9 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(printing::PrintViewManagerBasic);
namespace printing {
PrintViewManagerBasic::PrintViewManagerBasic(content::WebContents* web_contents)
: PrintViewManagerBase(web_contents) {
}
: PrintViewManagerBase(web_contents) {}
PrintViewManagerBasic::~PrintViewManagerBasic() {
}
PrintViewManagerBasic::~PrintViewManagerBasic() {}
#if defined(OS_ANDROID)
void PrintViewManagerBasic::RenderProcessGone(base::TerminationStatus status) {

View file

@ -89,24 +89,24 @@ void PrinterQuery::GetSettings(GetSettingsAskParam ask_user_for_settings,
margin_type, is_scripted, is_modifiable, base::string16()));
}
void PrinterQuery::GetSettings(
GetSettingsAskParam ask_user_for_settings,
int expected_page_count,
bool has_selection,
MarginType margin_type,
bool is_scripted,
bool is_modifiable,
const base::string16& device_name,
const base::Closure& callback) {
void PrinterQuery::GetSettings(GetSettingsAskParam ask_user_for_settings,
int expected_page_count,
bool has_selection,
MarginType margin_type,
bool is_scripted,
bool is_modifiable,
const base::string16& device_name,
const base::Closure& callback) {
DCHECK(RunsTasksInCurrentSequence());
DCHECK(!is_print_dialog_box_shown_);
StartWorker(callback);
is_print_dialog_box_shown_ = false;
worker_->PostTask(FROM_HERE,
base::Bind(&PrintJobWorker::GetSettings, base::Unretained(worker_.get()),
is_print_dialog_box_shown_, expected_page_count, has_selection,
margin_type, is_scripted, is_modifiable, device_name));
worker_->PostTask(
FROM_HERE,
base::Bind(&PrintJobWorker::GetSettings, base::Unretained(worker_.get()),
is_print_dialog_box_shown_, expected_page_count, has_selection,
margin_type, is_scripted, is_modifiable, device_name));
}
void PrinterQuery::SetSettings(
@ -114,10 +114,9 @@ void PrinterQuery::SetSettings(
const base::Closure& callback) {
StartWorker(callback);
worker_->PostTask(FROM_HERE,
base::Bind(&PrintJobWorker::SetSettings,
base::Unretained(worker_.get()),
base::Passed(&new_settings)));
worker_->PostTask(FROM_HERE, base::Bind(&PrintJobWorker::SetSettings,
base::Unretained(worker_.get()),
base::Passed(&new_settings)));
}
void PrinterQuery::StartWorker(const base::Closure& callback) {

View file

@ -16,11 +16,9 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/common/child_process_host.h"
#include "printing/features/features.h"
#if defined(OS_ANDROID)
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/printing/print_view_manager_basic.h"
@ -86,15 +84,15 @@ PrintingMessageFilter::PrintingMessageFilter(int render_process_id)
DCHECK(queue_.get());
}
PrintingMessageFilter::~PrintingMessageFilter() {
}
PrintingMessageFilter::~PrintingMessageFilter() {}
void PrintingMessageFilter::OnDestruct() const {
BrowserThread::DeleteOnUIThread::Destruct(this);
}
void PrintingMessageFilter::OverrideThreadForMessage(
const IPC::Message& message, BrowserThread::ID* thread) {
const IPC::Message& message,
BrowserThread::ID* thread) {
#if defined(OS_ANDROID)
if (message.type() == PrintHostMsg_AllocateTempFileForPrinting::ID ||
message.type() == PrintHostMsg_TempFileForPrintingWritten::ID) {
@ -174,8 +172,9 @@ void PrintingMessageFilter::OnGetDefaultPrintSettings(IPC::Message* reply_msg) {
printer_query, reply_msg));
}
void PrintingMessageFilter::OnInitSettingWithDeviceName(const base::string16& device_name,
IPC::Message* reply_msg) {
void PrintingMessageFilter::OnInitSettingWithDeviceName(
const base::string16& device_name,
IPC::Message* reply_msg) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
scoped_refptr<PrinterQuery> printer_query;
printer_query = queue_->PopPrinterQuery(0);
@ -187,17 +186,10 @@ void PrintingMessageFilter::OnInitSettingWithDeviceName(const base::string16& de
// Loads default settings. This is asynchronous, only the IPC message sender
// will hang until the settings are retrieved.
printer_query->GetSettings(
PrinterQuery::GetSettingsAskParam::DEFAULTS,
0,
false,
DEFAULT_MARGINS,
true,
true,
device_name,
base::Bind(&PrintingMessageFilter::OnGetDefaultPrintSettingsReply,
this,
printer_query,
reply_msg));
PrinterQuery::GetSettingsAskParam::DEFAULTS, 0, false, DEFAULT_MARGINS,
true, true, device_name,
base::Bind(&PrintingMessageFilter::OnGetDefaultPrintSettingsReply, this,
printer_query, reply_msg));
}
void PrintingMessageFilter::OnGetDefaultPrintSettingsReply(
@ -289,7 +281,8 @@ void PrintingMessageFilter::UpdateFileDescriptor(int render_view_id, int fd) {
#endif
void PrintingMessageFilter::OnUpdatePrintSettings(
int document_cookie, const base::DictionaryValue& job_settings,
int document_cookie,
const base::DictionaryValue& job_settings,
IPC::Message* reply_msg) {
std::unique_ptr<base::DictionaryValue> new_settings(job_settings.DeepCopy());

View file

@ -117,11 +117,12 @@ const int kMaxACKMessageLength = arraysize(kShutdownToken) - 1;
const char kLockDelimiter = '-';
const base::FilePath::CharType kSingletonCookieFilename[] =
FILE_PATH_LITERAL("SingletonCookie");
FILE_PATH_LITERAL("SingletonCookie");
const base::FilePath::CharType kSingletonLockFilename[] = FILE_PATH_LITERAL("SingletonLock");
const base::FilePath::CharType kSingletonLockFilename[] =
FILE_PATH_LITERAL("SingletonLock");
const base::FilePath::CharType kSingletonSocketFilename[] =
FILE_PATH_LITERAL("SS");
FILE_PATH_LITERAL("SS");
// Set the close-on-exec bit on a file descriptor.
// Returns 0 on success, -1 on failure.
@ -141,7 +142,7 @@ void CloseSocket(int fd) {
}
// Write a message to a socket fd.
bool WriteToSocket(int fd, const char *message, size_t length) {
bool WriteToSocket(int fd, const char* message, size_t length) {
DCHECK(message);
DCHECK(length);
size_t bytes_written = 0;
@ -343,6 +344,7 @@ class ScopedSocket {
CloseSocket(fd_);
fd_ = -1;
}
private:
int fd_;
};
@ -380,8 +382,8 @@ bool ConnectSocket(ScopedSocket* socket,
base::FilePath cookie = ReadLink(cookie_path);
if (cookie.empty())
return false;
base::FilePath remote_cookie = socket_target.DirName().
Append(kSingletonCookieFilename);
base::FilePath remote_cookie =
socket_target.DirName().Append(kSingletonCookieFilename);
// Verify the cookie before connecting.
if (!CheckCookie(remote_cookie, cookie))
return false;
@ -389,9 +391,8 @@ bool ConnectSocket(ScopedSocket* socket,
// owner. Try to connect.
sockaddr_un addr;
SetupSockAddr(socket_target.value(), &addr);
int ret = HANDLE_EINTR(connect(socket->fd(),
reinterpret_cast<sockaddr*>(&addr),
sizeof(addr)));
int ret = HANDLE_EINTR(connect(
socket->fd(), reinterpret_cast<sockaddr*>(&addr), sizeof(addr)));
if (ret != 0)
return false;
// Check the cookie again. We only link in /tmp, which is sticky, so, if the
@ -408,9 +409,8 @@ bool ConnectSocket(ScopedSocket* socket,
// later). Just connect to it directly; this is an older version of Chrome.
sockaddr_un addr;
SetupSockAddr(socket_path.value(), &addr);
int ret = HANDLE_EINTR(connect(socket->fd(),
reinterpret_cast<sockaddr*>(&addr),
sizeof(addr)));
int ret = HANDLE_EINTR(connect(
socket->fd(), reinterpret_cast<sockaddr*>(&addr), sizeof(addr)));
return (ret == 0);
} else {
// File is missing, or other error.
@ -490,7 +490,7 @@ class ProcessSingleton::LinuxWatcher
// Finish handling the incoming message by optionally sending back an ACK
// message and removing this SocketReader.
void FinishWithACK(const char *message, size_t length);
void FinishWithACK(const char* message, size_t length);
private:
void OnSocketCanReadWithoutBlocking();
@ -546,9 +546,7 @@ class ProcessSingleton::LinuxWatcher
friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
friend class base::DeleteHelper<ProcessSingleton::LinuxWatcher>;
~LinuxWatcher() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
}
~LinuxWatcher() { DCHECK_CURRENTLY_ON(BrowserThread::IO); }
void OnSocketCanReadWithoutBlocking(int socket);
@ -596,13 +594,13 @@ void ProcessSingleton::LinuxWatcher::StartListening(int socket) {
}
void ProcessSingleton::LinuxWatcher::HandleMessage(
const std::string& current_dir, const std::vector<std::string>& argv,
const std::string& current_dir,
const std::vector<std::string>& argv,
SocketReader* reader) {
DCHECK(ui_task_runner_->BelongsToCurrentThread());
DCHECK(reader);
if (parent_->notification_callback_.Run(argv,
base::FilePath(current_dir))) {
if (parent_->notification_callback_.Run(argv, base::FilePath(current_dir))) {
// Send back "ACK" message to prevent the client process from starting up.
reader->FinishWithACK(kACKToken, arraysize(kACKToken) - 1);
} else {
@ -663,9 +661,9 @@ void ProcessSingleton::LinuxWatcher::SocketReader::
}
std::string str(buf_, bytes_read_);
std::vector<std::string> tokens = base::SplitString(
str, std::string(1, kTokenDelimiter),
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
std::vector<std::string> tokens =
base::SplitString(str, std::string(1, kTokenDelimiter),
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
if (tokens.size() < 3 || tokens[0] != kStartToken) {
LOG(ERROR) << "Wrong message format: " << str;
@ -694,7 +692,8 @@ void ProcessSingleton::LinuxWatcher::SocketReader::
}
void ProcessSingleton::LinuxWatcher::SocketReader::FinishWithACK(
const char *message, size_t length) {
const char* message,
size_t length) {
if (message && length) {
// Not necessary to care about the return value.
WriteToSocket(fd_, message, length);
@ -704,10 +703,8 @@ void ProcessSingleton::LinuxWatcher::SocketReader::FinishWithACK(
PLOG(ERROR) << "shutdown() failed";
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
base::Bind(&ProcessSingleton::LinuxWatcher::RemoveSocketReader,
parent_,
BrowserThread::IO, FROM_HERE,
base::Bind(&ProcessSingleton::LinuxWatcher::RemoveSocketReader, parent_,
this));
// We will be deleted once the posted RemoveSocketReader task runs.
}
@ -728,8 +725,8 @@ ProcessSingleton::ProcessSingleton(
lock_path_ = user_data_dir.Append(kSingletonLockFilename);
cookie_path_ = user_data_dir.Append(kSingletonCookieFilename);
kill_callback_ = base::Bind(&ProcessSingleton::KillProcess,
base::Unretained(this));
kill_callback_ =
base::Bind(&ProcessSingleton::KillProcess, base::Unretained(this));
}
ProcessSingleton::~ProcessSingleton() {
@ -814,10 +811,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
}
timeval socket_timeout = TimeDeltaToTimeVal(timeout);
setsockopt(socket.fd(),
SOL_SOCKET,
SO_SNDTIMEO,
&socket_timeout,
setsockopt(socket.fd(), SOL_SOCKET, SO_SNDTIMEO, &socket_timeout,
sizeof(socket_timeout));
// Found another process, prepare our command line
@ -832,7 +826,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
const std::vector<std::string>& argv = atom::AtomCommandLine::argv();
for (std::vector<std::string>::const_iterator it = argv.begin();
it != argv.end(); ++it) {
it != argv.end(); ++it) {
to_send.push_back(kTokenDelimiter);
to_send.append(*it);
}
@ -889,10 +883,8 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessOrCreate() {
void ProcessSingleton::StartListeningOnSocket() {
watcher_ = new LinuxWatcher(this);
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
base::Bind(&ProcessSingleton::LinuxWatcher::StartListening,
watcher_,
BrowserThread::IO, FROM_HERE,
base::Bind(&ProcessSingleton::LinuxWatcher::StartListening, watcher_,
sock_));
}
@ -933,8 +925,8 @@ ProcessSingleton::NotifyOtherProcessWithTimeoutOrCreate(
// we did.)
// This time, we don't want to kill anything if we aren't successful, since we
// aren't going to try to take over the lock ourselves.
result = NotifyOtherProcessWithTimeout(
command_line, retry_attempts, timeout, false);
result = NotifyOtherProcessWithTimeout(command_line, retry_attempts, timeout,
false);
if (result == PROCESS_NOTIFIED) {
UMA_HISTOGRAM_MEDIUM_TIMES("Chrome.ProcessSingleton.TimeToNotify",
@ -971,10 +963,7 @@ bool ProcessSingleton::Create() {
// The symlink lock is pointed to the hostname and process id, so other
// processes can find it out.
base::FilePath symlink_content(base::StringPrintf(
"%s%c%u",
net::GetHostName().c_str(),
kLockDelimiter,
current_pid_));
"%s%c%u", net::GetHostName().c_str(), kLockDelimiter, current_pid_));
// Create symbol link before binding the socket, to ensure only one instance
// can have the socket open.
@ -1110,6 +1099,6 @@ void ProcessSingleton::KillProcess(int pid) {
int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL);
// ESRCH = No Such Process (can happen if the other process is already in
// progress of shutting down and finishes before we try to kill it).
DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: "
<< base::safe_strerror(errno);
DCHECK(rv == 0 || errno == ESRCH)
<< "Error killing process: " << base::safe_strerror(errno);
}

View file

@ -110,8 +110,8 @@ bool ParseCommandLine(const COPYDATASTRUCT* cds,
const std::wstring::size_type first_null = msg.find_first_of(L'\0');
if (first_null == 0 || first_null == std::wstring::npos) {
// no NULL byte, don't know what to do
LOG(WARNING) << "Invalid WM_COPYDATA, length = " << msg.length() <<
", first null = " << first_null;
LOG(WARNING) << "Invalid WM_COPYDATA, length = " << msg.length()
<< ", first null = " << first_null;
return false;
}
@ -122,23 +122,22 @@ bool ParseCommandLine(const COPYDATASTRUCT* cds,
VLOG(1) << "Handling STARTUP request from another process";
const std::wstring::size_type second_null =
msg.find_first_of(L'\0', first_null + 1);
if (second_null == std::wstring::npos ||
first_null == msg.length() - 1 || second_null == msg.length()) {
if (second_null == std::wstring::npos || first_null == msg.length() - 1 ||
second_null == msg.length()) {
LOG(WARNING) << "Invalid format for start command, we need a string in 4 "
"parts separated by NULLs";
"parts separated by NULLs";
return false;
}
// Get current directory.
*current_directory = base::FilePath(msg.substr(first_null + 1,
second_null - first_null));
*current_directory =
base::FilePath(msg.substr(first_null + 1, second_null - first_null));
const std::wstring::size_type third_null =
msg.find_first_of(L'\0', second_null + 1);
if (third_null == std::wstring::npos ||
third_null == msg.length()) {
if (third_null == std::wstring::npos || third_null == msg.length()) {
LOG(WARNING) << "Invalid format for start command, we need a string in 4 "
"parts separated by NULLs";
"parts separated by NULLs";
}
// Get command line.
@ -169,8 +168,9 @@ bool ProcessLaunchNotification(
return true;
}
*result = notification_callback.Run(parsed_command_line, current_directory) ?
TRUE : FALSE;
*result = notification_callback.Run(parsed_command_line, current_directory)
? TRUE
: FALSE;
return true;
}
@ -231,8 +231,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() {
// The window is hung. Scan for every window to find a visible one.
bool visible_window = false;
::EnumThreadWindows(thread_id,
&BrowserWindowEnumeration,
::EnumThreadWindows(thread_id, &BrowserWindowEnumeration,
reinterpret_cast<LPARAM>(&visible_window));
// If there is a visible browser window, ask the user before killing it.
@ -247,8 +246,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() {
return PROCESS_NONE;
}
ProcessSingleton::NotifyResult
ProcessSingleton::NotifyOtherProcessOrCreate() {
ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessOrCreate() {
ProcessSingleton::NotifyResult result = PROCESS_NONE;
if (!Create()) {
result = NotifyOtherProcess();
@ -291,17 +289,14 @@ bool ProcessSingleton::Create() {
// We have to make sure there is no Chrome instance running on another
// machine that uses the same profile.
base::FilePath lock_file_path = user_data_dir_.AppendASCII(kLockfile);
lock_file_ = ::CreateFile(lock_file_path.value().c_str(),
GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL |
FILE_FLAG_DELETE_ON_CLOSE,
NULL);
lock_file_ =
::CreateFile(lock_file_path.value().c_str(), GENERIC_WRITE,
FILE_SHARE_READ, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, NULL);
DWORD error = ::GetLastError();
LOG_IF(WARNING, lock_file_ != INVALID_HANDLE_VALUE &&
error == ERROR_ALREADY_EXISTS) << "Lock file exists but is writable.";
error == ERROR_ALREADY_EXISTS)
<< "Lock file exists but is writable.";
LOG_IF(ERROR, lock_file_ == INVALID_HANDLE_VALUE)
<< "Lock file can not be created! Error code: " << error;
@ -315,7 +310,8 @@ bool ProcessSingleton::Create() {
// NB: Ensure that if the primary app gets started as elevated
// admin inadvertently, secondary windows running not as elevated
// will still be able to send messages
::ChangeWindowMessageFilterEx(window_.hwnd(), WM_COPYDATA, MSGFLT_ALLOW, NULL);
::ChangeWindowMessageFilterEx(window_.hwnd(), WM_COPYDATA, MSGFLT_ALLOW,
NULL);
CHECK(result && window_.hwnd());
}
}
@ -324,8 +320,7 @@ bool ProcessSingleton::Create() {
return window_.hwnd() != NULL;
}
void ProcessSingleton::Cleanup() {
}
void ProcessSingleton::Cleanup() {}
void ProcessSingleton::OverrideShouldKillRemoteProcessCallbackForTesting(
const ShouldKillRemoteProcessCallback& display_dialog_callback) {

View file

@ -29,7 +29,8 @@ ChromeBrowserPepperHostFactory::ChromeBrowserPepperHostFactory(
ChromeBrowserPepperHostFactory::~ChromeBrowserPepperHostFactory() {}
std::unique_ptr<ResourceHost> ChromeBrowserPepperHostFactory::CreateResourceHost(
std::unique_ptr<ResourceHost>
ChromeBrowserPepperHostFactory::CreateResourceHost(
ppapi::host::PpapiHost* host,
PP_Resource resource,
PP_Instance instance,

View file

@ -92,8 +92,7 @@ int32_t PepperFlashBrowserHost::OnGetLocalDataRestrictions(
// call |GetLocalDataRestrictions| with it.
GURL document_url = host_->GetDocumentURLForInstance(pp_instance());
GURL plugin_url = host_->GetPluginURLForInstance(pp_instance());
GetLocalDataRestrictions(context->MakeReplyMessageContext(),
document_url,
GetLocalDataRestrictions(context->MakeReplyMessageContext(), document_url,
plugin_url);
return PP_OK_COMPLETIONPENDING;
}
@ -105,9 +104,8 @@ void PepperFlashBrowserHost::GetLocalDataRestrictions(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
PP_FlashLSORestrictions restrictions = PP_FLASHLSORESTRICTIONS_NONE;
SendReply(reply_context,
PpapiPluginMsg_Flash_GetLocalDataRestrictionsReply(
static_cast<int32_t>(restrictions)));
SendReply(reply_context, PpapiPluginMsg_Flash_GetLocalDataRestrictionsReply(
static_cast<int32_t>(restrictions)));
}
} // namespace chrome

View file

@ -87,8 +87,7 @@ void WriteDataToPickle(const std::map<base::string16, std::string>& data,
base::Pickle* pickle) {
pickle->WriteUInt32(data.size());
for (std::map<base::string16, std::string>::const_iterator it = data.begin();
it != data.end();
++it) {
it != data.end(); ++it) {
pickle->WriteString16(it->first);
pickle->WriteString(it->second);
}

View file

@ -66,7 +66,7 @@ bool GetSystemVolumeSerialNumber(std::string* number) {
}
#endif
}
} // namespace
#if defined(OS_WIN)
// Helper class to get the UI thread which monitor is showing the
@ -89,8 +89,7 @@ class MonitorFinder : public base::RefCountedThreadSafe<MonitorFinder> {
// to call and we can't cache the |monitor_| value.
if (InterlockedCompareExchange(&request_sent_, 1, 0) == 0) {
content::BrowserThread::PostTask(
content::BrowserThread::UI,
FROM_HERE,
content::BrowserThread::UI, FROM_HERE,
base::Bind(&MonitorFinder::FetchMonitorFromWidget, this));
}
return reinterpret_cast<int64_t>(monitor_);

View file

@ -24,15 +24,13 @@ PepperIsolatedFileSystemMessageFilter::Create(PP_Instance instance,
content::BrowserPpapiHost* host) {
int render_process_id;
int unused_render_frame_id;
if (!host->GetRenderFrameIDsForInstance(
instance, &render_process_id, &unused_render_frame_id)) {
if (!host->GetRenderFrameIDsForInstance(instance, &render_process_id,
&unused_render_frame_id)) {
return NULL;
}
return new PepperIsolatedFileSystemMessageFilter(
render_process_id,
host->GetProfileDataDirectory(),
host->GetDocumentURLForInstance(instance),
host->GetPpapiHost());
render_process_id, host->GetProfileDataDirectory(),
host->GetDocumentURLForInstance(instance), host->GetPpapiHost());
}
PepperIsolatedFileSystemMessageFilter::PepperIsolatedFileSystemMessageFilter(
@ -43,8 +41,7 @@ PepperIsolatedFileSystemMessageFilter::PepperIsolatedFileSystemMessageFilter(
: render_process_id_(render_process_id),
profile_directory_(profile_directory),
document_url_(document_url),
ppapi_host_(ppapi_host) {
}
ppapi_host_(ppapi_host) {}
PepperIsolatedFileSystemMessageFilter::
~PepperIsolatedFileSystemMessageFilter() {}
@ -63,8 +60,7 @@ int32_t PepperIsolatedFileSystemMessageFilter::OnResourceMessageReceived(
ppapi::host::HostMessageContext* context) {
PPAPI_BEGIN_MESSAGE_MAP(PepperIsolatedFileSystemMessageFilter, msg)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
PpapiHostMsg_IsolatedFileSystem_BrowserOpen,
OnOpenFileSystem)
PpapiHostMsg_IsolatedFileSystem_BrowserOpen, OnOpenFileSystem)
PPAPI_END_MESSAGE_MAP()
return PP_ERROR_FAILED;
}

View file

@ -6,29 +6,27 @@
#include "base/bind.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/webplugininfo.h"
#include "content/public/browser/plugin_service.h"
#include "media/media_features.h"
using content::BrowserThread;
using content::PluginService;
using content::WebPluginInfo;
using content::BrowserThread;
WidevineCdmMessageFilter::WidevineCdmMessageFilter(
int render_process_id,
content::BrowserContext* browser_context)
: BrowserMessageFilter(ChromeMsgStart),
render_process_id_(render_process_id),
browser_context_(browser_context) {
}
browser_context_(browser_context) {}
bool WidevineCdmMessageFilter::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(WidevineCdmMessageFilter, message)
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
IPC_MESSAGE_HANDLER(
ChromeViewHostMsg_IsInternalPluginAvailableForMimeType,
OnIsInternalPluginAvailableForMimeType)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_IsInternalPluginAvailableForMimeType,
OnIsInternalPluginAvailableForMimeType)
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
IPC_MESSAGE_UNHANDLED(return false)
IPC_END_MESSAGE_MAP()
@ -49,7 +47,6 @@ void WidevineCdmMessageFilter::OnIsInternalPluginAvailableForMimeType(
const std::vector<content::WebPluginMimeType>& mime_types =
plugin.mime_types;
for (size_t j = 0; j < mime_types.size(); ++j) {
if (mime_types[j].mime_type == mime_type) {
*is_available = true;
*additional_param_names = mime_types[j].additional_param_names;
@ -67,5 +64,4 @@ void WidevineCdmMessageFilter::OnDestruct() const {
BrowserThread::DeleteOnUIThread::Destruct(this);
}
WidevineCdmMessageFilter::~WidevineCdmMessageFilter() {
}
WidevineCdmMessageFilter::~WidevineCdmMessageFilter() {}

View file

@ -27,36 +27,26 @@ std::string TrimLanguageCode(std::string lang) {
} // namespace
bool IsFinalTtsEventType(TtsEventType event_type) {
return (event_type == TTS_EVENT_END ||
event_type == TTS_EVENT_INTERRUPTED ||
event_type == TTS_EVENT_CANCELLED ||
event_type == TTS_EVENT_ERROR);
return (event_type == TTS_EVENT_END || event_type == TTS_EVENT_INTERRUPTED ||
event_type == TTS_EVENT_CANCELLED || event_type == TTS_EVENT_ERROR);
}
//
// UtteranceContinuousParameters
//
UtteranceContinuousParameters::UtteranceContinuousParameters()
: rate(-1),
pitch(-1),
volume(-1) {}
: rate(-1), pitch(-1), volume(-1) {}
//
// VoiceData
//
VoiceData::VoiceData()
: gender(TTS_GENDER_NONE),
remote(false),
native(false) {}
: gender(TTS_GENDER_NONE), remote(false), native(false) {}
VoiceData::~VoiceData() {}
//
// Utterance
//
@ -118,8 +108,7 @@ TtsControllerImpl::TtsControllerImpl()
: current_utterance_(NULL),
paused_(false),
platform_impl_(NULL),
tts_engine_delegate_(NULL) {
}
tts_engine_delegate_(NULL) {}
TtsControllerImpl::~TtsControllerImpl() {
if (current_utterance_) {
@ -215,12 +204,9 @@ void TtsControllerImpl::SpeakNow(Utterance* utterance) {
// during |speak|.
current_utterance_ = utterance;
GetPlatformImpl()->clear_error();
bool success = GetPlatformImpl()->Speak(
utterance->id(),
utterance->text(),
utterance->lang(),
voice,
utterance->continuous_parameters());
bool success = GetPlatformImpl()->Speak(utterance->id(), utterance->text(),
utterance->lang(), voice,
utterance->continuous_parameters());
if (!success)
current_utterance_ = NULL;
@ -288,9 +274,9 @@ void TtsControllerImpl::Resume() {
}
void TtsControllerImpl::OnTtsEvent(int utterance_id,
TtsEventType event_type,
int char_index,
const std::string& error_message) {
TtsEventType event_type,
int char_index,
const std::string& error_message) {
// We may sometimes receive completion callbacks "late", after we've
// already finished the utterance (for example because another utterance
// interrupted or we got a call to Stop). This is normal and we can
@ -306,7 +292,7 @@ void TtsControllerImpl::OnTtsEvent(int utterance_id,
}
void TtsControllerImpl::GetVoices(content::BrowserContext* browser_context,
std::vector<VoiceData>* out_voices) {
std::vector<VoiceData>* out_voices) {
#if !defined(OS_ANDROID)
if (browser_context && tts_engine_delegate_)
tts_engine_delegate_->GetVoices(browser_context, out_voices);
@ -362,8 +348,7 @@ void TtsControllerImpl::ClearUtteranceQueue(bool send_events) {
}
}
void TtsControllerImpl::SetPlatformImpl(
TtsPlatformImpl* platform_impl) {
void TtsControllerImpl::SetPlatformImpl(TtsPlatformImpl* platform_impl) {
platform_impl_ = platform_impl;
}
@ -377,8 +362,8 @@ TtsPlatformImpl* TtsControllerImpl::GetPlatformImpl() {
return platform_impl_;
}
int TtsControllerImpl::GetMatchingVoice(
const Utterance* utterance, std::vector<VoiceData>& voices) {
int TtsControllerImpl::GetMatchingVoice(const Utterance* utterance,
std::vector<VoiceData>& voices) {
// Make two passes: the first time, do strict language matching
// ('fr-FR' does not match 'fr-CA'). The second time, do prefix
// language matching ('fr-FR' matches 'fr' and 'fr-CA')
@ -391,8 +376,7 @@ int TtsControllerImpl::GetMatchingVoice(
continue;
}
if (!voice.name.empty() &&
!utterance->voice_name().empty() &&
if (!voice.name.empty() && !utterance->voice_name().empty() &&
voice.name != utterance->voice_name()) {
continue;
}
@ -417,8 +401,7 @@ int TtsControllerImpl::GetMatchingVoice(
bool has_all_required_event_types = true;
for (std::set<TtsEventType>::const_iterator iter =
utterance->required_event_types().begin();
iter != utterance->required_event_types().end();
++iter) {
iter != utterance->required_event_types().end(); ++iter) {
if (voice.events.find(*iter) == voice.events.end()) {
has_all_required_event_types = false;
break;
@ -453,8 +436,7 @@ void TtsControllerImpl::RemoveVoicesChangedDelegate(
voices_changed_delegates_.erase(delegate);
}
void TtsControllerImpl::SetTtsEngineDelegate(
TtsEngineDelegate* delegate) {
void TtsControllerImpl::SetTtsEngineDelegate(TtsEngineDelegate* delegate) {
tts_engine_delegate_ = delegate;
}

View file

@ -81,7 +81,7 @@ class TtsPlatformImplLinux : public TtsPlatformImpl {
// Map a string composed of a voicename and module to the voicename. Used to
// uniquely identify a voice across all available modules.
std::unique_ptr<std::map<std::string, SPDChromeVoice> > all_native_voices_;
std::unique_ptr<std::map<std::string, SPDChromeVoice>> all_native_voices_;
friend struct base::DefaultSingletonTraits<TtsPlatformImplLinux>;
@ -89,20 +89,17 @@ class TtsPlatformImplLinux : public TtsPlatformImpl {
};
// static
SPDNotificationType TtsPlatformImplLinux::current_notification_ =
SPD_EVENT_END;
SPDNotificationType TtsPlatformImplLinux::current_notification_ = SPD_EVENT_END;
TtsPlatformImplLinux::TtsPlatformImplLinux()
: utterance_id_(0) {
TtsPlatformImplLinux::TtsPlatformImplLinux() : utterance_id_(0) {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (!command_line.HasSwitch(switches::kEnableSpeechDispatcher))
return;
BrowserThread::PostTask(BrowserThread::FILE,
FROM_HERE,
base::Bind(&TtsPlatformImplLinux::Initialize,
base::Unretained(this)));
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(&TtsPlatformImplLinux::Initialize, base::Unretained(this)));
}
void TtsPlatformImplLinux::Initialize() {
@ -115,19 +112,15 @@ void TtsPlatformImplLinux::Initialize() {
// spd_open has memory leaks which are hard to suppress.
// http://crbug.com/317360
ANNOTATE_SCOPED_MEMORY_LEAK;
conn_ = libspeechd_loader_.spd_open(
"chrome", "extension_api", NULL, SPD_MODE_THREADED);
conn_ = libspeechd_loader_.spd_open("chrome", "extension_api", NULL,
SPD_MODE_THREADED);
}
if (!conn_)
return;
// Register callbacks for all events.
conn_->callback_begin =
conn_->callback_end =
conn_->callback_cancel =
conn_->callback_pause =
conn_->callback_resume =
&NotificationCallback;
conn_->callback_begin = conn_->callback_end = conn_->callback_cancel =
conn_->callback_pause = conn_->callback_resume = &NotificationCallback;
conn_->callback_im = &IndexMarkCallback;
@ -150,8 +143,8 @@ void TtsPlatformImplLinux::Reset() {
base::AutoLock lock(initialization_lock_);
if (conn_)
libspeechd_loader_.spd_close(conn_);
conn_ = libspeechd_loader_.spd_open(
"chrome", "extension_api", NULL, SPD_MODE_THREADED);
conn_ = libspeechd_loader_.spd_open("chrome", "extension_api", NULL,
SPD_MODE_THREADED);
}
bool TtsPlatformImplLinux::PlatformImplAvailable() {
@ -162,12 +155,11 @@ bool TtsPlatformImplLinux::PlatformImplAvailable() {
return result;
}
bool TtsPlatformImplLinux::Speak(
int utterance_id,
const std::string& utterance,
const std::string& lang,
const VoiceData& voice,
const UtteranceContinuousParameters& params) {
bool TtsPlatformImplLinux::Speak(int utterance_id,
const std::string& utterance,
const std::string& lang,
const VoiceData& voice,
const UtteranceContinuousParameters& params) {
if (!PlatformImplAvailable()) {
error_ = kNotSupportedError;
return false;
@ -232,8 +224,7 @@ bool TtsPlatformImplLinux::IsSpeaking() {
return current_notification_ == SPD_EVENT_BEGIN;
}
void TtsPlatformImplLinux::GetVoices(
std::vector<VoiceData>* out_voices) {
void TtsPlatformImplLinux::GetVoices(std::vector<VoiceData>* out_voices) {
if (!all_native_voices_.get()) {
all_native_voices_.reset(new std::map<std::string, SPDChromeVoice>());
char** modules = libspeechd_loader_.spd_list_modules(conn_);
@ -267,8 +258,7 @@ void TtsPlatformImplLinux::GetVoices(
for (std::map<std::string, SPDChromeVoice>::iterator it =
all_native_voices_->begin();
it != all_native_voices_->end();
it++) {
it != all_native_voices_->end(); it++) {
out_voices->push_back(VoiceData());
VoiceData& voice = out_voices->back();
voice.native = true;
@ -285,40 +275,40 @@ void TtsPlatformImplLinux::GetVoices(
void TtsPlatformImplLinux::OnSpeechEvent(SPDNotificationType type) {
TtsController* controller = TtsController::GetInstance();
switch (type) {
case SPD_EVENT_BEGIN:
controller->OnTtsEvent(utterance_id_, TTS_EVENT_START, 0, std::string());
break;
case SPD_EVENT_RESUME:
controller->OnTtsEvent(utterance_id_, TTS_EVENT_RESUME, 0, std::string());
break;
case SPD_EVENT_END:
controller->OnTtsEvent(
utterance_id_, TTS_EVENT_END, utterance_.size(), std::string());
break;
case SPD_EVENT_PAUSE:
controller->OnTtsEvent(
utterance_id_, TTS_EVENT_PAUSE, utterance_.size(), std::string());
break;
case SPD_EVENT_CANCEL:
controller->OnTtsEvent(
utterance_id_, TTS_EVENT_CANCELLED, 0, std::string());
break;
case SPD_EVENT_INDEX_MARK:
controller->OnTtsEvent(utterance_id_, TTS_EVENT_MARKER, 0, std::string());
break;
case SPD_EVENT_BEGIN:
controller->OnTtsEvent(utterance_id_, TTS_EVENT_START, 0, std::string());
break;
case SPD_EVENT_RESUME:
controller->OnTtsEvent(utterance_id_, TTS_EVENT_RESUME, 0, std::string());
break;
case SPD_EVENT_END:
controller->OnTtsEvent(utterance_id_, TTS_EVENT_END, utterance_.size(),
std::string());
break;
case SPD_EVENT_PAUSE:
controller->OnTtsEvent(utterance_id_, TTS_EVENT_PAUSE, utterance_.size(),
std::string());
break;
case SPD_EVENT_CANCEL:
controller->OnTtsEvent(utterance_id_, TTS_EVENT_CANCELLED, 0,
std::string());
break;
case SPD_EVENT_INDEX_MARK:
controller->OnTtsEvent(utterance_id_, TTS_EVENT_MARKER, 0, std::string());
break;
}
}
// static
void TtsPlatformImplLinux::NotificationCallback(
size_t msg_id, size_t client_id, SPDNotificationType type) {
void TtsPlatformImplLinux::NotificationCallback(size_t msg_id,
size_t client_id,
SPDNotificationType type) {
// We run Speech Dispatcher in threaded mode, so these callbacks should always
// be in a separate thread.
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
current_notification_ = type;
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
BrowserThread::UI, FROM_HERE,
base::Bind(&TtsPlatformImplLinux::OnSpeechEvent,
base::Unretained(TtsPlatformImplLinux::GetInstance()),
type));
@ -327,9 +317,9 @@ void TtsPlatformImplLinux::NotificationCallback(
// static
void TtsPlatformImplLinux::IndexMarkCallback(size_t msg_id,
size_t client_id,
SPDNotificationType state,
char* index_mark) {
size_t client_id,
SPDNotificationType state,
char* index_mark) {
// TODO(dtseng): index_mark appears to specify an index type supplied by a
// client. Need to explore how this is used before hooking it up with existing
// word, sentence events.
@ -337,10 +327,11 @@ void TtsPlatformImplLinux::IndexMarkCallback(size_t msg_id,
// be in a separate thread.
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
current_notification_ = state;
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&TtsPlatformImplLinux::OnSpeechEvent,
base::Unretained(TtsPlatformImplLinux::GetInstance()),
state));
base::Unretained(TtsPlatformImplLinux::GetInstance()),
state));
}
}

View file

@ -25,16 +25,16 @@ TtsMessageFilter::TtsMessageFilter(int render_process_id,
AddRef();
}
void TtsMessageFilter::OverrideThreadForMessage(
const IPC::Message& message, BrowserThread::ID* thread) {
void TtsMessageFilter::OverrideThreadForMessage(const IPC::Message& message,
BrowserThread::ID* thread) {
switch (message.type()) {
case TtsHostMsg_InitializeVoiceList::ID:
case TtsHostMsg_Speak::ID:
case TtsHostMsg_Pause::ID:
case TtsHostMsg_Resume::ID:
case TtsHostMsg_Cancel::ID:
*thread = BrowserThread::UI;
break;
case TtsHostMsg_InitializeVoiceList::ID:
case TtsHostMsg_Speak::ID:
case TtsHostMsg_Pause::ID:
case TtsHostMsg_Resume::ID:
case TtsHostMsg_Cancel::ID:
*thread = BrowserThread::UI;
break;
}
}
@ -144,8 +144,8 @@ void TtsMessageFilter::OnTtsEvent(Utterance* utterance,
Send(new TtsMsg_WasCancelled(utterance->src_id()));
break;
case TTS_EVENT_ERROR:
Send(new TtsMsg_SpeakingErrorOccurred(
utterance->src_id(), error_message));
Send(
new TtsMsg_SpeakingErrorOccurred(utterance->src_id(), error_message));
break;
case TTS_EVENT_PAUSE:
Send(new TtsMsg_DidPauseSpeaking(utterance->src_id()));

View file

@ -16,16 +16,13 @@
class TtsPlatformImplWin : public TtsPlatformImpl {
public:
bool PlatformImplAvailable() override {
return true;
}
bool PlatformImplAvailable() override { return true; }
bool Speak(
int utterance_id,
const std::string& utterance,
const std::string& lang,
const VoiceData& voice,
const UtteranceContinuousParameters& params) override;
bool Speak(int utterance_id,
const std::string& utterance,
const std::string& lang,
const VoiceData& voice,
const UtteranceContinuousParameters& params) override;
bool StopSpeaking() override;
@ -68,12 +65,11 @@ TtsPlatformImpl* TtsPlatformImpl::GetInstance() {
return TtsPlatformImplWin::GetInstance();
}
bool TtsPlatformImplWin::Speak(
int utterance_id,
const std::string& src_utterance,
const std::string& lang,
const VoiceData& voice,
const UtteranceContinuousParameters& params) {
bool TtsPlatformImplWin::Speak(int utterance_id,
const std::string& src_utterance,
const std::string& lang,
const VoiceData& voice,
const UtteranceContinuousParameters& params) {
std::wstring prefix;
std::wstring suffix;
@ -114,10 +110,8 @@ bool TtsPlatformImplWin::Speak(
std::wstring merged_utterance = prefix + utterance_ + suffix;
prefix_len_ = prefix.size();
HRESULT result = speech_synthesizer_->Speak(
merged_utterance.c_str(),
SPF_ASYNC,
&stream_number_);
HRESULT result = speech_synthesizer_->Speak(merged_utterance.c_str(),
SPF_ASYNC, &stream_number_);
return (result == S_OK);
}
@ -143,8 +137,8 @@ void TtsPlatformImplWin::Pause() {
if (speech_synthesizer_.Get() && utterance_id_ && !paused_) {
speech_synthesizer_->Pause();
paused_ = true;
TtsController::GetInstance()->OnTtsEvent(
utterance_id_, TTS_EVENT_PAUSE, char_position_, "");
TtsController::GetInstance()->OnTtsEvent(utterance_id_, TTS_EVENT_PAUSE,
char_position_, "");
}
}
@ -152,8 +146,8 @@ void TtsPlatformImplWin::Resume() {
if (speech_synthesizer_.Get() && utterance_id_ && paused_) {
speech_synthesizer_->Resume();
paused_ = false;
TtsController::GetInstance()->OnTtsEvent(
utterance_id_, TTS_EVENT_RESUME, char_position_, "");
TtsController::GetInstance()->OnTtsEvent(utterance_id_, TTS_EVENT_RESUME,
char_position_, "");
}
}
@ -171,8 +165,7 @@ bool TtsPlatformImplWin::IsSpeaking() {
return false;
}
void TtsPlatformImplWin::GetVoices(
std::vector<VoiceData>* out_voices) {
void TtsPlatformImplWin::GetVoices(std::vector<VoiceData>* out_voices) {
// TODO: get all voices, not just default voice.
// http://crbug.com/88059
out_voices->push_back(VoiceData());
@ -196,51 +189,47 @@ void TtsPlatformImplWin::OnSpeechEvent() {
continue;
switch (event.eEventId) {
case SPEI_START_INPUT_STREAM:
controller->OnTtsEvent(
utterance_id_, TTS_EVENT_START, 0, std::string());
break;
case SPEI_END_INPUT_STREAM:
char_position_ = utterance_.size();
controller->OnTtsEvent(
utterance_id_, TTS_EVENT_END, char_position_, std::string());
break;
case SPEI_TTS_BOOKMARK:
controller->OnTtsEvent(
utterance_id_, TTS_EVENT_MARKER, char_position_, std::string());
break;
case SPEI_WORD_BOUNDARY:
char_position_ = static_cast<ULONG>(event.lParam) - prefix_len_;
controller->OnTtsEvent(
utterance_id_, TTS_EVENT_WORD, char_position_,
std::string());
break;
case SPEI_SENTENCE_BOUNDARY:
char_position_ = static_cast<ULONG>(event.lParam) - prefix_len_;
controller->OnTtsEvent(
utterance_id_, TTS_EVENT_SENTENCE, char_position_,
std::string());
break;
default:
break;
case SPEI_START_INPUT_STREAM:
controller->OnTtsEvent(utterance_id_, TTS_EVENT_START, 0,
std::string());
break;
case SPEI_END_INPUT_STREAM:
char_position_ = utterance_.size();
controller->OnTtsEvent(utterance_id_, TTS_EVENT_END, char_position_,
std::string());
break;
case SPEI_TTS_BOOKMARK:
controller->OnTtsEvent(utterance_id_, TTS_EVENT_MARKER, char_position_,
std::string());
break;
case SPEI_WORD_BOUNDARY:
char_position_ = static_cast<ULONG>(event.lParam) - prefix_len_;
controller->OnTtsEvent(utterance_id_, TTS_EVENT_WORD, char_position_,
std::string());
break;
case SPEI_SENTENCE_BOUNDARY:
char_position_ = static_cast<ULONG>(event.lParam) - prefix_len_;
controller->OnTtsEvent(utterance_id_, TTS_EVENT_SENTENCE,
char_position_, std::string());
break;
default:
break;
}
}
}
TtsPlatformImplWin::TtsPlatformImplWin()
: utterance_id_(0),
prefix_len_(0),
stream_number_(0),
char_position_(0),
paused_(false) {
: utterance_id_(0),
prefix_len_(0),
stream_number_(0),
char_position_(0),
paused_(false) {
::CoCreateInstance(CLSID_SpVoice, nullptr, CLSCTX_ALL,
IID_PPV_ARGS(&speech_synthesizer_));
if (speech_synthesizer_.Get()) {
ULONGLONG event_mask =
SPFEI(SPEI_START_INPUT_STREAM) |
SPFEI(SPEI_TTS_BOOKMARK) |
SPFEI(SPEI_WORD_BOUNDARY) |
SPFEI(SPEI_SENTENCE_BOUNDARY) |
SPFEI(SPEI_START_INPUT_STREAM) | SPFEI(SPEI_TTS_BOOKMARK) |
SPFEI(SPEI_WORD_BOUNDARY) | SPFEI(SPEI_SENTENCE_BOUNDARY) |
SPFEI(SPEI_END_INPUT_STREAM);
speech_synthesizer_->SetInterest(event_mask, event_mask);
speech_synthesizer_->SetNotifyCallbackFunction(
@ -255,7 +244,6 @@ TtsPlatformImplWin* TtsPlatformImplWin::GetInstance() {
}
// static
void TtsPlatformImplWin::SpeechEventCallback(
WPARAM w_param, LPARAM l_param) {
void TtsPlatformImplWin::SpeechEventCallback(WPARAM w_param, LPARAM l_param) {
GetInstance()->OnSpeechEvent();
}

View file

@ -128,7 +128,7 @@ void SecurityStateTabHelper::DidStartNavigation(
void SecurityStateTabHelper::DidFinishNavigation(
content::NavigationHandle* navigation_handle) {
if (navigation_handle->IsInMainFrame() &&
!navigation_handle->IsSameDocument()) {
!navigation_handle->IsSameDocument()) {
// Only reset the console message flag for main-frame navigations,
// and not for same-page navigations like reference fragments and pushState.
logged_http_warning_on_current_navigation_ = false;

View file

@ -52,8 +52,8 @@ void ColorChooserAura::SetSelectedColor(SkColor color) {
}
// static
ColorChooserAura* ColorChooserAura::Open(
content::WebContents* web_contents, SkColor initial_color) {
ColorChooserAura* ColorChooserAura::Open(content::WebContents* web_contents,
SkColor initial_color) {
return new ColorChooserAura(web_contents, initial_color);
}

View file

@ -22,10 +22,7 @@ COLORREF ColorChooserDialog::g_custom_colors[16];
ColorChooserDialog::ExecuteOpenParams::ExecuteOpenParams(SkColor color,
RunState run_state,
HWND owner)
: color(color),
run_state(run_state),
owner(owner) {
}
: color(color), run_state(run_state), owner(owner) {}
ColorChooserDialog::ColorChooserDialog(views::ColorChooserListener* listener,
SkColor initial_color,
@ -36,16 +33,16 @@ ColorChooserDialog::ColorChooserDialog(views::ColorChooserListener* listener,
HWND owning_hwnd = views::HWNDForNativeWindow(owning_window);
ExecuteOpenParams execute_params(initial_color, BeginRun(owning_hwnd),
owning_hwnd);
execute_params.run_state.dialog_thread->task_runner()->PostTask(FROM_HERE,
execute_params.run_state.dialog_thread->task_runner()->PostTask(
FROM_HERE,
base::Bind(&ColorChooserDialog::ExecuteOpen, this, execute_params));
}
ColorChooserDialog::~ColorChooserDialog() {
}
ColorChooserDialog::~ColorChooserDialog() {}
bool ColorChooserDialog::IsRunning(gfx::NativeWindow owning_window) const {
return listener_ && IsRunningDialogForOwner(
views::HWNDForNativeWindow(owning_window));
return listener_ &&
IsRunningDialogForOwner(views::HWNDForNativeWindow(owning_window));
}
void ColorChooserDialog::ListenerDestroyed() {
@ -63,7 +60,8 @@ void ColorChooserDialog::ExecuteOpen(const ExecuteOpenParams& params) {
cc.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT;
bool success = !!ChooseColor(&cc);
DisableOwner(cc.hwndOwner);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&ColorChooserDialog::DidCloseDialog, this, success,
skia::COLORREFToSkColor(cc.rgbResult), params.run_state));
}

View file

@ -21,8 +21,7 @@ class ColorChooserWin : public content::ColorChooser,
static ColorChooserWin* Open(content::WebContents* web_contents,
SkColor initial_color);
ColorChooserWin(content::WebContents* web_contents,
SkColor initial_color);
ColorChooserWin(content::WebContents* web_contents, SkColor initial_color);
~ColorChooserWin();
// content::ColorChooser overrides:
@ -58,13 +57,12 @@ ColorChooserWin::ColorChooserWin(content::WebContents* web_contents,
SkColor initial_color)
: web_contents_(web_contents) {
gfx::NativeWindow owning_window = web_contents->GetRenderViewHost()
->GetWidget()
->GetView()
->GetNativeView()
->GetToplevelWindow();
color_chooser_dialog_ = new ColorChooserDialog(this,
initial_color,
owning_window);
->GetWidget()
->GetView()
->GetNativeView()
->GetToplevelWindow();
color_chooser_dialog_ =
new ColorChooserDialog(this, initial_color, owning_window);
}
ColorChooserWin::~ColorChooserWin() {

View file

@ -45,24 +45,19 @@ GlobalMenuBarRegistrarX11::GlobalMenuBarRegistrarX11()
// even when |connection_type| is set to SHARED.
g_dbus_proxy_new_for_bus(
G_BUS_TYPE_SESSION,
static_cast<GDBusProxyFlags>(
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START),
nullptr,
kAppMenuRegistrarName,
kAppMenuRegistrarPath,
static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START),
nullptr, kAppMenuRegistrarName, kAppMenuRegistrarPath,
kAppMenuRegistrarName,
nullptr, // TODO: Probalby want a real cancelable.
static_cast<GAsyncReadyCallback>(OnProxyCreatedThunk),
this);
static_cast<GAsyncReadyCallback>(OnProxyCreatedThunk), this);
}
GlobalMenuBarRegistrarX11::~GlobalMenuBarRegistrarX11() {
if (registrar_proxy_) {
g_signal_handlers_disconnect_by_func(
registrar_proxy_,
reinterpret_cast<void*>(OnNameOwnerChangedThunk),
registrar_proxy_, reinterpret_cast<void*>(OnNameOwnerChangedThunk),
this);
g_object_unref(registrar_proxy_);
}
@ -72,7 +67,7 @@ void GlobalMenuBarRegistrarX11::RegisterXID(unsigned long xid) {
DCHECK(registrar_proxy_);
std::string path = atom::GlobalMenuBarX11::GetPathForWindow(xid);
ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/314087
ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/314087
// TODO(erg): The mozilla implementation goes to a lot of callback trouble
// just to make sure that they react to make sure there's some sort of
// cancelable object; including making a whole callback just to handle the
@ -80,20 +75,16 @@ void GlobalMenuBarRegistrarX11::RegisterXID(unsigned long xid) {
//
// I don't see any reason why we should care if "RegisterWindow" completes or
// not.
g_dbus_proxy_call(registrar_proxy_,
"RegisterWindow",
g_dbus_proxy_call(registrar_proxy_, "RegisterWindow",
g_variant_new("(uo)", xid, path.c_str()),
G_DBUS_CALL_FLAGS_NONE, -1,
nullptr,
nullptr,
nullptr);
G_DBUS_CALL_FLAGS_NONE, -1, nullptr, nullptr, nullptr);
}
void GlobalMenuBarRegistrarX11::UnregisterXID(unsigned long xid) {
DCHECK(registrar_proxy_);
std::string path = atom::GlobalMenuBarX11::GetPathForWindow(xid);
ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/314087
ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/314087
// TODO(erg): The mozilla implementation goes to a lot of callback trouble
// just to make sure that they react to make sure there's some sort of
// cancelable object; including making a whole callback just to handle the
@ -101,13 +92,9 @@ void GlobalMenuBarRegistrarX11::UnregisterXID(unsigned long xid) {
//
// I don't see any reason why we should care if "UnregisterWindow" completes
// or not.
g_dbus_proxy_call(registrar_proxy_,
"UnregisterWindow",
g_variant_new("(u)", xid),
G_DBUS_CALL_FLAGS_NONE, -1,
nullptr,
nullptr,
nullptr);
g_dbus_proxy_call(registrar_proxy_, "UnregisterWindow",
g_variant_new("(u)", xid), G_DBUS_CALL_FLAGS_NONE, -1,
nullptr, nullptr, nullptr);
}
void GlobalMenuBarRegistrarX11::OnProxyCreated(GObject* source,