DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (31ec81b5d7bb)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "FrameworkView.h"
#include "MetroUtils.h"
#include "nsICommandLineRunner.h"
#include "nsNetUtil.h"
#include "nsIDOMChromeWindow.h"
#include "nsIURI.h"
#include "nsPrintfCString.h"
#include "mozilla/Services.h"
#include <wrl/wrappers/corewrappers.h>
#include <shellapi.h>
#include <DXGIFormat.h>
#include <d2d1_1.h>
#include <printpreview.h>
#include <D3D10.h>
#include "MetroUIUtils.h"
#include "nsIStringBundle.h"

using namespace mozilla;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::Foundation::Collections;
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;

// Play to contract
using namespace ABI::Windows::Media::PlayTo;

// Activation contracts
using namespace ABI::Windows::ApplicationModel::Activation;
using namespace ABI::Windows::ApplicationModel::DataTransfer;
using namespace ABI::Windows::ApplicationModel::Search;

// Settings contract
using namespace ABI::Windows::UI::ApplicationSettings;
using namespace ABI::Windows::UI::Popups;

// Print contract
using namespace ABI::Windows::Graphics::Printing;

namespace mozilla {
namespace widget {
namespace winrt {

extern nsTArray<nsString>* sSettingsArray;

void
FrameworkView::SearchActivated(ComPtr<ISearchActivatedEventArgs>& aArgs, bool aStartup)
{
  if (!aArgs)
    return;

  HString data;
  AssertHRESULT(aArgs->get_QueryText(data.GetAddressOf()));
  if (WindowsIsStringEmpty(data.Get()))
    return;

  unsigned int length;
  LogW(L"SearchActivated text=%s", data.GetRawBuffer(&length));
  if (aStartup) {
    mActivationURI = data.GetRawBuffer(&length);
  } else {
    PerformURILoadOrSearch(data);
  }
}

void
FrameworkView::FileActivated(ComPtr<IFileActivatedEventArgs>& aArgs, bool aStartup)
{
  if (!aArgs)
    return;

  ComPtr<IVectorView<ABI::Windows::Storage::IStorageItem*>> list;
  AssertHRESULT(aArgs->get_Files(list.GetAddressOf()));
  ComPtr<ABI::Windows::Storage::IStorageItem> item;
  AssertHRESULT(list->GetAt(0, item.GetAddressOf()));
  HString filePath;
  AssertHRESULT(item->get_Path(filePath.GetAddressOf()));

  if (aStartup) {
    unsigned int length;
    mActivationURI = filePath.GetRawBuffer(&length);
  } else {
    PerformURILoad(filePath);
  }
}

void
FrameworkView::LaunchActivated(ComPtr<ILaunchActivatedEventArgs>& aArgs, bool aStartup)
{
  if (!aArgs)
    return;
  HString data;
  AssertHRESULT(aArgs->get_Arguments(data.GetAddressOf()));
  if (WindowsIsStringEmpty(data.Get()))
    return;

  // If we're being launched from a secondary tile then we have a 2nd command line param of -url
  // and a third of the secondary tile.  We want it in mActivationURI so that browser.js will
  // load it in without showing the start UI.
  int argc;
  unsigned int length;
  LPWSTR* argv = CommandLineToArgvW(data.GetRawBuffer(&length), &argc);
  if (aStartup && argc == 3 && !wcsicmp(argv[1], L"-url")) {
    mActivationURI = argv[2];
  } else {
    // Some other command line or this is not a startup.
    // If it is startup we process it later when XPCOM is initialilzed.
    mActivationCommandLine = data.GetRawBuffer(&length);
    if (!aStartup) {
      ProcessLaunchArguments();
    }
  }
}

void
FrameworkView::ProcessLaunchArguments()
{
  if (!mActivationCommandLine.Length())
    return;

  int argc;
  LPWSTR* argv = CommandLineToArgvW(mActivationCommandLine.BeginReading(), &argc);
  nsCOMPtr<nsICommandLineRunner> cmdLine =
    (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
  if (!cmdLine) {
    NS_WARNING("Unable to instantiate command line runner.");
    return;
  }

  LPSTR *argvUTF8 = new LPSTR[argc];
  for (int i = 0; i < argc; ++i) {
    NS_ConvertUTF16toUTF8 arg(argv[i]);
    argvUTF8[i] = new char[arg.Length() + 1];
    strcpy(argvUTF8[i], const_cast<char *>(arg.BeginReading()));
    LogW(L"Launch arg[%d]: '%s'", i, argv[i]);
  }

  nsresult rv = cmdLine->Init(argc,
                              argvUTF8,
                              nullptr,
                              nsICommandLine::STATE_REMOTE_EXPLICIT);
  if (NS_SUCCEEDED(rv)) {
    cmdLine->Run();
  } else {
    NS_WARNING("cmdLine->Init failed.");
  }

  for (int i = 0; i < argc; ++i) {
    delete[] argvUTF8[i];
  }
  delete[] argvUTF8;
}

void
FrameworkView::ProcessActivationArgs(IActivatedEventArgs* aArgs, bool aStartup)
{
  ActivationKind kind;
  if (!aArgs || FAILED(aArgs->get_Kind(&kind)))
    return;
  ComPtr<IActivatedEventArgs> args(aArgs);
  if (kind == ActivationKind::ActivationKind_Protocol) {
    Log("Activation argument kind: Protocol");
    ComPtr<IProtocolActivatedEventArgs> protoArgs;
    AssertHRESULT(args.As(&protoArgs));
    ComPtr<IUriRuntimeClass> uri;
    AssertHRESULT(protoArgs->get_Uri(uri.GetAddressOf()));
    if (!uri)
      return;

    HString data;
    AssertHRESULT(uri->get_AbsoluteUri(data.GetAddressOf()));
    if (WindowsIsStringEmpty(data.Get()))
      return;

    if (aStartup) {
      unsigned int length;
      mActivationURI = data.GetRawBuffer(&length);
    } else {
      PerformURILoad(data);
    }
  } else if (kind == ActivationKind::ActivationKind_Search) {
    Log("Activation argument kind: Search");
    ComPtr<ISearchActivatedEventArgs> searchArgs;
    args.As(&searchArgs);
    SearchActivated(searchArgs, aStartup);
  } else if (kind == ActivationKind::ActivationKind_File) {
    Log("Activation argument kind: File");
    ComPtr<IFileActivatedEventArgs> fileArgs;
    args.As(&fileArgs);
    FileActivated(fileArgs, aStartup);
  } else if (kind == ActivationKind::ActivationKind_Launch) {
    Log("Activation argument kind: Launch");
    ComPtr<ILaunchActivatedEventArgs> launchArgs;
    args.As(&launchArgs);
    LaunchActivated(launchArgs, aStartup);
  }
}

void
FrameworkView::SetupContracts()
{
  LogFunction();
  HRESULT hr;

  // Add support for the share charm to indicate that we share data to other apps
  ComPtr<IDataTransferManagerStatics> transStatics;
  hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_DataTransfer_DataTransferManager).Get(),
                            transStatics.GetAddressOf());
  AssertHRESULT(hr);
  ComPtr<IDataTransferManager> trans;
  AssertHRESULT(transStatics->GetForCurrentView(trans.GetAddressOf()));
  trans->add_DataRequested(Callback<__FITypedEventHandler_2_Windows__CApplicationModel__CDataTransfer__CDataTransferManager_Windows__CApplicationModel__CDataTransfer__CDataRequestedEventArgs_t>(
    this, &FrameworkView::OnDataShareRequested).Get(), &mDataTransferRequested);

  // Add support for the search charm to indicate that you can search using our app.
  ComPtr<ISearchPaneStatics> searchStatics;
  hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_Search_SearchPane).Get(),
                            searchStatics.GetAddressOf());
  AssertHRESULT(hr);
  ComPtr<ISearchPane> searchPane;
  AssertHRESULT(searchStatics->GetForCurrentView(searchPane.GetAddressOf()));
  searchPane->add_QuerySubmitted(Callback<__FITypedEventHandler_2_Windows__CApplicationModel__CSearch__CSearchPane_Windows__CApplicationModel__CSearch__CSearchPaneQuerySubmittedEventArgs_t>(
    this, &FrameworkView::OnSearchQuerySubmitted).Get(), &mSearchQuerySubmitted);

  // Add support for the devices play to charm
  ComPtr<IPlayToManagerStatics> playToStatics;
  hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Media_PlayTo_PlayToManager).Get(),
                            playToStatics.GetAddressOf());
  AssertHRESULT(hr);
  ComPtr<IPlayToManager> playTo;
  AssertHRESULT(playToStatics->GetForCurrentView(playTo.GetAddressOf()));
  playTo->add_SourceRequested(Callback<__FITypedEventHandler_2_Windows__CMedia__CPlayTo__CPlayToManager_Windows__CMedia__CPlayTo__CPlayToSourceRequestedEventArgs_t>(
    this, &FrameworkView::OnPlayToSourceRequested).Get(), &mPlayToRequested);

  // Add support for the settings charm
  ComPtr<ISettingsPaneStatics> settingsPaneStatics;
  hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ApplicationSettings_SettingsPane).Get(),
                            settingsPaneStatics.GetAddressOf());
  AssertHRESULT(hr);
  ComPtr<ISettingsPane> settingsPane;
  AssertHRESULT(settingsPaneStatics->GetForCurrentView(settingsPane.GetAddressOf()));
  settingsPane->add_CommandsRequested(Callback<__FITypedEventHandler_2_Windows__CUI__CApplicationSettings__CSettingsPane_Windows__CUI__CApplicationSettings__CSettingsPaneCommandsRequestedEventArgs_t>(
    this, &FrameworkView::OnSettingsCommandsRequested).Get(), &mSettingsPane);

  // Add support for the settings print charm
  ComPtr<IPrintManagerStatic> printStatics;
  hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Printing_PrintManager).Get(),
                            printStatics.GetAddressOf());
  AssertHRESULT(hr);
  ComPtr<IPrintManager> printManager;
  AssertHRESULT(printStatics->GetForCurrentView(printManager.GetAddressOf()));
  printManager->add_PrintTaskRequested(Callback<__FITypedEventHandler_2_Windows__CGraphics__CPrinting__CPrintManager_Windows__CGraphics__CPrinting__CPrintTaskRequestedEventArgs_t>(
    this, &FrameworkView::OnPrintTaskRequested).Get(), &mPrintManager);
}

void
FrameworkView::PerformURILoad(HString& aURI)
{
  LogFunction();

  unsigned int length;
  LogW(L"PerformURILoad uri=%s", aURI.GetRawBuffer(&length));

  nsCOMPtr<nsICommandLineRunner> cmdLine =
    (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
  if (!cmdLine) {
    NS_WARNING("Unable to instantiate command line runner.");
    return;
  }

  nsAutoCString utf8data(NS_ConvertUTF16toUTF8(aURI.GetRawBuffer(&length)));
  const char *argv[] = { "metrobrowser",
                         "-url",
                         utf8data.BeginReading() };
  nsresult rv = cmdLine->Init(ArrayLength(argv),
                              const_cast<char **>(argv), nullptr,
                              nsICommandLine::STATE_REMOTE_EXPLICIT);
  if (NS_FAILED(rv)) {
    NS_WARNING("cmdLine->Init failed.");
    return;
  }
  cmdLine->Run();
}

void
FrameworkView::PerformSearch(HString& aQuery)
{
  LogFunction();

  nsCOMPtr<nsICommandLineRunner> cmdLine =
    (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
  if (!cmdLine) {
    NS_WARNING("Unable to instantiate command line runner.");
    return;
  }

  nsAutoCString parameter;
  parameter.AppendLiteral("\"");
  unsigned int length;
  parameter.Append(NS_ConvertUTF16toUTF8(aQuery.GetRawBuffer(&length)));
  parameter.AppendLiteral("\"");

  const char *argv[] = { "metrobrowser",
                         "-search",
                         parameter.BeginReading() };
  nsresult rv = cmdLine->Init(ArrayLength(argv),
                              const_cast<char **>(argv), nullptr,
                              nsICommandLine::STATE_REMOTE_EXPLICIT);
  if (NS_FAILED(rv)) {
    NS_WARNING("cmdLine->Init failed.");
    return;
  }
  cmdLine->Run();
}

void
FrameworkView::PerformURILoadOrSearch(HString& aString)
{
  LogFunction();

  if (WindowsIsStringEmpty(aString.Get())) {
    Log("Emptry string passed to PerformURILoadOrSearch");
    return;
  }

  // If we have a URI then devert to load the URI directly
  ComPtr<IUriRuntimeClass> uri;
  MetroUtils::CreateUri(aString.Get(), uri);
  if (uri) {
    PerformURILoad(aString);
  } else {
    PerformSearch(aString);
  }
}

HRESULT
FrameworkView::OnDataShareRequested(IDataTransferManager* aDTM,
                                    IDataRequestedEventArgs* aArg)
{
  // Only share pages that contain a title and a URI
  nsCOMPtr<nsIMetroUIUtils> metroUIUtils = do_CreateInstance("@mozilla.org/metro-ui-utils;1");
  if (!metroUIUtils)
      return E_FAIL;

  nsString url, title;
  nsresult rv = metroUIUtils->GetCurrentPageURI(url);
  nsresult rv2 = metroUIUtils->GetCurrentPageTitle(title);
  if (NS_FAILED(rv) || NS_FAILED(rv2)) {
    return E_FAIL;
  }

  // Get the package to share
  HRESULT hr;
  ComPtr<IDataRequest> request;
  AssertRetHRESULT(hr = aArg->get_Request(request.GetAddressOf()), hr);
  ComPtr<IDataPackage> dataPackage;
  AssertRetHRESULT(hr = request->get_Data(dataPackage.GetAddressOf()), hr);
  ComPtr<IDataPackagePropertySet> props;
  AssertRetHRESULT(hr = dataPackage->get_Properties(props.GetAddressOf()), hr);

  // Only add a URI to the package when there is no selected content.
  // This is because most programs treat URIs as highest priority to generate
  // their own preview, but we only want the selected content to show up.
  bool hasSelectedContent = false;
  metroUIUtils->GetHasSelectedContent(&hasSelectedContent);
  if (!hasSelectedContent) {
    ComPtr<IUriRuntimeClass> uri;
    AssertRetHRESULT(hr = MetroUtils::CreateUri(HStringReference(url.BeginReading()).Get(), uri), hr);

    // If there is no selection, then we don't support sharing for sites that
    // are not HTTP, HTTPS, FTP, and FILE.
    HString schemeHString;
    uri->get_SchemeName(schemeHString.GetAddressOf());
    unsigned int length;
    LPCWSTR scheme = schemeHString.GetRawBuffer(&length);
    if (!scheme || wcscmp(scheme, L"http") && wcscmp(scheme, L"https") &&
        wcscmp(scheme, L"ftp") && wcscmp(scheme, L"file")) {
      return S_OK;
    }

    AssertRetHRESULT(hr = dataPackage->SetUri(uri.Get()), hr);
  }

  // Add whatever content metroUIUtils wants us to for the text sharing
  nsString shareText;
  if (NS_SUCCEEDED(metroUIUtils->GetShareText(shareText)) && shareText.Length()) {
    AssertRetHRESULT(hr = dataPackage->SetText(HStringReference(shareText.BeginReading()).Get()) ,hr);
  }

  // Add whatever content metroUIUtils wants us to for the HTML sharing
  nsString shareHTML;
  if (NS_SUCCEEDED(metroUIUtils->GetShareHTML(shareHTML)) && shareHTML.Length()) {
    // The sharing format needs some special headers, so pass it through Windows
    ComPtr<IHtmlFormatHelperStatics> htmlFormatHelper;
    hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_DataTransfer_HtmlFormatHelper).Get(),
                              htmlFormatHelper.GetAddressOf());
    AssertRetHRESULT(hr, hr);
    HSTRING fixedHTML;
    htmlFormatHelper->CreateHtmlFormat(HStringReference(shareHTML.BeginReading()).Get(), &fixedHTML);

    // And now add the fixed HTML to the data package
    AssertRetHRESULT(hr = dataPackage->SetHtmlFormat(fixedHTML), hr);
  }

  // Obtain the brand name
  nsCOMPtr<nsIStringBundleService> bundleService = 
    do_GetService(NS_STRINGBUNDLE_CONTRACTID);
  NS_ENSURE_TRUE(bundleService, E_FAIL);
  nsCOMPtr<nsIStringBundle> brandBundle;
  nsString brandName;
  bundleService->CreateBundle("chrome://branding/locale/brand.properties",
    getter_AddRefs(brandBundle));
  NS_ENSURE_TRUE(brandBundle, E_FAIL);
  if(brandBundle) {
    brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(),
                                   getter_Copies(brandName));
  }

  // Set these properties at the end.  Otherwise users can get a
  // "There was a problem with the data package" error when there
  // is simply nothing to share.
  props->put_ApplicationName(HStringReference(brandName.BeginReading()).Get());
  if (title.Length()) {
    props->put_Title(HStringReference(title.BeginReading()).Get());
  } else {
    props->put_Title(HStringReference(brandName.BeginReading()).Get());
  }
  props->put_Description(HStringReference(url.BeginReading()).Get());

  return S_OK;
}

HRESULT
FrameworkView::OnSearchQuerySubmitted(ISearchPane* aPane,
                                      ISearchPaneQuerySubmittedEventArgs* aArgs)
{
  LogFunction();
  HString aQuery;
  aArgs->get_QueryText(aQuery.GetAddressOf());
  PerformURILoadOrSearch(aQuery);
  return S_OK;
}

HRESULT
FrameworkView::OnSettingsCommandInvoked(IUICommand* aCommand)
{
  LogFunction();
  HRESULT hr;
  uint32_t id;
  ComPtr<IPropertyValue> prop;
  AssertRetHRESULT(hr = aCommand->get_Id((IInspectable**)prop.GetAddressOf()), hr);
  AssertRetHRESULT(hr = prop->GetUInt32(&id), hr);

  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
  if (obs) {
    NS_ConvertASCIItoUTF16 idStr(nsPrintfCString("%lu", id));
    obs->NotifyObservers(nullptr, "metro-settings-entry-selected", idStr.BeginReading());
  }

  return S_OK;
}

void
FrameworkView::AddSetting(ISettingsPaneCommandsRequestedEventArgs* aArgs,
                          uint32_t aId, HString& aSettingName)
{
  HRESULT hr;

  ComPtr<ABI::Windows::UI::ApplicationSettings::ISettingsPaneCommandsRequest> request;
  AssertHRESULT(aArgs->get_Request(request.GetAddressOf()));

  // ApplicationCommands - vector that holds SettingsCommand to be invoked
  ComPtr<IVector<ABI::Windows::UI::ApplicationSettings::SettingsCommand*>> list;
  AssertHRESULT(request->get_ApplicationCommands(list.GetAddressOf()));

  ComPtr<IUICommand> command;
  ComPtr<ISettingsCommandFactory> factory;
  hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_ApplicationSettings_SettingsCommand).Get(),
                            factory.GetAddressOf());
  AssertHRESULT(hr);

  // Create the IInspectable string property that identifies this command
  ComPtr<IInspectable> prop;
  ComPtr<IPropertyValueStatics> propStatics;
  hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Foundation_PropertyValue).Get(),
                            propStatics.GetAddressOf());
  AssertHRESULT(hr);
  hr = propStatics->CreateUInt32(aId, prop.GetAddressOf());
  AssertHRESULT(hr);

  // Create the command
  hr = factory->CreateSettingsCommand(prop.Get(), aSettingName.Get(),
    Callback<ABI::Windows::UI::Popups::IUICommandInvokedHandler>(
      this, &FrameworkView::OnSettingsCommandInvoked).Get(), command.GetAddressOf());
  AssertHRESULT(hr);

  // Add it to the list
  hr = list->Append(command.Get());
  AssertHRESULT(hr);
}

HRESULT
FrameworkView::OnSettingsCommandsRequested(ISettingsPane* aPane,
                                           ISettingsPaneCommandsRequestedEventArgs* aArgs)
{
  if (!sSettingsArray)
    return E_FAIL;
  if (!sSettingsArray->Length())
    return S_OK;
  for (uint32_t i = 0; i < sSettingsArray->Length(); i++) {
    HString label;
    label.Set(sSettingsArray->ElementAt(i).BeginReading());
    AddSetting(aArgs, i, label);
  }
  return S_OK;
}

HRESULT
FrameworkView::OnPlayToSourceRequested(IPlayToManager* aPlayToManager,
                                       IPlayToSourceRequestedEventArgs* aArgs)
{
  // TODO: Implement PlayTo, find the element on the page and then do something similar to this:
  // PlayToReceiver::Dispatcher.Helper.BeginInvoke(
  // mMediaElement = ref new Windows::UI::Xaml::Controls::MediaElement();
  // mMediaElement->Source = ref new Uri("http://www.youtube.com/watch?v=2U0NFgoNI7s");
  // aArgs->SourceRequest->SetSource(mMediaElement->PlayToSource);
 return S_OK;
}

HRESULT
FrameworkView::OnPrintTaskSourceRequested(IPrintTaskSourceRequestedArgs* aArgs)
{
 return S_OK;
}

HRESULT
FrameworkView::OnPrintTaskRequested(IPrintManager* aPrintManager,
                                    IPrintTaskRequestedEventArgs* aArgs)
{
 return S_OK;
}

void
FrameworkView::CreatePrintControl(IPrintDocumentPackageTarget* docPackageTarget,
                                  D2D1_PRINT_CONTROL_PROPERTIES* printControlProperties)
{
}

HRESULT
FrameworkView::ClosePrintControl()
{
  return S_OK;
}

// Print out one page, with the given print ticket.
// This sample has only one page and we ignore pageNumber below.
void FrameworkView::PrintPage(uint32_t pageNumber,
                              D2D1_RECT_F imageableArea,
                              D2D1_SIZE_F pageSize,
                              IStream* pagePrintTicketStream)
{
}

} } }