Home | History | Annotate | Download | only in renderer
      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 "content/renderer/fetchers/alt_error_page_resource_fetcher.h"
      9 #include "third_party/WebKit/public/web/WebDataSource.h"
     10 
     11 namespace content {
     12 
     13 namespace {
     14 
     15 // Key InternalDocumentStateData is stored under in DocumentState.
     16 const char kUserDataKey[] = "InternalDocumentStateData";
     17 
     18 }
     19 
     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_(blink::WebURLRequest::UseProtocolCachePolicy),
     29       referrer_policy_set_(false),
     30       referrer_policy_(blink::WebReferrerPolicyDefault) {
     31 }
     32 
     33 // static
     34 InternalDocumentStateData* InternalDocumentStateData::FromDataSource(
     35     blink::WebDataSource* ds) {
     36   return FromDocumentState(static_cast<DocumentState*>(ds->extraData()));
     37 }
     38 
     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);
     49   }
     50   return data;
     51 }
     52 
     53 InternalDocumentStateData::~InternalDocumentStateData() {
     54 }
     55 
     56 void InternalDocumentStateData::set_alt_error_page_fetcher(
     57     AltErrorPageResourceFetcher* f) {
     58   alt_error_page_fetcher_.reset(f);
     59 }
     60 
     61 }  // namespace content
     62