<commit_before>// Copyright (c) 2015 <NAME> <<EMAIL>> and <NAME> <<EMAIL>>. All rights reserved.
// Copyright (c) 2015 <NAME> <<EMAIL>> and <NAME> <<EMAIL>>
// 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"

#include "base/strings/utf_string_conversions.h"
#include "browser/win/scoped_hstring.h"
#include "content/public/browser/desktop_notification_delegate.h"

using namespace ABI::Windows::Data::Xml::Dom;

namespace brightray {

namespace {

// Initialize Windows Runtime

HRESULT init = Windows::Foundation::Initialize(RO_INIT_MULTITHREADED);

}  // namespace

WindowsToastNotification::WindowsToastNotification(
    const std::string& app_name,
    scoped_ptr<content::DesktopNotificationDelegate> delegate)
    : delegate_(delegate.Pass()),
      weak_factory_(this) {
  ScopedHString toast_manager_str(
      RuntimeClass_Windows_UI_Notifications_ToastNotificationManager);
  if (!toast_manager_str.success())
    return;
  HRESULT hr = Windows::Foundation::GetActivationFactory(
      toast_manager_str, &toast_manager_);
  if (FAILED(hr))
    return;

  ScopedHString app_id(base::UTF8ToUTF16(app_name).c_str());<commit_msg>Windows Toasts: Don't call WFI statically<commit_after>// Copyright (c) 2015 <NAME> <<EMAIL>> and <NAME> <<EMAIL>>. All rights reserved.
// Copyright (c) 2015 <NAME> <<EMAIL>> and <NAME> <<EMAIL>>
// 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"

#include "base/strings/utf_string_conversions.h"
#include "browser/win/scoped_hstring.h"
#include "content/public/browser/desktop_notification_delegate.h"

using namespace ABI::Windows::Data::Xml::Dom;

namespace brightray {
  
WindowsToastNotification::WindowsToastNotification(
    const std::string& app_name,
    scoped_ptr<content::DesktopNotificationDelegate> delegate)
    : delegate_(delegate.Pass()),
      weak_factory_(this) {
  // If it wasn't for Windows 7, we could do this statically
  HRESULT init = Windows::Foundation::Initialize(RO_INIT_MULTITHREADED);
  
  ScopedHString toast_manager_str(
      RuntimeClass_Windows_UI_Notifications_ToastNotificationManager);
  if (!toast_manager_str.success())
    return;
  HRESULT hr = Windows::Foundation::GetActivationFactory(
      toast_manager_str, &toast_manager_);
  if (FAILED(hr))
    return;

  ScopedHString app_id(base::UTF8ToUTF16(app_name).c_str());
{'fraction_non_alphanumeric': 0.1150855365474339, 'fraction_numerical': 0.008942457231726283, 'mean_word_length': 5.5470737913486, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1784920', 'n_tokens_mistral': 812, 'n_tokens_neox': 784, 'n_words': 190}