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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 if (proceed) { | 113 if (proceed) { |
114 controller()->Resume(); | 114 controller()->Resume(); |
115 } else { | 115 } else { |
116 controller()->Cancel(); | 116 controller()->Cancel(); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 bool OfflineResourceThrottle::IsRemote(const GURL& url) const { | 120 bool OfflineResourceThrottle::IsRemote(const GURL& url) const { |
121 return !net::IsLocalhost(url.host()) && (url.SchemeIs(content::kFtpScheme) || | 121 return !net::IsLocalhost(url.host()) && (url.SchemeIs(content::kFtpScheme) || |
122 url.SchemeIs(content::kHttpScheme) || | 122 url.SchemeIs(url::kHttpScheme) || |
123 url.SchemeIs(content::kHttpsScheme)); | 123 url.SchemeIs(url::kHttpsScheme)); |
124 } | 124 } |
125 | 125 |
126 bool OfflineResourceThrottle::ShouldShowOfflinePage(const GURL& url) const { | 126 bool OfflineResourceThrottle::ShouldShowOfflinePage(const GURL& url) const { |
127 // If the network is disconnected while loading other resources, we'll simply | 127 // If the network is disconnected while loading other resources, we'll simply |
128 // show broken link/images. | 128 // show broken link/images. |
129 return IsRemote(url) && net::NetworkChangeNotifier::IsOffline(); | 129 return IsRemote(url) && net::NetworkChangeNotifier::IsOffline(); |
130 } | 130 } |
131 | 131 |
132 void OfflineResourceThrottle::OnCanHandleOfflineComplete(int rv) { | 132 void OfflineResourceThrottle::OnCanHandleOfflineComplete(int rv) { |
133 appcache_completion_callback_.Cancel(); | 133 appcache_completion_callback_.Cancel(); |
134 | 134 |
135 if (rv == net::OK) { | 135 if (rv == net::OK) { |
136 controller()->Resume(); | 136 controller()->Resume(); |
137 } else { | 137 } else { |
138 const content::ResourceRequestInfo* info = | 138 const content::ResourceRequestInfo* info = |
139 content::ResourceRequestInfo::ForRequest(request_); | 139 content::ResourceRequestInfo::ForRequest(request_); |
140 BrowserThread::PostTask( | 140 BrowserThread::PostTask( |
141 BrowserThread::UI, | 141 BrowserThread::UI, |
142 FROM_HERE, | 142 FROM_HERE, |
143 base::Bind( | 143 base::Bind( |
144 &ShowOfflinePage, | 144 &ShowOfflinePage, |
145 info->GetChildID(), | 145 info->GetChildID(), |
146 info->GetRouteID(), | 146 info->GetRouteID(), |
147 request_->url(), | 147 request_->url(), |
148 base::Bind( | 148 base::Bind( |
149 &OfflineResourceThrottle::OnBlockingPageComplete, | 149 &OfflineResourceThrottle::OnBlockingPageComplete, |
150 AsWeakPtr()))); | 150 AsWeakPtr()))); |
151 } | 151 } |
152 } | 152 } |
OLD | NEW |