| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/internal_document_state_data.h" | 5 #include "content/renderer/internal_document_state_data.h" |
| 6 | 6 |
| 7 #include "content/public/renderer/document_state.h" | 7 #include "content/public/renderer/document_state.h" |
| 8 #include "third_party/WebKit/public/web/WebDataSource.h" | 8 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 // Key InternalDocumentStateData is stored under in DocumentState. | 14 // Key InternalDocumentStateData is stored under in DocumentState. |
| 15 const char kUserDataKey[] = "InternalDocumentStateData"; | 15 const char kUserDataKey[] = "InternalDocumentStateData"; |
| 16 | 16 |
| 17 } | 17 } |
| 18 | 18 |
| 19 InternalDocumentStateData::InternalDocumentStateData() | 19 InternalDocumentStateData::InternalDocumentStateData() |
| 20 : http_status_code_(0), | 20 : http_status_code_(0), |
| 21 is_overriding_user_agent_(false), | 21 is_overriding_user_agent_(false), |
| 22 must_reset_scroll_and_scale_state_(false), | 22 must_reset_scroll_and_scale_state_(false), |
| 23 cache_policy_override_set_(false), | 23 cache_policy_override_set_(false), |
| 24 cache_policy_override_(blink::WebURLRequest::UseProtocolCachePolicy) { | 24 cache_policy_override_(blink::WebCachePolicy::UseProtocolCachePolicy) {} |
| 25 } | |
| 26 | 25 |
| 27 // static | 26 // static |
| 28 InternalDocumentStateData* InternalDocumentStateData::FromDataSource( | 27 InternalDocumentStateData* InternalDocumentStateData::FromDataSource( |
| 29 blink::WebDataSource* ds) { | 28 blink::WebDataSource* ds) { |
| 30 return FromDocumentState(static_cast<DocumentState*>(ds->getExtraData())); | 29 return FromDocumentState(static_cast<DocumentState*>(ds->getExtraData())); |
| 31 } | 30 } |
| 32 | 31 |
| 33 // static | 32 // static |
| 34 InternalDocumentStateData* InternalDocumentStateData::FromDocumentState( | 33 InternalDocumentStateData* InternalDocumentStateData::FromDocumentState( |
| 35 DocumentState* ds) { | 34 DocumentState* ds) { |
| 36 if (!ds) | 35 if (!ds) |
| 37 return NULL; | 36 return NULL; |
| 38 InternalDocumentStateData* data = static_cast<InternalDocumentStateData*>( | 37 InternalDocumentStateData* data = static_cast<InternalDocumentStateData*>( |
| 39 ds->GetUserData(&kUserDataKey)); | 38 ds->GetUserData(&kUserDataKey)); |
| 40 if (!data) { | 39 if (!data) { |
| 41 data = new InternalDocumentStateData; | 40 data = new InternalDocumentStateData; |
| 42 ds->SetUserData(&kUserDataKey, data); | 41 ds->SetUserData(&kUserDataKey, data); |
| 43 } | 42 } |
| 44 return data; | 43 return data; |
| 45 } | 44 } |
| 46 | 45 |
| 47 InternalDocumentStateData::~InternalDocumentStateData() { | 46 InternalDocumentStateData::~InternalDocumentStateData() { |
| 48 } | 47 } |
| 49 | 48 |
| 50 } // namespace content | 49 } // namespace content |
| OLD | NEW |