| Index: content/browser/devtools/protocol/page_handler.cc
 | 
| diff --git a/content/browser/devtools/protocol/page_handler.cc b/content/browser/devtools/protocol/page_handler.cc
 | 
| index d5a9244dc95b4123fe0e2ad4e5d1248ac2ba873a..014deca099bd189954f3516ad62e9e3acf45bcb7 100644
 | 
| --- a/content/browser/devtools/protocol/page_handler.cc
 | 
| +++ b/content/browser/devtools/protocol/page_handler.cc
 | 
| @@ -14,6 +14,7 @@
 | 
|  #include "base/strings/utf_string_conversions.h"
 | 
|  #include "base/threading/thread_task_runner_handle.h"
 | 
|  #include "base/threading/worker_pool.h"
 | 
| +#include "content/browser/devtools/page_navigation_throttle.h"
 | 
|  #include "content/browser/devtools/protocol/color_picker.h"
 | 
|  #include "content/browser/renderer_host/render_widget_host_impl.h"
 | 
|  #include "content/browser/renderer_host/render_widget_host_view_base.h"
 | 
| @@ -23,6 +24,7 @@
 | 
|  #include "content/public/browser/javascript_dialog_manager.h"
 | 
|  #include "content/public/browser/navigation_controller.h"
 | 
|  #include "content/public/browser/navigation_entry.h"
 | 
| +#include "content/public/browser/navigation_handle.h"
 | 
|  #include "content/public/browser/notification_service.h"
 | 
|  #include "content/public/browser/notification_types.h"
 | 
|  #include "content/public/browser/storage_partition.h"
 | 
| @@ -102,11 +104,12 @@ PageHandler::PageHandler()
 | 
|        session_id_(0),
 | 
|        frame_counter_(0),
 | 
|        frames_in_flight_(0),
 | 
| -      color_picker_(new ColorPicker(base::Bind(
 | 
| -          &PageHandler::OnColorPicked, base::Unretained(this)))),
 | 
| +      color_picker_(new ColorPicker(
 | 
| +          base::Bind(&PageHandler::OnColorPicked, base::Unretained(this)))),
 | 
| +      navigation_throttle_enabled_(false),
 | 
| +      next_navigation_id_(0),
 | 
|        host_(nullptr),
 | 
| -      weak_factory_(this) {
 | 
| -}
 | 
| +      weak_factory_(this) {}
 | 
|  
 | 
|  PageHandler::~PageHandler() {
 | 
|  }
 | 
| @@ -201,6 +204,7 @@ Response PageHandler::Enable() {
 | 
|  Response PageHandler::Disable() {
 | 
|    enabled_ = false;
 | 
|    screencast_enabled_ = false;
 | 
| +  SetNavigationThrottleEnabled(false);
 | 
|    color_picker_->SetEnabled(false);
 | 
|    return Response::FallThrough();
 | 
|  }
 | 
| @@ -373,6 +377,67 @@ Response PageHandler::RequestAppBanner() {
 | 
|    return Response::OK();
 | 
|  }
 | 
|  
 | 
| +Response PageHandler::SetNavigationThrottleEnabled(bool enabled) {
 | 
| +  navigation_throttle_enabled_ = enabled;
 | 
| +  // We don't own the page PageNavigationThrottles so we can't delete them, but
 | 
| +  // we can turn them into NOPs.
 | 
| +  for (auto& pair : navigation_throttles_) {
 | 
| +    pair.second->AlwaysProceed();
 | 
| +  }
 | 
| +  navigation_throttles_.clear();
 | 
| +  return Response::OK();
 | 
| +}
 | 
| +
 | 
| +Response PageHandler::ProcessNavigation(const std::string& response,
 | 
| +                                        int navigation_id) {
 | 
| +  auto it = navigation_throttles_.find(navigation_id);
 | 
| +  if (it == navigation_throttles_.end())
 | 
| +    return Response::InvalidParams("Unknown navigation id");
 | 
| +
 | 
| +  if (response == kNavigationThrottleResponseProceed) {
 | 
| +    it->second->Resume();
 | 
| +    return Response::OK();
 | 
| +  } else if (response == kNavigationThrottleResponseCancel) {
 | 
| +    it->second->CancelDeferredNavigation(content::NavigationThrottle::CANCEL);
 | 
| +    return Response::OK();
 | 
| +  } else if (response == kNavigationThrottleResponseCancelAndIgnore) {
 | 
| +    it->second->CancelDeferredNavigation(
 | 
| +        content::NavigationThrottle::CANCEL_AND_IGNORE);
 | 
| +    return Response::OK();
 | 
| +  }
 | 
| +
 | 
| +  return Response::InvalidParams("Unrecognized response");
 | 
| +}
 | 
| +
 | 
| +std::unique_ptr<PageNavigationThrottle> PageHandler::GetThrottleForNavigation(
 | 
| +    NavigationHandle* navigation_handle) {
 | 
| +  if (!navigation_throttle_enabled_)
 | 
| +    return nullptr;
 | 
| +
 | 
| +  std::unique_ptr<PageNavigationThrottle> throttle(new PageNavigationThrottle(
 | 
| +      weak_factory_.GetWeakPtr(), next_navigation_id_, navigation_handle));
 | 
| +  navigation_throttles_[next_navigation_id_++] = throttle.get();
 | 
| +  return throttle;
 | 
| +}
 | 
| +
 | 
| +void PageHandler::OnPageNavigationThrottleDisposed(int navigation_id) {
 | 
| +  DCHECK(navigation_throttles_.find(navigation_id) !=
 | 
| +         navigation_throttles_.end());
 | 
| +  navigation_throttles_.erase(navigation_id);
 | 
| +}
 | 
| +
 | 
| +void PageHandler::NavigationRequested(const PageNavigationThrottle* throttle) {
 | 
| +  NavigationHandle* navigation_handle = throttle->navigation_handle();
 | 
| +  client_->NavigationRequested(
 | 
| +      NavigationRequestedParams::Create()
 | 
| +          ->set_is_in_main_frame(navigation_handle->IsInMainFrame())
 | 
| +          ->set_is_parent_main_frame(navigation_handle->IsParentMainFrame())
 | 
| +          ->set_is_redirect(navigation_handle->WasServerRedirect())
 | 
| +          ->set_navigation_id(throttle->navigation_id())
 | 
| +          ->set_url(navigation_handle->GetURL().spec())
 | 
| +          ->set_renderer_initiated(navigation_handle->IsRendererInitiated()));
 | 
| +}
 | 
| +
 | 
|  WebContentsImpl* PageHandler::GetWebContents() {
 | 
|    return host_ ?
 | 
|        static_cast<WebContentsImpl*>(WebContents::FromRenderFrameHost(host_)) :
 | 
| 
 |