Browse Source

Remove cpplint errors

Kevin Sawicki 8 years ago
parent
commit
be0c0e278a

+ 2 - 2
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 <string>
-
 #include <libnotify/notify.h>
 
+#include <string>
+
 class LibNotifyLoader {
  public:
   LibNotifyLoader();

+ 1 - 1
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);
 }

+ 4 - 2
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<net::HostResolver> host_resolver(net::HostResolver::CreateDefaultResolver(nullptr));
+    std::unique_ptr<net::HostResolver> 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();
     }
 

+ 1 - 1
brightray/browser/views/inspectable_web_contents_view_views.h

@@ -14,7 +14,7 @@ class Widget;
 
 namespace brightray {
 
-namespace {
+namespace { // NOLINT
 class DevToolsWindowDelegate;
 }
 

+ 2 - 1
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 <[email protected]> and Jason Poon <[email protected]>. All rights reserved.
+// Copyright (c) 2015 Felix Rieseberg <[email protected]> and
+// Jason Poon <[email protected]>. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE-CHROMIUM file.
 

+ 5 - 4
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 <[email protected]> and Jason Poon <[email protected]>. All rights reserved.
+// Copyright (c) 2015 Felix Rieseberg <[email protected]> and
+// Jason Poon <[email protected]>. 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_

+ 4 - 4
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 <string>
-
 #include <hstring.h>
 #include <windows.h>
 
+#include <string>
+
 #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();

+ 60 - 43
brightray/browser/win/windows_toast_notification.cc

@@ -1,6 +1,9 @@
-// Copyright (c) 2015 Felix Rieseberg <[email protected]> and Jason Poon <[email protected]>. All rights reserved.
-// Copyright (c) 2015 Ryan McShane <[email protected]> and Brandon Smith <[email protected]>
-// Thanks to both of those folks mentioned above who first thought up a bunch of this code
+// Copyright (c) 2015 Felix Rieseberg <[email protected]> and Jason Poon
+// <[email protected]>. All rights reserved.
+// Copyright (c) 2015 Ryan McShane <[email protected]> and Brandon Smith
+// <[email protected]>
+// 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<NotificationPresenterWin*>(presenter());
   std::wstring icon_path = presenter_win->SaveIconToFilesystem(icon, icon_url);
 
   ComPtr<IXmlDocument> 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<ABI::Windows::UI::Notifications::IToastNotificationFactory> toast_factory;
+  ComPtr<ABI::Windows::UI::Notifications::IToastNotificationFactory>
+      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<IXmlNode> 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<IXmlNode> 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<IXmlNodeList> 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<IXmlNodeList> 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_));

+ 49 - 26
brightray/browser/win/windows_toast_notification.h

@@ -1,6 +1,9 @@
-// Copyright (c) 2015 Felix Rieseberg <[email protected]> and Jason Poon <[email protected]>. All rights reserved.
-// Copyright (c) 2015 Ryan McShane <[email protected]> and Brandon Smith <[email protected]>
-// Thanks to both of those folks mentioned above who first thought up a bunch of this code
+// Copyright (c) 2015 Felix Rieseberg <[email protected]> and Jason Poon
+// <[email protected]>. All rights reserved.
+// Copyright (c) 2015 Ryan McShane <[email protected]> and Brandon Smith
+// <[email protected]>
+// 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::UI::Notifications::ToastNotification*,
-    IInspectable*>;
+    ABI::Windows::Foundation::ITypedEventHandler<
+        ABI::Windows::UI::Notifications::ToastNotification*,
+        IInspectable*>;
 using DesktopToastDismissedEventHandler =
-    ABI::Windows::Foundation::ITypedEventHandler<ABI::Windows::UI::Notifications::ToastNotification*,
-    ABI::Windows::UI::Notifications::ToastDismissedEventArgs*>;
+    ABI::Windows::Foundation::ITypedEventHandler<
+        ABI::Windows::UI::Notifications::ToastNotification*,
+        ABI::Windows::UI::Notifications::ToastDismissedEventArgs*>;
 using DesktopToastFailedEventHandler =
-    ABI::Windows::Foundation::ITypedEventHandler<ABI::Windows::UI::Notifications::ToastNotification*,
-    ABI::Windows::UI::Notifications::ToastFailedEventArgs*>;
+    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<ABI::Windows::UI::Notifications::IToastNotificationManagerStatics> toast_manager_;
-  static ComPtr<ABI::Windows::UI::Notifications::IToastNotifier> toast_notifier_;
+  static ComPtr<
+      ABI::Windows::UI::Notifications::IToastNotificationManagerStatics>
+      toast_manager_;
+  static ComPtr<ABI::Windows::UI::Notifications::IToastNotifier>
+      toast_notifier_;
 
   EventRegistrationToken activated_token_;
   EventRegistrationToken dismissed_token_;
   EventRegistrationToken failed_token_;
 
   ComPtr<ToastEventHandler> event_handler_;
-  ComPtr<ABI::Windows::UI::Notifications::IToastNotification> toast_notification_;
+  ComPtr<ABI::Windows::UI::Notifications::IToastNotification>
+      toast_notification_;
 
   DISALLOW_COPY_AND_ASSIGN(WindowsToastNotification);
 };
 
-
 class ToastEventHandler : public RuntimeClass<RuntimeClassFlags<ClassicCom>,
                                               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> notification_;  // weak ref.