12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
57dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "apps/app_window_contents.h"
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
74e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "apps/ui/native_app_window.h"
87dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "chrome/browser/chrome_notification_types.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/profiles/profile.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/common/extensions/api/app_window.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/common/extensions/extension_messages.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/browser_thread.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/render_process_host.h"
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/render_view_host.h"
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/resource_dispatcher_host.h"
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/site_instance.h"
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/browser/web_contents.h"
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/public/common/renderer_preferences.h"
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace app_window = extensions::api::app_window;
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)namespace {
231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)const int kUnboundedSize = apps::ShellWindow::SizeConstraints::kUnboundedSize;
251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}
271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
287dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdochnamespace apps {
29eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)AppWindowContents::AppWindowContents(ShellWindow* host)
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    : host_(host) {
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)AppWindowContents::~AppWindowContents() {
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void AppWindowContents::Initialize(Profile* profile, const GURL& url) {
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  url_ = url;
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  extension_function_dispatcher_.reset(
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      new ExtensionFunctionDispatcher(profile, this));
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  web_contents_.reset(content::WebContents::Create(
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      content::WebContents::CreateParams(
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)          profile, content::SiteInstance::CreateForURL(profile, url_))));
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  content::WebContentsObserver::Observe(web_contents_.get());
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  web_contents_->GetMutableRendererPrefs()->
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      browser_handles_all_top_level_requests = true;
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  web_contents_->GetRenderViewHost()->SyncRendererPrefs();
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void AppWindowContents::LoadContents(int32 creator_process_id) {
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // If the new view is in the same process as the creator, block the created
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // RVH from loading anything until the background page has had a chance to
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // do any initialization it wants. If it's a different process, the new RVH
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // shouldn't communicate with the background page anyway (e.g. sandboxed).
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (web_contents_->GetRenderViewHost()->GetProcess()->GetID() ==
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      creator_process_id) {
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    SuspendRenderViewHost(web_contents_->GetRenderViewHost());
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  } else {
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    VLOG(1) << "ShellWindow created in new process ("
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            << web_contents_->GetRenderViewHost()->GetProcess()->GetID()
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            << ") != creator (" << creator_process_id
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            << "). Routing disabled.";
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // TODO(jeremya): there's a bug where navigating a web contents to an
694e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // extension URL causes it to create a new RVH and discard the old (perfectly
704e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // usable) one. To work around this, we watch for a
714e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // NOTIFICATION_RENDER_VIEW_HOST_CHANGED message from the web contents (which
724e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // will be sent during LoadURL) and suspend resource requests on the new RVH
734e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // to ensure that we block the new RVH from loading anything. It should be
744e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // okay to remove the NOTIFICATION_RENDER_VIEW_HOST_CHANGED registration once
754e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // http://crbug.com/123007 is fixed.
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
774e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)                 content::Source<content::WebContents>(web_contents()));
782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  web_contents_->GetController().LoadURL(
792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      url_, content::Referrer(), content::PAGE_TRANSITION_LINK,
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      std::string());
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  registrar_.RemoveAll();
822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void AppWindowContents::NativeWindowChanged(
852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    NativeAppWindow* native_app_window) {
86eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  base::ListValue args;
872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DictionaryValue* dictionary = new DictionaryValue();
882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  args.Append(dictionary);
892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Rect bounds = host_->GetClientBounds();
912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  app_window::Bounds update;
922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  update.left.reset(new int(bounds.x()));
932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  update.top.reset(new int(bounds.y()));
942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  update.width.reset(new int(bounds.width()));
952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  update.height.reset(new int(bounds.height()));
962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  dictionary->Set("bounds", update.ToValue().release());
972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  dictionary->SetBoolean("fullscreen",
982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                         native_app_window->IsFullscreenOrPending());
992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  dictionary->SetBoolean("minimized", native_app_window->IsMinimized());
1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  dictionary->SetBoolean("maximized", native_app_window->IsMaximized());
101f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  dictionary->SetBoolean("alwaysOnTop", host_->IsAlwaysOnTop());
1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1031e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  const ShellWindow::SizeConstraints& size_constraints =
1041e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      host_->size_constraints();
1051e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  gfx::Size min_size = size_constraints.GetMinimumSize();
1061e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  gfx::Size max_size = size_constraints.GetMaximumSize();
1071e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  if (min_size.width() != kUnboundedSize)
1081e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    dictionary->SetInteger("minWidth", min_size.width());
1091e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  if (min_size.height() != kUnboundedSize)
1101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    dictionary->SetInteger("minHeight", min_size.height());
1111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  if (max_size.width() != kUnboundedSize)
1121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    dictionary->SetInteger("maxWidth", max_size.width());
1131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  if (max_size.height() != kUnboundedSize)
1141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    dictionary->SetInteger("maxHeight", max_size.height());
1151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  rvh->Send(new ExtensionMsg_MessageInvoke(rvh->GetRoutingID(),
11868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles)                                           host_->extension_id(),
119868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)                                           "app.window",
1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                           "updateAppWindowProperties",
1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                           args,
1222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                           false));
1232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void AppWindowContents::NativeWindowClosed() {
1262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  rvh->Send(new ExtensionMsg_AppWindowClosed(rvh->GetRoutingID()));
1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)content::WebContents* AppWindowContents::GetWebContents() const {
1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return web_contents_.get();
1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void AppWindowContents::Observe(
1352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    int type,
1362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const content::NotificationSource& source,
1372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const content::NotificationDetails& details) {
1382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  switch (type) {
1392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    case content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED: {
1402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      // TODO(jeremya): once http://crbug.com/123007 is fixed, we'll no longer
1412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      // need to suspend resource requests here (the call in the constructor
1422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      // should be enough).
1432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      content::Details<std::pair<content::RenderViewHost*,
1442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                 content::RenderViewHost*> >
1452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)          host_details(details);
1462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      if (host_details->first)
1472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)        SuspendRenderViewHost(host_details->second);
1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      break;
1492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    }
1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    default:
1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      NOTREACHED() << "Received unexpected notification";
1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool AppWindowContents::OnMessageReceived(const IPC::Message& message) {
1562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool handled = true;
1572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  IPC_BEGIN_MESSAGE_MAP(AppWindowContents, message)
1582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    IPC_MESSAGE_HANDLER(ExtensionHostMsg_UpdateDraggableRegions,
1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                        UpdateDraggableRegions)
1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    IPC_MESSAGE_UNHANDLED(handled = false)
1622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  IPC_END_MESSAGE_MAP()
1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return handled;
1642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)extensions::WindowController*
1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)AppWindowContents::GetExtensionWindowController() const {
1682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return NULL;
1692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)content::WebContents* AppWindowContents::GetAssociatedWebContents() const {
1722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return web_contents_.get();
1732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void AppWindowContents::OnRequest(
1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const ExtensionHostMsg_Request_Params& params) {
1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  extension_function_dispatcher_->Dispatch(
1782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      params, web_contents_->GetRenderViewHost());
1792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void AppWindowContents::UpdateDraggableRegions(
1822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const std::vector<extensions::DraggableRegion>& regions) {
1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  host_->UpdateDraggableRegions(regions);
1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void AppWindowContents::SuspendRenderViewHost(
1872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    content::RenderViewHost* rvh) {
1882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DCHECK(rvh);
1892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  content::BrowserThread::PostTask(
1902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      content::BrowserThread::IO, FROM_HERE,
1912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      base::Bind(&content::ResourceDispatcherHost::BlockRequestsForRoute,
1922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                 base::Unretained(content::ResourceDispatcherHost::Get()),
1932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                 rvh->GetProcess()->GetID(), rvh->GetRoutingID()));
1942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1957dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
1967dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch}  // namespace apps
197