summaryrefslogtreecommitdiffstats
path: root/content/renderer/internal_document_state_data.cc
blob: f7ae54d872a7dfb6b8a34548a65e78e0fd6e4854 (plain)
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) 2013 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 "content/renderer/internal_document_state_data.h"

#include "content/public/renderer/document_state.h"
#include "content/renderer/fetchers/alt_error_page_resource_fetcher.h"
#include "third_party/WebKit/public/web/WebDataSource.h"

namespace content {

namespace {

// Key InternalDocumentStateData is stored under in DocumentState.
const char kUserDataKey[] = "InternalDocumentStateData";

}

InternalDocumentStateData::InternalDocumentStateData()
    : did_first_visually_non_empty_layout_(false),
      did_first_visually_non_empty_paint_(false),
      http_status_code_(0),
      use_error_page_(false),
      is_overriding_user_agent_(false),
      must_reset_scroll_and_scale_state_(false),
      cache_policy_override_set_(false),
      cache_policy_override_(blink::WebURLRequest::UseProtocolCachePolicy),
      referrer_policy_set_(false),
      referrer_policy_(blink::WebReferrerPolicyDefault) {
}

// static
InternalDocumentStateData* InternalDocumentStateData::FromDataSource(
    blink::WebDataSource* ds) {
  return FromDocumentState(static_cast<DocumentState*>(ds->extraData()));
}

// static
InternalDocumentStateData* InternalDocumentStateData::FromDocumentState(
    DocumentState* ds) {
  if (!ds)
    return NULL;
  InternalDocumentStateData* data = static_cast<InternalDocumentStateData*>(
      ds->GetUserData(&kUserDataKey));
  if (!data) {
    data = new InternalDocumentStateData;
    ds->SetUserData(&kUserDataKey, data);
  }
  return data;
}

InternalDocumentStateData::~InternalDocumentStateData() {
}

}  // namespace content