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