From be0c0e278a36487fd991ef9678c60235c975d246 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 23 Mar 2017 12:48:22 -0700 Subject: [PATCH] Remove cpplint errors --- brightray/browser/linux/libnotify_loader.h | 4 +- .../devtools_network_upload_data_stream.cc | 2 +- .../browser/url_request_context_getter.cc | 6 +- .../inspectable_web_contents_view_views.h | 2 +- .../browser/win/notification_presenter_win.cc | 3 +- .../browser/win/notification_presenter_win.h | 9 +- brightray/browser/win/scoped_hstring.h | 8 +- .../browser/win/windows_toast_notification.cc | 103 ++++++++++-------- .../browser/win/windows_toast_notification.h | 75 ++++++++----- 9 files changed, 128 insertions(+), 84 deletions(-) diff --git a/brightray/browser/linux/libnotify_loader.h b/brightray/browser/linux/libnotify_loader.h index 825a349b39fc..48fda0b632ab 100644 --- a/brightray/browser/linux/libnotify_loader.h +++ b/brightray/browser/linux/libnotify_loader.h @@ -4,10 +4,10 @@ #ifndef BRIGHTRAY_BROWSER_LINUX_LIBNOTIFY_LOADER_H_ #define BRIGHTRAY_BROWSER_LINUX_LIBNOTIFY_LOADER_H_ -#include - #include +#include + class LibNotifyLoader { public: LibNotifyLoader(); diff --git a/brightray/browser/net/devtools_network_upload_data_stream.cc b/brightray/browser/net/devtools_network_upload_data_stream.cc index c6369dcb4587..6687038b097f 100644 --- a/brightray/browser/net/devtools_network_upload_data_stream.cc +++ b/brightray/browser/net/devtools_network_upload_data_stream.cc @@ -81,7 +81,7 @@ int DevToolsNetworkUploadDataStream::ThrottleRead(int result) { } void DevToolsNetworkUploadDataStream::ThrottleCallback( - int result, int64_t bytes) { + int result, int64_t bytes) { throttled_byte_count_ = bytes; OnReadCompleted(result); } diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index e3e7dca54359..3510d00b8448 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -200,7 +200,8 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { net::HttpUtil::GenerateAcceptLanguageHeader(accept_lang), user_agent_))); - std::unique_ptr host_resolver(net::HostResolver::CreateDefaultResolver(nullptr)); + std::unique_ptr host_resolver( + net::HostResolver::CreateDefaultResolver(nullptr)); // --host-resolver-rules if (command_line.HasSwitch(::switches::kHostResolverRules)) { @@ -301,7 +302,8 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { // --host-rules if (command_line.HasSwitch(switches::kHostRules)) { host_mapping_rules_.reset(new net::HostMappingRules); - host_mapping_rules_->SetRulesFromString(command_line.GetSwitchValueASCII(switches::kHostRules)); + host_mapping_rules_->SetRulesFromString( + command_line.GetSwitchValueASCII(switches::kHostRules)); network_session_params.host_mapping_rules = host_mapping_rules_.get(); } diff --git a/brightray/browser/views/inspectable_web_contents_view_views.h b/brightray/browser/views/inspectable_web_contents_view_views.h index 8205cc5f06e8..1af53e92fdfb 100644 --- a/brightray/browser/views/inspectable_web_contents_view_views.h +++ b/brightray/browser/views/inspectable_web_contents_view_views.h @@ -14,7 +14,7 @@ class Widget; namespace brightray { -namespace { +namespace { // NOLINT class DevToolsWindowDelegate; } diff --git a/brightray/browser/win/notification_presenter_win.cc b/brightray/browser/win/notification_presenter_win.cc index 018fa3212a41..6e913ea37ff8 100644 --- a/brightray/browser/win/notification_presenter_win.cc +++ b/brightray/browser/win/notification_presenter_win.cc @@ -1,5 +1,6 @@ // Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Copyright (c) 2015 Felix Rieseberg and Jason Poon . All rights reserved. +// Copyright (c) 2015 Felix Rieseberg and +// Jason Poon . All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE-CHROMIUM file. diff --git a/brightray/browser/win/notification_presenter_win.h b/brightray/browser/win/notification_presenter_win.h index 7bcf1a9909dd..69b89f4ae5da 100644 --- a/brightray/browser/win/notification_presenter_win.h +++ b/brightray/browser/win/notification_presenter_win.h @@ -1,12 +1,13 @@ // Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Copyright (c) 2015 Felix Rieseberg and Jason Poon . All rights reserved. +// Copyright (c) 2015 Felix Rieseberg and +// Jason Poon . All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE-CHROMIUM file. // Usage Example (JavaScript: // var windowsNotification = new Notification("Test Title", { -// body: "Hi, I'm an example body. How are you?", -// icon: "file:///C:/Path/To/Your/Image.png" +// body: "Hi, I'm an example body. How are you?", +// icon: "file:///C:/Path/To/Your/Image.png" // }); // windowsNotification.onshow = function () { console.log("Notification shown") }; @@ -40,6 +41,6 @@ class NotificationPresenterWin : public NotificationPresenter { DISALLOW_COPY_AND_ASSIGN(NotificationPresenterWin); }; -} // namespace +} // namespace brightray #endif // BRIGHTRAY_BROWSER_WIN_NOTIFICATION_PRESENTER_WIN_H_ diff --git a/brightray/browser/win/scoped_hstring.h b/brightray/browser/win/scoped_hstring.h index 67e4fe67fd07..879e62cd39b8 100644 --- a/brightray/browser/win/scoped_hstring.h +++ b/brightray/browser/win/scoped_hstring.h @@ -5,18 +5,18 @@ #ifndef BRIGHTRAY_BROWSER_WIN_SCOPED_HSTRING_H_ #define BRIGHTRAY_BROWSER_WIN_SCOPED_HSTRING_H_ -#include - #include #include +#include + #include "base/macros.h" class ScopedHString { public: // Copy from |source|. - ScopedHString(const wchar_t* source); - ScopedHString(const std::wstring& source); + explicit ScopedHString(const wchar_t* source); + explicit ScopedHString(const std::wstring& source); // Create empty string. ScopedHString(); ~ScopedHString(); diff --git a/brightray/browser/win/windows_toast_notification.cc b/brightray/browser/win/windows_toast_notification.cc index 4d4b5bfc3412..4a3a5a6f678b 100644 --- a/brightray/browser/win/windows_toast_notification.cc +++ b/brightray/browser/win/windows_toast_notification.cc @@ -1,6 +1,9 @@ -// Copyright (c) 2015 Felix Rieseberg and Jason Poon . All rights reserved. -// Copyright (c) 2015 Ryan McShane and Brandon Smith -// Thanks to both of those folks mentioned above who first thought up a bunch of this code +// Copyright (c) 2015 Felix Rieseberg and Jason Poon +// . All rights reserved. +// Copyright (c) 2015 Ryan McShane and Brandon Smith +// +// Thanks to both of those folks mentioned above who first thought up a bunch of +// this code // and released it as MIT to the world. #include "browser/win/windows_toast_notification.h" @@ -14,7 +17,13 @@ #include "common/application_info.h" #include "content/public/browser/browser_thread.h" -using namespace ABI::Windows::Data::Xml::Dom; +using ABI::Windows::Data::Xml::Dom::IXmlAttribute; +using ABI::Windows::Data::Xml::Dom::IXmlDocument; +using ABI::Windows::Data::Xml::Dom::IXmlElement; +using ABI::Windows::Data::Xml::Dom::IXmlNamedNodeMap; +using ABI::Windows::Data::Xml::Dom::IXmlNode; +using ABI::Windows::Data::Xml::Dom::IXmlNodeList; +using ABI::Windows::Data::Xml::Dom::IXmlText; namespace brightray { @@ -71,8 +80,7 @@ bool WindowsToastNotification::Initialize() { WindowsToastNotification::WindowsToastNotification( NotificationDelegate* delegate, NotificationPresenter* presenter) - : Notification(delegate, presenter) { -} + : Notification(delegate, presenter) {} WindowsToastNotification::~WindowsToastNotification() { // Remove the notification on exit. @@ -82,18 +90,18 @@ WindowsToastNotification::~WindowsToastNotification() { } } -void WindowsToastNotification::Show( - const base::string16& title, - const base::string16& msg, - const std::string& tag, - const GURL& icon_url, - const SkBitmap& icon, - const bool silent) { +void WindowsToastNotification::Show(const base::string16& title, + const base::string16& msg, + const std::string& tag, + const GURL& icon_url, + const SkBitmap& icon, + const bool silent) { auto presenter_win = static_cast(presenter()); std::wstring icon_path = presenter_win->SaveIconToFilesystem(icon, icon_url); ComPtr toast_xml; - if(FAILED(GetToastXml(toast_manager_.Get(), title, msg, icon_path, silent, &toast_xml))) { + if (FAILED(GetToastXml(toast_manager_.Get(), title, msg, icon_path, silent, + &toast_xml))) { NotificationFailed(); return; } @@ -105,7 +113,8 @@ void WindowsToastNotification::Show( return; } - ComPtr toast_factory; + ComPtr + toast_factory; if (FAILED(Windows::Foundation::GetActivationFactory(toast_str, &toast_factory))) { NotificationFailed(); @@ -136,7 +145,8 @@ void WindowsToastNotification::Dismiss() { } bool WindowsToastNotification::GetToastXml( - ABI::Windows::UI::Notifications::IToastNotificationManagerStatics* toastManager, + ABI::Windows::UI::Notifications::IToastNotificationManagerStatics* + toastManager, const std::wstring& title, const std::wstring& msg, const std::wstring& icon_path, @@ -145,16 +155,22 @@ bool WindowsToastNotification::GetToastXml( ABI::Windows::UI::Notifications::ToastTemplateType template_type; if (title.empty() || msg.empty()) { // Single line toast. - template_type = icon_path.empty() ? ABI::Windows::UI::Notifications::ToastTemplateType_ToastText01 : - ABI::Windows::UI::Notifications::ToastTemplateType_ToastImageAndText01; + template_type = + icon_path.empty() + ? ABI::Windows::UI::Notifications::ToastTemplateType_ToastText01 + : ABI::Windows::UI::Notifications:: + ToastTemplateType_ToastImageAndText01; if (FAILED(toast_manager_->GetTemplateContent(template_type, toast_xml))) return false; if (!SetXmlText(*toast_xml, title.empty() ? msg : title)) return false; } else { // Title and body toast. - template_type = icon_path.empty() ? ABI::Windows::UI::Notifications::ToastTemplateType_ToastText02 : - ABI::Windows::UI::Notifications::ToastTemplateType_ToastImageAndText02; + template_type = + icon_path.empty() + ? ABI::Windows::UI::Notifications::ToastTemplateType_ToastText02 + : ABI::Windows::UI::Notifications:: + ToastTemplateType_ToastImageAndText02; if (FAILED(toastManager->GetTemplateContent(template_type, toast_xml))) return false; if (!SetXmlText(*toast_xml, title, msg)) @@ -174,9 +190,8 @@ bool WindowsToastNotification::GetToastXml( return true; } -bool WindowsToastNotification::SetXmlAudioSilent( - IXmlDocument* doc) { - ScopedHString tag(L"toast"); +bool WindowsToastNotification::SetXmlAudioSilent(IXmlDocument* doc) { + ScopedHString tag(L"toast"); if (!tag.success()) return false; @@ -230,15 +245,17 @@ bool WindowsToastNotification::SetXmlAudioSilent( return false; ComPtr child_node; - if (FAILED(silent_attribute_node->AppendChild(silent_node.Get(), &child_node))) + if (FAILED( + silent_attribute_node->AppendChild(silent_node.Get(), &child_node))) return false; ComPtr silent_attribute_pnode; - return SUCCEEDED(attributes.Get()->SetNamedItem(silent_attribute_node.Get(), &silent_attribute_pnode)); + return SUCCEEDED(attributes.Get()->SetNamedItem(silent_attribute_node.Get(), + &silent_attribute_pnode)); } -bool WindowsToastNotification::SetXmlText( - IXmlDocument* doc, const std::wstring& text) { +bool WindowsToastNotification::SetXmlText(IXmlDocument* doc, + const std::wstring& text) { ScopedHString tag; ComPtr node_list; if (!GetTextNodeList(&tag, doc, &node_list, 1)) @@ -251,8 +268,9 @@ bool WindowsToastNotification::SetXmlText( return AppendTextToXml(doc, node.Get(), text); } -bool WindowsToastNotification::SetXmlText( - IXmlDocument* doc, const std::wstring& title, const std::wstring& body) { +bool WindowsToastNotification::SetXmlText(IXmlDocument* doc, + const std::wstring& title, + const std::wstring& body) { ScopedHString tag; ComPtr node_list; if (!GetTextNodeList(&tag, doc, &node_list, 2)) @@ -271,8 +289,8 @@ bool WindowsToastNotification::SetXmlText( return AppendTextToXml(doc, node.Get(), body); } -bool WindowsToastNotification::SetXmlImage( - IXmlDocument* doc, const std::wstring& icon_path) { +bool WindowsToastNotification::SetXmlImage(IXmlDocument* doc, + const std::wstring& icon_path) { ScopedHString tag(L"image"); if (!tag.success()) return false; @@ -313,11 +331,10 @@ bool WindowsToastNotification::SetXmlImage( return SUCCEEDED(src_attr->AppendChild(src_node.Get(), &child_node)); } -bool WindowsToastNotification::GetTextNodeList( - ScopedHString* tag, - IXmlDocument* doc, - IXmlNodeList** node_list, - uint32_t req_length) { +bool WindowsToastNotification::GetTextNodeList(ScopedHString* tag, + IXmlDocument* doc, + IXmlNodeList** node_list, + uint32_t req_length) { tag->Reset(L"text"); if (!tag->success()) return false; @@ -332,8 +349,9 @@ bool WindowsToastNotification::GetTextNodeList( return node_length >= req_length; } -bool WindowsToastNotification::AppendTextToXml( - IXmlDocument* doc, IXmlNode* node, const std::wstring& text) { +bool WindowsToastNotification::AppendTextToXml(IXmlDocument* doc, + IXmlNode* node, + const std::wstring& text) { ScopedHString str(text); if (!str.success()) return false; @@ -377,14 +395,13 @@ bool WindowsToastNotification::RemoveCallbacks( / Toast Event Handler */ ToastEventHandler::ToastEventHandler(Notification* notification) - : notification_(notification->GetWeakPtr()) { -} + : notification_(notification->GetWeakPtr()) {} -ToastEventHandler::~ToastEventHandler() { -} +ToastEventHandler::~ToastEventHandler() {} IFACEMETHODIMP ToastEventHandler::Invoke( - ABI::Windows::UI::Notifications::IToastNotification* sender, IInspectable* args) { + ABI::Windows::UI::Notifications::IToastNotification* sender, + IInspectable* args) { content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, base::Bind(&Notification::NotificationClicked, notification_)); diff --git a/brightray/browser/win/windows_toast_notification.h b/brightray/browser/win/windows_toast_notification.h index fcbe78faa4d0..47c7d596a88b 100644 --- a/brightray/browser/win/windows_toast_notification.h +++ b/brightray/browser/win/windows_toast_notification.h @@ -1,6 +1,9 @@ -// Copyright (c) 2015 Felix Rieseberg and Jason Poon . All rights reserved. -// Copyright (c) 2015 Ryan McShane and Brandon Smith -// Thanks to both of those folks mentioned above who first thought up a bunch of this code +// Copyright (c) 2015 Felix Rieseberg and Jason Poon +// . All rights reserved. +// Copyright (c) 2015 Ryan McShane and Brandon Smith +// +// Thanks to both of those folks mentioned above who first thought up a bunch of +// this code // and released it as MIT to the world. #ifndef BRIGHTRAY_BROWSER_WIN_WINDOWS_TOAST_NOTIFICATION_H_ @@ -12,21 +15,28 @@ #include "browser/notification.h" -using namespace Microsoft::WRL; +using Microsoft::WRL::ClassicCom; +using Microsoft::WRL::ComPtr; +using Microsoft::WRL::Make; +using Microsoft::WRL::RuntimeClass; +using Microsoft::WRL::RuntimeClassFlags; class ScopedHString; namespace brightray { using DesktopToastActivatedEventHandler = - ABI::Windows::Foundation::ITypedEventHandler; + ABI::Windows::Foundation::ITypedEventHandler< + ABI::Windows::UI::Notifications::ToastNotification*, + IInspectable*>; using DesktopToastDismissedEventHandler = - ABI::Windows::Foundation::ITypedEventHandler; + ABI::Windows::Foundation::ITypedEventHandler< + ABI::Windows::UI::Notifications::ToastNotification*, + ABI::Windows::UI::Notifications::ToastDismissedEventArgs*>; using DesktopToastFailedEventHandler = - ABI::Windows::Foundation::ITypedEventHandler; + ABI::Windows::Foundation::ITypedEventHandler< + ABI::Windows::UI::Notifications::ToastNotification*, + ABI::Windows::UI::Notifications::ToastFailedEventArgs*>; class WindowsToastNotification : public Notification { public: @@ -50,12 +60,14 @@ class WindowsToastNotification : public Notification { private: friend class ToastEventHandler; - bool GetToastXml(ABI::Windows::UI::Notifications::IToastNotificationManagerStatics* toastManager, - const std::wstring& title, - const std::wstring& msg, - const std::wstring& icon_path, - const bool silent, - ABI::Windows::Data::Xml::Dom::IXmlDocument** toastXml); + bool GetToastXml( + ABI::Windows::UI::Notifications::IToastNotificationManagerStatics* + toastManager, + const std::wstring& title, + const std::wstring& msg, + const std::wstring& icon_path, + const bool silent, + ABI::Windows::Data::Xml::Dom::IXmlDocument** toastXml); bool SetXmlAudioSilent(ABI::Windows::Data::Xml::Dom::IXmlDocument* doc); bool SetXmlText(ABI::Windows::Data::Xml::Dom::IXmlDocument* doc, const std::wstring& text); @@ -71,34 +83,45 @@ class WindowsToastNotification : public Notification { bool AppendTextToXml(ABI::Windows::Data::Xml::Dom::IXmlDocument* doc, ABI::Windows::Data::Xml::Dom::IXmlNode* node, const std::wstring& text); - bool SetupCallbacks(ABI::Windows::UI::Notifications::IToastNotification* toast); - bool RemoveCallbacks(ABI::Windows::UI::Notifications::IToastNotification* toast); + bool SetupCallbacks( + ABI::Windows::UI::Notifications::IToastNotification* toast); + bool RemoveCallbacks( + ABI::Windows::UI::Notifications::IToastNotification* toast); - static ComPtr toast_manager_; - static ComPtr toast_notifier_; + static ComPtr< + ABI::Windows::UI::Notifications::IToastNotificationManagerStatics> + toast_manager_; + static ComPtr + toast_notifier_; EventRegistrationToken activated_token_; EventRegistrationToken dismissed_token_; EventRegistrationToken failed_token_; ComPtr event_handler_; - ComPtr toast_notification_; + ComPtr + toast_notification_; DISALLOW_COPY_AND_ASSIGN(WindowsToastNotification); }; - class ToastEventHandler : public RuntimeClass, DesktopToastActivatedEventHandler, DesktopToastDismissedEventHandler, DesktopToastFailedEventHandler> { public: - ToastEventHandler(Notification* notification); + explicit ToastEventHandler(Notification* notification); ~ToastEventHandler(); - IFACEMETHODIMP Invoke(ABI::Windows::UI::Notifications::IToastNotification* sender, IInspectable* args); - IFACEMETHODIMP Invoke(ABI::Windows::UI::Notifications::IToastNotification* sender, ABI::Windows::UI::Notifications::IToastDismissedEventArgs* e); - IFACEMETHODIMP Invoke(ABI::Windows::UI::Notifications::IToastNotification* sender, ABI::Windows::UI::Notifications::IToastFailedEventArgs* e); + IFACEMETHODIMP Invoke( + ABI::Windows::UI::Notifications::IToastNotification* sender, + IInspectable* args); + IFACEMETHODIMP Invoke( + ABI::Windows::UI::Notifications::IToastNotification* sender, + ABI::Windows::UI::Notifications::IToastDismissedEventArgs* e); + IFACEMETHODIMP Invoke( + ABI::Windows::UI::Notifications::IToastNotification* sender, + ABI::Windows::UI::Notifications::IToastFailedEventArgs* e); private: base::WeakPtr notification_; // weak ref.