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. 4 5 #include "content/renderer/internal_document_state_data.h" 6 7 #include "content/public/renderer/document_state.h" 8 #include "third_party/WebKit/public/web/WebDataSource.h" 9 10 namespace content { 11 12 namespace { 13 14 // Key InternalDocumentStateData is stored under in DocumentState. 15 const char kUserDataKey[] = "InternalDocumentStateData"; 16 17 } 18 InternalDocumentStateData()19InternalDocumentStateData::InternalDocumentStateData() 20 : did_first_visually_non_empty_layout_(false), 21 did_first_visually_non_empty_paint_(false), 22 http_status_code_(0), 23 use_error_page_(false), 24 is_overriding_user_agent_(false), 25 must_reset_scroll_and_scale_state_(false), 26 cache_policy_override_set_(false), 27 cache_policy_override_(blink::WebURLRequest::UseProtocolCachePolicy) { 28 } 29 30 // static FromDataSource(blink::WebDataSource * ds)31InternalDocumentStateData* InternalDocumentStateData::FromDataSource( 32 blink::WebDataSource* ds) { 33 return FromDocumentState(static_cast<DocumentState*>(ds->extraData())); 34 } 35 36 // static FromDocumentState(DocumentState * ds)37InternalDocumentStateData* InternalDocumentStateData::FromDocumentState( 38 DocumentState* ds) { 39 if (!ds) 40 return NULL; 41 InternalDocumentStateData* data = static_cast<InternalDocumentStateData*>( 42 ds->GetUserData(&kUserDataKey)); 43 if (!data) { 44 data = new InternalDocumentStateData; 45 ds->SetUserData(&kUserDataKey, data); 46 } 47 return data; 48 } 49 ~InternalDocumentStateData()50InternalDocumentStateData::~InternalDocumentStateData() { 51 } 52 53 } // namespace content 54