Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: content/browser/ssl/ssl_error_handler.cc

Issue 1459473003: Add a WebContents getter callback in ResourceRequestInfo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + addressed David's comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/ssl/ssl_error_handler.h" 5 #include "content/browser/ssl/ssl_error_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/frame_host/navigation_controller_impl.h" 8 #include "content/browser/frame_host/navigation_controller_impl.h"
9 #include "content/browser/frame_host/render_frame_host_impl.h" 9 #include "content/browser/frame_host/render_frame_host_impl.h"
10 #include "content/browser/ssl/ssl_cert_error_handler.h" 10 #include "content/browser/ssl/ssl_cert_error_handler.h"
11 #include "content/browser/web_contents/web_contents_impl.h" 11 #include "content/browser/web_contents/web_contents_impl.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/resource_request_info.h" 13 #include "content/public/browser/resource_request_info.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/url_request/url_request.h" 15 #include "net/url_request/url_request.h"
16 16
17 using net::SSLInfo; 17 using net::SSLInfo;
18 18
19 namespace content { 19 namespace content {
20 20
21 SSLErrorHandler::SSLErrorHandler(const base::WeakPtr<Delegate>& delegate, 21 SSLErrorHandler::SSLErrorHandler(const base::WeakPtr<Delegate>& delegate,
22 ResourceType resource_type, 22 ResourceType resource_type,
23 const GURL& url, 23 const GURL& url)
24 int render_process_id,
25 int render_frame_id)
26 : manager_(NULL), 24 : manager_(NULL),
27 delegate_(delegate), 25 delegate_(delegate),
28 render_process_id_(render_process_id),
29 render_frame_id_(render_frame_id),
30 request_url_(url), 26 request_url_(url),
31 resource_type_(resource_type), 27 resource_type_(resource_type),
32 request_has_been_notified_(false) { 28 request_has_been_notified_(false) {
33 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); 29 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
34 DCHECK(delegate.get()); 30 DCHECK(delegate.get());
35 31
36 // This makes sure we don't disappear on the IO thread until we've given an 32 // This makes sure we don't disappear on the IO thread until we've given an
37 // answer to the net::URLRequest. 33 // answer to the net::URLRequest.
38 // 34 //
39 // Release in CompleteCancelRequest, CompleteContinueRequest, or 35 // Release in CompleteCancelRequest, CompleteContinueRequest, or
40 // CompleteTakeNoAction. 36 // CompleteTakeNoAction.
41 AddRef(); 37 AddRef();
42 } 38 }
43 39
44 SSLErrorHandler::~SSLErrorHandler() {} 40 SSLErrorHandler::~SSLErrorHandler() {}
45 41
46 void SSLErrorHandler::OnDispatchFailed() { 42 void SSLErrorHandler::OnDispatchFailed() {
47 TakeNoAction(); 43 TakeNoAction();
48 } 44 }
49 45
50 void SSLErrorHandler::OnDispatched() { 46 void SSLErrorHandler::OnDispatched() {
51 TakeNoAction(); 47 TakeNoAction();
52 } 48 }
53 49
54 SSLCertErrorHandler* SSLErrorHandler::AsSSLCertErrorHandler() { 50 SSLCertErrorHandler* SSLErrorHandler::AsSSLCertErrorHandler() {
55 return NULL; 51 return NULL;
56 } 52 }
57 53
58 void SSLErrorHandler::Dispatch() { 54 void SSLErrorHandler::Dispatch(
55 const base::Callback<WebContents*(void)>& web_contents_getter) {
59 DCHECK_CURRENTLY_ON(BrowserThread::UI); 56 DCHECK_CURRENTLY_ON(BrowserThread::UI);
60 57
61 WebContents* web_contents = NULL; 58 WebContents* web_contents = web_contents_getter.Run();
62 RenderFrameHost* render_frame_host =
63 RenderFrameHost::FromID(render_process_id_, render_frame_id_);
64 web_contents = WebContents::FromRenderFrameHost(render_frame_host);
65 59
66 if (!web_contents) { 60 if (!web_contents) {
67 // We arrived on the UI thread, but the tab we're looking for is no longer 61 // We arrived on the UI thread, but the tab we're looking for is no longer
68 // here. 62 // here.
69 OnDispatchFailed(); 63 OnDispatchFailed();
70 return; 64 return;
71 } 65 }
72 66
73 // Hand ourselves off to the SSLManager. 67 // Hand ourselves off to the SSLManager.
74 manager_ = 68 manager_ =
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 if (request_has_been_notified_) 160 if (request_has_been_notified_)
167 return; 161 return;
168 162
169 request_has_been_notified_ = true; 163 request_has_been_notified_ = true;
170 164
171 // We're done with this object on the IO thread. 165 // We're done with this object on the IO thread.
172 Release(); 166 Release();
173 } 167 }
174 168
175 } // namespace content 169 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698