1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "base/compiler_specific.h"
MSVC_PUSH_WARNING_LEVEL(0);
#include "ResourceResponse.h"
MSVC_POP_WARNING();
#undef LOG
#include "webkit/glue/alt_error_page_resource_fetcher.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/webframe_impl.h"
#include "webkit/glue/webview_delegate.h"
#include "webkit/glue/webview.h"
// Number of seconds to wait for the alternate error page server. If it takes
// too long, just use the local error page.
static const double kDownloadTimeoutSec = 3.0;
AltErrorPageResourceFetcher::AltErrorPageResourceFetcher(
WebView* web_view,
const WebErrorImpl& web_error,
WebFrameImpl* web_frame,
const GURL& url)
: web_view_(web_view),
web_error_(web_error),
web_frame_(web_frame) {
failed_request_.reset(web_frame_->GetProvisionalDataSource()->
GetRequest().Clone());
fetcher_.reset(new ResourceFetcherWithTimeout(url, web_frame->frame(),
kDownloadTimeoutSec, this));
}
void AltErrorPageResourceFetcher::OnURLFetchComplete(
const WebCore::ResourceResponse& response,
const std::string& data) {
WebViewDelegate* delegate = web_view_->GetDelegate();
if (!delegate)
return;
if (response.httpStatusCode() == 200) {
// We successfully got a response from the alternate error page server, so
// load it.
delegate->LoadNavigationErrorPage(web_frame_, failed_request_.get(),
web_error_, data, true);
} else {
delegate->LoadNavigationErrorPage(web_frame_, failed_request_.get(),
web_error_, std::string(), true);
}
}
|