Merge pull request #9076 from electron/cleanup-cpp

Cleanup cpp codebase
This commit is contained in:
Kevin Sawicki 2017-04-03 08:30:08 -07:00 committed by GitHub
commit f5a75c4e87
29 changed files with 75 additions and 68 deletions

View file

@ -44,7 +44,7 @@ content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
std::vector<std::string> flash_version_numbers = base::SplitString( std::vector<std::string> flash_version_numbers = base::SplitString(
version, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); version, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
if (flash_version_numbers.size() < 1) if (flash_version_numbers.empty())
flash_version_numbers.push_back("11"); flash_version_numbers.push_back("11");
// |SplitString()| puts in an empty string given an empty string. :( // |SplitString()| puts in an empty string given an empty string. :(
else if (flash_version_numbers[0].empty()) else if (flash_version_numbers[0].empty())

View file

@ -427,7 +427,7 @@ void OnClientCertificateSelected(
auto certs = net::X509Certificate::CreateCertificateListFromBytes( auto certs = net::X509Certificate::CreateCertificateListFromBytes(
data.c_str(), data.length(), net::X509Certificate::FORMAT_AUTO); data.c_str(), data.length(), net::X509Certificate::FORMAT_AUTO);
if (certs.size() > 0) if (!certs.empty())
delegate->ContinueWithCertificate(certs[0].get()); delegate->ContinueWithCertificate(certs[0].get());
} }
@ -520,7 +520,7 @@ void App::OnQuit() {
int exitCode = AtomBrowserMainParts::Get()->GetExitCode(); int exitCode = AtomBrowserMainParts::Get()->GetExitCode();
Emit("quit", exitCode); Emit("quit", exitCode);
if (process_singleton_.get()) { if (process_singleton_) {
process_singleton_->Cleanup(); process_singleton_->Cleanup();
process_singleton_.reset(); process_singleton_.reset();
} }
@ -695,7 +695,7 @@ std::string App::GetLocale() {
bool App::MakeSingleInstance( bool App::MakeSingleInstance(
const ProcessSingleton::NotificationCallback& callback) { const ProcessSingleton::NotificationCallback& callback) {
if (process_singleton_.get()) if (process_singleton_)
return false; return false;
base::FilePath user_dir; base::FilePath user_dir;
@ -716,7 +716,7 @@ bool App::MakeSingleInstance(
} }
void App::ReleaseSingleInstance() { void App::ReleaseSingleInstance() {
if (process_singleton_.get()) { if (process_singleton_) {
process_singleton_->Cleanup(); process_singleton_->Cleanup();
process_singleton_.reset(); process_singleton_.reset();
} }

View file

@ -88,7 +88,7 @@ void AutoUpdater::SetFeedURL(const std::string& url, mate::Arguments* args) {
void AutoUpdater::QuitAndInstall() { void AutoUpdater::QuitAndInstall() {
// If we don't have any window then quitAndInstall immediately. // If we don't have any window then quitAndInstall immediately.
WindowList* window_list = WindowList::GetInstance(); WindowList* window_list = WindowList::GetInstance();
if (window_list->size() == 0) { if (window_list->empty()) {
auto_updater::AutoUpdater::QuitAndInstall(); auto_updater::AutoUpdater::QuitAndInstall();
return; return;
} }

View file

@ -78,13 +78,14 @@ void ShowMessageBox(int type,
if (mate::Converter<atom::MessageBoxCallback>::FromV8(args->isolate(), if (mate::Converter<atom::MessageBoxCallback>::FromV8(args->isolate(),
peek, peek,
&callback)) { &callback)) {
atom::ShowMessageBox(window, (atom::MessageBoxType)type, buttons, atom::ShowMessageBox(window, static_cast<atom::MessageBoxType>(type),
default_id, cancel_id, options, title, message, detail, buttons, default_id, cancel_id, options, title,
checkbox_label, checkbox_checked, icon, callback); message, detail, checkbox_label, checkbox_checked,
icon, callback);
} else { } else {
int chosen = atom::ShowMessageBox(window, (atom::MessageBoxType)type, int chosen = atom::ShowMessageBox(
buttons, default_id, cancel_id, window, static_cast<atom::MessageBoxType>(type), buttons, default_id,
options, title, message, detail, icon); cancel_id, options, title, message, detail, icon);
args->Return(chosen); args->Return(chosen);
} }
} }

View file

@ -233,7 +233,7 @@ class ResolveProxyHelper {
public: public:
ResolveProxyHelper(AtomBrowserContext* browser_context, ResolveProxyHelper(AtomBrowserContext* browser_context,
const GURL& url, const GURL& url,
Session::ResolveProxyCallback callback) const Session::ResolveProxyCallback& callback)
: callback_(callback), : callback_(callback),
original_thread_(base::ThreadTaskRunnerHandle::Get()) { original_thread_(base::ThreadTaskRunnerHandle::Get()) {
scoped_refptr<net::URLRequestContextGetter> context_getter = scoped_refptr<net::URLRequestContextGetter> context_getter =

View file

@ -240,7 +240,7 @@ content::ServiceWorkerContext* GetServiceWorkerContext(
} }
// Called when CapturePage is done. // Called when CapturePage is done.
void OnCapturePageDone(base::Callback<void(const gfx::Image&)> callback, void OnCapturePageDone(const base::Callback<void(const gfx::Image&)>& callback,
const SkBitmap& bitmap, const SkBitmap& bitmap,
content::ReadbackResponse response) { content::ReadbackResponse response) {
callback.Run(gfx::Image::CreateFrom1xBitmap(bitmap)); callback.Run(gfx::Image::CreateFrom1xBitmap(bitmap));

View file

@ -27,7 +27,7 @@ namespace {
bool g_update_available = false; bool g_update_available = false;
std::string update_url_ = ""; std::string update_url_ = "";
} } // namespace
std::string AutoUpdater::GetFeedURL() { std::string AutoUpdater::GetFeedURL() {
return update_url_; return update_url_;

View file

@ -44,7 +44,7 @@ void Browser::Quit() {
return; return;
atom::WindowList* window_list = atom::WindowList::GetInstance(); atom::WindowList* window_list = atom::WindowList::GetInstance();
if (window_list->size() == 0) if (window_list->empty())
NotifyAndShutdown(); NotifyAndShutdown();
window_list->CloseAllWindows(); window_list->CloseAllWindows();
@ -66,7 +66,7 @@ void Browser::Exit(mate::Arguments* args) {
// Must destroy windows before quitting, otherwise bad things can happen. // Must destroy windows before quitting, otherwise bad things can happen.
atom::WindowList* window_list = atom::WindowList::GetInstance(); atom::WindowList* window_list = atom::WindowList::GetInstance();
if (window_list->size() == 0) { if (window_list->empty()) {
Shutdown(); Shutdown();
} else { } else {
// Unlike Quit(), we do not ask to close window, but destroy the window // Unlike Quit(), we do not ask to close window, but destroy the window

View file

@ -102,7 +102,7 @@ class Browser : public WindowListObserver {
std::vector<base::string16> args; std::vector<base::string16> args;
}; };
void SetLoginItemSettings(LoginItemSettings settings); void SetLoginItemSettings(LoginItemSettings settings);
LoginItemSettings GetLoginItemSettings(LoginItemSettings options); LoginItemSettings GetLoginItemSettings(const LoginItemSettings& options);
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Hide the application. // Hide the application.

View file

@ -64,7 +64,7 @@ void Browser::SetLoginItemSettings(LoginItemSettings settings) {
} }
Browser::LoginItemSettings Browser::GetLoginItemSettings( Browser::LoginItemSettings Browser::GetLoginItemSettings(
LoginItemSettings options) { const LoginItemSettings& options) {
return LoginItemSettings(); return LoginItemSettings();
} }

View file

@ -64,8 +64,9 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
// On macOS, we can't query the default, but the handlers list seems to put // On macOS, we can't query the default, but the handlers list seems to put
// Apple's defaults first, so we'll use the first option that isn't our bundle // Apple's defaults first, so we'll use the first option that isn't our bundle
CFStringRef other = nil; CFStringRef other = nil;
for (CFIndex i = 0; i < CFArrayGetCount(bundleList); i++) { for (CFIndex i = 0; i < CFArrayGetCount(bundleList); ++i) {
other = (CFStringRef)CFArrayGetValueAtIndex(bundleList, i); other = base::mac::CFCast<CFStringRef>(CFArrayGetValueAtIndex(bundleList,
i));
if (![identifier isEqualToString: (__bridge NSString *)other]) { if (![identifier isEqualToString: (__bridge NSString *)other]) {
break; break;
} }
@ -152,7 +153,7 @@ bool Browser::ContinueUserActivity(const std::string& type,
} }
Browser::LoginItemSettings Browser::GetLoginItemSettings( Browser::LoginItemSettings Browser::GetLoginItemSettings(
LoginItemSettings options) { const LoginItemSettings& options) {
LoginItemSettings settings; LoginItemSettings settings;
settings.open_at_login = base::mac::CheckLoginItemStatus( settings.open_at_login = base::mac::CheckLoginItemStatus(
&settings.open_as_hidden); &settings.open_as_hidden);
@ -179,7 +180,7 @@ std::string Browser::GetExecutableFileProductName() const {
int Browser::DockBounce(BounceType type) { int Browser::DockBounce(BounceType type) {
return [[AtomApplication sharedApplication] return [[AtomApplication sharedApplication]
requestUserAttention:(NSRequestUserAttentionType)type]; requestUserAttention:static_cast<NSRequestUserAttentionType>(type)];
} }
void Browser::DockCancelBounce(int request_id) { void Browser::DockCancelBounce(int request_id) {

View file

@ -287,7 +287,7 @@ void Browser::SetLoginItemSettings(LoginItemSettings settings) {
} }
Browser::LoginItemSettings Browser::GetLoginItemSettings( Browser::LoginItemSettings Browser::GetLoginItemSettings(
LoginItemSettings options) { const LoginItemSettings& options) {
LoginItemSettings settings; LoginItemSettings settings;
base::string16 keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run"; base::string16 keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS); base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);

View file

@ -338,7 +338,7 @@ void CommonWebContentsDelegate::DevToolsRequestFileSystems() {
} }
std::vector<FileSystem> file_systems; std::vector<FileSystem> file_systems;
for (auto file_system_path : file_system_paths) { for (const auto& file_system_path : file_system_paths) {
base::FilePath path = base::FilePath::FromUTF8Unsafe(file_system_path); base::FilePath path = base::FilePath::FromUTF8Unsafe(file_system_path);
std::string file_system_id = RegisterFileSystem(GetDevToolsWebContents(), std::string file_system_id = RegisterFileSystem(GetDevToolsWebContents(),
path); path);

View file

@ -1290,7 +1290,7 @@ void NativeWindowMac::SetProgressBar(double progress, const NativeWindow::Progre
NSDockTile* dock_tile = [NSApp dockTile]; NSDockTile* dock_tile = [NSApp dockTile];
// For the first time API invoked, we need to create a ContentView in DockTile. // For the first time API invoked, we need to create a ContentView in DockTile.
if (dock_tile.contentView == NULL) { if (dock_tile.contentView == nullptr) {
NSImageView* image_view = [[NSImageView alloc] init]; NSImageView* image_view = [[NSImageView alloc] init];
[image_view setImage:[NSApp applicationIconImage]]; [image_view setImage:[NSApp applicationIconImage]];
[dock_tile setContentView:image_view]; [dock_tile setContentView:image_view];
@ -1386,22 +1386,22 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
// they are available in the minimum SDK version // they are available in the minimum SDK version
if (type == "selection") { if (type == "selection") {
// NSVisualEffectMaterialSelection // NSVisualEffectMaterialSelection
vibrancyType = (NSVisualEffectMaterial) 4; vibrancyType = static_cast<NSVisualEffectMaterial>(4);
} else if (type == "menu") { } else if (type == "menu") {
// NSVisualEffectMaterialMenu // NSVisualEffectMaterialMenu
vibrancyType = (NSVisualEffectMaterial) 5; vibrancyType = static_cast<NSVisualEffectMaterial>(5);
} else if (type == "popover") { } else if (type == "popover") {
// NSVisualEffectMaterialPopover // NSVisualEffectMaterialPopover
vibrancyType = (NSVisualEffectMaterial) 6; vibrancyType = static_cast<NSVisualEffectMaterial>(6);
} else if (type == "sidebar") { } else if (type == "sidebar") {
// NSVisualEffectMaterialSidebar // NSVisualEffectMaterialSidebar
vibrancyType = (NSVisualEffectMaterial) 7; vibrancyType = static_cast<NSVisualEffectMaterial>(7);
} else if (type == "medium-light") { } else if (type == "medium-light") {
// NSVisualEffectMaterialMediumLight // NSVisualEffectMaterialMediumLight
vibrancyType = (NSVisualEffectMaterial) 8; vibrancyType = static_cast<NSVisualEffectMaterial>(8);
} else if (type == "ultra-dark") { } else if (type == "ultra-dark") {
// NSVisualEffectMaterialUltraDark // NSVisualEffectMaterialUltraDark
vibrancyType = (NSVisualEffectMaterial) 9; vibrancyType = static_cast<NSVisualEffectMaterial>(9);
} }
} }

View file

@ -50,7 +50,7 @@ class CertVerifierRequest : public AtomCertVerifier::Request {
first_response_(true), first_response_(true),
weak_ptr_factory_(this) {} weak_ptr_factory_(this) {}
~CertVerifierRequest() { ~CertVerifierRequest() override {
cert_verifier_->RemoveRequest(params_); cert_verifier_->RemoveRequest(params_);
default_verifier_request_.reset(); default_verifier_request_.reset();
while (!response_list_.empty() && !first_response_) { while (!response_list_.empty() && !first_response_) {

View file

@ -402,7 +402,7 @@ void AtomNetworkDelegate::OnListenerResultInIO(
if (!base::ContainsKey(callbacks_, id)) if (!base::ContainsKey(callbacks_, id))
return; return;
ReadFromResponseObject(*response.get(), out); ReadFromResponseObject(*response, out);
bool cancel = false; bool cancel = false;
response->GetBoolean("cancel", &cancel); response->GetBoolean("cancel", &cancel);

View file

@ -164,7 +164,7 @@ void NodeDebugger::DidRead(net::test_server::StreamListenSocket* socket,
buffer_.append(data, len); buffer_.append(data, len);
do { do {
if (buffer_.size() == 0) if (buffer_.empty())
return; return;
// Read the "Content-Length" header. // Read the "Content-Length" header.

View file

@ -851,12 +851,12 @@ void OffScreenRenderWidgetHostView::SetupFrameRate(bool force) {
GetCompositor()->vsync_manager()->SetAuthoritativeVSyncInterval( GetCompositor()->vsync_manager()->SetAuthoritativeVSyncInterval(
base::TimeDelta::FromMilliseconds(frame_rate_threshold_ms_)); base::TimeDelta::FromMilliseconds(frame_rate_threshold_ms_));
if (copy_frame_generator_.get()) { if (copy_frame_generator_) {
copy_frame_generator_->set_frame_rate_threshold_ms( copy_frame_generator_->set_frame_rate_threshold_ms(
frame_rate_threshold_ms_); frame_rate_threshold_ms_);
} }
if (begin_frame_timer_.get()) { if (begin_frame_timer_) {
begin_frame_timer_->SetFrameRateThresholdMs(frame_rate_threshold_ms_); begin_frame_timer_->SetFrameRateThresholdMs(frame_rate_threshold_ms_);
} else { } else {
begin_frame_timer_.reset(new AtomBeginFrameTimer( begin_frame_timer_.reset(new AtomBeginFrameTimer(
@ -871,7 +871,7 @@ void OffScreenRenderWidgetHostView::Invalidate() {
if (software_output_device_) { if (software_output_device_) {
software_output_device_->OnPaint(bounds_in_pixels); software_output_device_->OnPaint(bounds_in_pixels);
} else if (copy_frame_generator_.get()) { } else if (copy_frame_generator_) {
copy_frame_generator_->GenerateCopyFrame(true, bounds_in_pixels); copy_frame_generator_->GenerateCopyFrame(true, bounds_in_pixels);
} }
} }

View file

@ -145,4 +145,4 @@ OffScreenRenderWidgetHostView::GetDelegatedFrameHost() const {
return browser_compositor_->GetDelegatedFrameHost(); return browser_compositor_->GetDelegatedFrameHost();
} }
} // namespace } // namespace atom

View file

@ -70,7 +70,7 @@ Role kRolesMap[] = {
// while its context menu is still open. // while its context menu is still open.
[self cancel]; [self cancel];
model_ = NULL; model_ = nullptr;
[super dealloc]; [super dealloc];
} }

View file

@ -319,7 +319,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
- (void)updateColorPicker:(NSColorPickerTouchBarItem*)item - (void)updateColorPicker:(NSColorPickerTouchBarItem*)item
withSettings:(const mate::PersistentDictionary&)settings { withSettings:(const mate::PersistentDictionary&)settings {
std::vector<std::string> colors; std::vector<std::string> colors;
if (settings.Get("availableColors", &colors) && colors.size() > 0) { if (settings.Get("availableColors", &colors) && !colors.empty()) {
NSColorList* color_list = [[[NSColorList alloc] initWithName:@""] autorelease]; NSColorList* color_list = [[[NSColorList alloc] initWithName:@""] autorelease];
for (size_t i = 0; i < colors.size(); ++i) { for (size_t i = 0; i < colors.size(); ++i) {
[color_list insertColor:[self colorFromHexColorString:colors[i]] [color_list insertColor:[self colorFromHexColorString:colors[i]]
@ -414,7 +414,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
NSMutableArray* generatedItems = [NSMutableArray array]; NSMutableArray* generatedItems = [NSMutableArray array];
NSMutableArray* identifiers = [self identifiersFromSettings:items]; NSMutableArray* identifiers = [self identifiersFromSettings:items];
for (NSUInteger i = 0; i < [identifiers count]; i++) { for (NSUInteger i = 0; i < [identifiers count]; ++i) {
if ([identifiers objectAtIndex:i] != NSTouchBarItemIdentifierOtherItemsProxy) { if ([identifiers objectAtIndex:i] != NSTouchBarItemIdentifierOtherItemsProxy) {
NSTouchBarItem* generatedItem = [self makeItemForIdentifier:[identifiers objectAtIndex:i]]; NSTouchBarItem* generatedItem = [self makeItemForIdentifier:[identifiers objectAtIndex:i]];
if (generatedItem) { if (generatedItem) {
@ -474,7 +474,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
settings.Get("segments", &segments); settings.Get("segments", &segments);
control.segmentCount = segments.size(); control.segmentCount = segments.size();
for (int i = 0; i < (int)segments.size(); i++) { for (size_t i = 0; i < segments.size(); ++i) {
std::string label; std::string label;
gfx::Image image; gfx::Image image;
bool enabled = true; bool enabled = true;
@ -581,7 +581,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
std::vector<mate::PersistentDictionary> items; std::vector<mate::PersistentDictionary> items;
if (!settings.Get("items", &items)) return nil; if (!settings.Get("items", &items)) return nil;
if (index >= (long)items.size()) return nil; if (index >= static_cast<NSInteger>(items.size())) return nil;
mate::PersistentDictionary item = items[index]; mate::PersistentDictionary item = items[index];

View file

@ -154,7 +154,7 @@ void ShowOpenDialog(const DialogSettings& settings,
NSWindow* window = settings.parent_window ? NSWindow* window = settings.parent_window ?
settings.parent_window->GetNativeWindow() : settings.parent_window->GetNativeWindow() :
NULL; nullptr;
[dialog beginSheetModalForWindow:window [dialog beginSheetModalForWindow:window
completionHandler:^(NSInteger chosen) { completionHandler:^(NSInteger chosen) {
if (chosen == NSFileHandlingPanelCancelButton) { if (chosen == NSFileHandlingPanelCancelButton) {
@ -193,7 +193,7 @@ void ShowSaveDialog(const DialogSettings& settings,
NSWindow* window = settings.parent_window ? NSWindow* window = settings.parent_window ?
settings.parent_window->GetNativeWindow() : settings.parent_window->GetNativeWindow() :
NULL; nullptr;
[dialog beginSheetModalForWindow:window [dialog beginSheetModalForWindow:window
completionHandler:^(NSInteger chosen) { completionHandler:^(NSInteger chosen) {
if (chosen == NSFileHandlingPanelCancelButton) { if (chosen == NSFileHandlingPanelCancelButton) {

View file

@ -66,7 +66,8 @@ void WebContentsPermissionHelper::RequestPermission(
void WebContentsPermissionHelper::RequestFullscreenPermission( void WebContentsPermissionHelper::RequestFullscreenPermission(
const base::Callback<void(bool)>& callback) { const base::Callback<void(bool)>& callback) {
RequestPermission((content::PermissionType)(PermissionType::FULLSCREEN), RequestPermission(
static_cast<content::PermissionType>(PermissionType::FULLSCREEN),
callback); callback);
} }
@ -86,17 +87,17 @@ void WebContentsPermissionHelper::RequestWebNotificationPermission(
void WebContentsPermissionHelper::RequestPointerLockPermission( void WebContentsPermissionHelper::RequestPointerLockPermission(
bool user_gesture) { bool user_gesture) {
RequestPermission((content::PermissionType)(PermissionType::POINTER_LOCK), RequestPermission(
base::Bind(&OnPointerLockResponse, web_contents_), static_cast<content::PermissionType>(PermissionType::POINTER_LOCK),
user_gesture); base::Bind(&OnPointerLockResponse, web_contents_), user_gesture);
} }
void WebContentsPermissionHelper::RequestOpenExternalPermission( void WebContentsPermissionHelper::RequestOpenExternalPermission(
const base::Callback<void(bool)>& callback, const base::Callback<void(bool)>& callback,
bool user_gesture) { bool user_gesture) {
RequestPermission((content::PermissionType)(PermissionType::OPEN_EXTERNAL), RequestPermission(
callback, static_cast<content::PermissionType>(PermissionType::OPEN_EXTERNAL),
user_gesture); callback, user_gesture);
} }
} // namespace atom } // namespace atom

View file

@ -51,7 +51,7 @@ class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
private: private:
friend class base::RefCounted<FileSelectHelper>; friend class base::RefCounted<FileSelectHelper>;
~FileSelectHelper() {} ~FileSelectHelper() override {}
void OnOpenDialogDone(bool result, const std::vector<base::FilePath>& paths) { void OnOpenDialogDone(bool result, const std::vector<base::FilePath>& paths) {
std::vector<content::FileChooserFileInfo> file_info; std::vector<content::FileChooserFileInfo> file_info;

View file

@ -46,7 +46,7 @@ void WindowList::RemoveWindow(NativeWindow* window) {
for (WindowListObserver& observer : observers_.Get()) for (WindowListObserver& observer : observers_.Get())
observer.OnWindowRemoved(window); observer.OnWindowRemoved(window);
if (windows.size() == 0) { if (windows.empty()) {
for (WindowListObserver& observer : observers_.Get()) for (WindowListObserver& observer : observers_.Get())
observer.OnWindowAllClosed(); observer.OnWindowAllClosed();
} }

View file

@ -168,11 +168,13 @@ v8::Local<v8::Value> Converter<content::PermissionType>::ToV8(
break; break;
} }
if (val == (content::PermissionType)(PermissionType::POINTER_LOCK)) if (val == static_cast<content::PermissionType>(PermissionType::POINTER_LOCK))
return StringToV8(isolate, "pointerLock"); return StringToV8(isolate, "pointerLock");
else if (val == (content::PermissionType)(PermissionType::FULLSCREEN)) else if (val ==
static_cast<content::PermissionType>(PermissionType::FULLSCREEN))
return StringToV8(isolate, "fullscreen"); return StringToV8(isolate, "fullscreen");
else if (val == (content::PermissionType)(PermissionType::OPEN_EXTERNAL)) else if (val ==
static_cast<content::PermissionType>(PermissionType::OPEN_EXTERNAL))
return StringToV8(isolate, "openExternal"); return StringToV8(isolate, "openExternal");
return StringToV8(isolate, "unknown"); return StringToV8(isolate, "unknown");

View file

@ -11,6 +11,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/mac/mac_logging.h" #include "base/mac/mac_logging.h"
#include "base/mac/scoped_aedesc.h" #include "base/mac/scoped_aedesc.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
@ -71,10 +72,10 @@ std::string MessageForOSStatus(OSStatus status, const char* default_message) {
// thread safe, including LSGetApplicationForURL (> 10.2) and // thread safe, including LSGetApplicationForURL (> 10.2) and
// NSWorkspace#openURLs. // NSWorkspace#openURLs.
std::string OpenURL(NSURL* ns_url, bool activate) { std::string OpenURL(NSURL* ns_url, bool activate) {
CFURLRef openingApp = NULL; CFURLRef openingApp = nullptr;
OSStatus status = LSGetApplicationForURL((CFURLRef)ns_url, OSStatus status = LSGetApplicationForURL(base::mac::NSToCFCast(ns_url),
kLSRolesAll, kLSRolesAll,
NULL, nullptr,
&openingApp); &openingApp);
if (status != noErr) if (status != noErr)
return MessageForOSStatus(status, "Failed to open"); return MessageForOSStatus(status, "Failed to open");
@ -156,7 +157,7 @@ bool OpenItem(const base::FilePath& full_path) {
// Create the list of files (only ever one) to open. // Create the list of files (only ever one) to open.
base::mac::ScopedAEDesc<AEDescList> fileList; base::mac::ScopedAEDesc<AEDescList> fileList;
status = AECreateList(NULL, // factoringPtr status = AECreateList(nullptr, // factoringPtr
0, // factoredSize 0, // factoredSize
false, // isRecord false, // isRecord
fileList.OutPointer()); // resultList fileList.OutPointer()); // resultList
@ -167,7 +168,8 @@ bool OpenItem(const base::FilePath& full_path) {
// Add the single path to the file list. C-style cast to avoid both a // Add the single path to the file list. C-style cast to avoid both a
// static_cast and a const_cast to get across the toll-free bridge. // static_cast and a const_cast to get across the toll-free bridge.
CFURLRef pathURLRef = (CFURLRef)[NSURL fileURLWithPath:path_string]; CFURLRef pathURLRef = base::mac::NSToCFCast(
[NSURL fileURLWithPath:path_string]);
FSRef pathRef; FSRef pathRef;
if (CFURLGetFSRef(pathURLRef, &pathRef)) { if (CFURLGetFSRef(pathURLRef, &pathRef)) {
status = AEPutPtr(fileList.OutPointer(), // theAEDescList status = AEPutPtr(fileList.OutPointer(), // theAEDescList
@ -202,8 +204,8 @@ bool OpenItem(const base::FilePath& full_path) {
kAENoReply + kAEAlwaysInteract, // sendMode kAENoReply + kAEAlwaysInteract, // sendMode
kAENormalPriority, // sendPriority kAENormalPriority, // sendPriority
kAEDefaultTimeout, // timeOutInTicks kAEDefaultTimeout, // timeOutInTicks
NULL, // idleProc nullptr, // idleProc
NULL); // filterProc nullptr); // filterProc
if (status != noErr) { if (status != noErr) {
OSSTATUS_LOG(WARNING, status) OSSTATUS_LOG(WARNING, status)
<< "Could not send AE to Finder in OpenItem()"; << "Could not send AE to Finder in OpenItem()";

View file

@ -238,7 +238,7 @@ void AtomSandboxedRendererClient::WillReleaseScriptContext(
void AtomSandboxedRendererClient::InvokeIpcCallback( void AtomSandboxedRendererClient::InvokeIpcCallback(
v8::Handle<v8::Context> context, v8::Handle<v8::Context> context,
std::string callback_name, const std::string& callback_name,
std::vector<v8::Handle<v8::Value>> args) { std::vector<v8::Handle<v8::Value>> args) {
auto isolate = context->GetIsolate(); auto isolate = context->GetIsolate();
auto binding_key = mate::ConvertToV8(isolate, kIpcKey)->ToString(); auto binding_key = mate::ConvertToV8(isolate, kIpcKey)->ToString();

View file

@ -21,7 +21,7 @@ class AtomSandboxedRendererClient : public RendererClientBase {
void WillReleaseScriptContext( void WillReleaseScriptContext(
v8::Handle<v8::Context> context, content::RenderFrame* render_frame); v8::Handle<v8::Context> context, content::RenderFrame* render_frame);
void InvokeIpcCallback(v8::Handle<v8::Context> context, void InvokeIpcCallback(v8::Handle<v8::Context> context,
std::string callback_name, const std::string& callback_name,
std::vector<v8::Handle<v8::Value>> args); std::vector<v8::Handle<v8::Value>> args);
// content::ContentRendererClient: // content::ContentRendererClient:
void RenderFrameCreated(content::RenderFrame*) override; void RenderFrameCreated(content::RenderFrame*) override;