Refactor management of overview window copy lifetime into a separate class.
[chromium-blink-merge.git] / content / renderer / internal_document_state_data.cc
blobcd400f371ebf02303b56e8a15d4bb0314adca026
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/renderer/internal_document_state_data.h"
7 #include "content/public/renderer/document_state.h"
8 #include "content/renderer/fetchers/alt_error_page_resource_fetcher.h"
9 #include "third_party/WebKit/public/web/WebDataSource.h"
11 namespace content {
13 namespace {
15 // Key InternalDocumentStateData is stored under in DocumentState.
16 const char kUserDataKey[] = "InternalDocumentStateData";
20 InternalDocumentStateData::InternalDocumentStateData()
21 : did_first_visually_non_empty_layout_(false),
22 did_first_visually_non_empty_paint_(false),
23 http_status_code_(0),
24 use_error_page_(false),
25 is_overriding_user_agent_(false),
26 must_reset_scroll_and_scale_state_(false),
27 cache_policy_override_set_(false),
28 cache_policy_override_(WebKit::WebURLRequest::UseProtocolCachePolicy),
29 referrer_policy_set_(false),
30 referrer_policy_(WebKit::WebReferrerPolicyDefault) {
33 // static
34 InternalDocumentStateData* InternalDocumentStateData::FromDataSource(
35 WebKit::WebDataSource* ds) {
36 return FromDocumentState(static_cast<DocumentState*>(ds->extraData()));
39 // static
40 InternalDocumentStateData* InternalDocumentStateData::FromDocumentState(
41 DocumentState* ds) {
42 if (!ds)
43 return NULL;
44 InternalDocumentStateData* data = static_cast<InternalDocumentStateData*>(
45 ds->GetUserData(&kUserDataKey));
46 if (!data) {
47 data = new InternalDocumentStateData;
48 ds->SetUserData(&kUserDataKey, data);
50 return data;
53 InternalDocumentStateData::~InternalDocumentStateData() {
56 void InternalDocumentStateData::set_alt_error_page_fetcher(
57 AltErrorPageResourceFetcher* f) {
58 alt_error_page_fetcher_.reset(f);
61 } // namespace content