OLD | NEW |
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 "chrome/browser/renderer_host/offline_resource_throttle.h" | 5 #include "chrome/browser/renderer_host/offline_resource_throttle.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
111 | 111 |
112 if (proceed) { | 112 if (proceed) { |
113 controller()->Resume(); | 113 controller()->Resume(); |
114 } else { | 114 } else { |
115 controller()->Cancel(); | 115 controller()->Cancel(); |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 bool OfflineResourceThrottle::IsRemote(const GURL& url) const { | 119 bool OfflineResourceThrottle::IsRemote(const GURL& url) const { |
120 return !net::IsLocalhost(url.host()) && | 120 return !net::IsLocalhost(url.host()) && (url.SchemeIs(chrome::kFtpScheme) || |
121 (url.SchemeIs(chrome::kFtpScheme) || | 121 url.SchemeIs(chrome::kHttpScheme) || |
122 url.SchemeIs(chrome::kHttpScheme) || | 122 url.SchemeIs(content::kHttpsScheme)); |
123 url.SchemeIs(chrome::kHttpsScheme)); | |
124 } | 123 } |
125 | 124 |
126 bool OfflineResourceThrottle::ShouldShowOfflinePage(const GURL& url) const { | 125 bool OfflineResourceThrottle::ShouldShowOfflinePage(const GURL& url) const { |
127 // If the network is disconnected while loading other resources, we'll simply | 126 // If the network is disconnected while loading other resources, we'll simply |
128 // show broken link/images. | 127 // show broken link/images. |
129 return IsRemote(url) && net::NetworkChangeNotifier::IsOffline(); | 128 return IsRemote(url) && net::NetworkChangeNotifier::IsOffline(); |
130 } | 129 } |
131 | 130 |
132 void OfflineResourceThrottle::OnCanHandleOfflineComplete(int rv) { | 131 void OfflineResourceThrottle::OnCanHandleOfflineComplete(int rv) { |
133 appcache_completion_callback_.Cancel(); | 132 appcache_completion_callback_.Cancel(); |
134 | 133 |
135 if (rv == net::OK) { | 134 if (rv == net::OK) { |
136 controller()->Resume(); | 135 controller()->Resume(); |
137 } else { | 136 } else { |
138 BrowserThread::PostTask( | 137 BrowserThread::PostTask( |
139 BrowserThread::UI, | 138 BrowserThread::UI, |
140 FROM_HERE, | 139 FROM_HERE, |
141 base::Bind( | 140 base::Bind( |
142 &ShowOfflinePage, | 141 &ShowOfflinePage, |
143 render_process_id_, | 142 render_process_id_, |
144 render_view_id_, | 143 render_view_id_, |
145 request_->url(), | 144 request_->url(), |
146 base::Bind( | 145 base::Bind( |
147 &OfflineResourceThrottle::OnBlockingPageComplete, | 146 &OfflineResourceThrottle::OnBlockingPageComplete, |
148 AsWeakPtr()))); | 147 AsWeakPtr()))); |
149 } | 148 } |
150 } | 149 } |
OLD | NEW |