190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// found in the LICENSE file. 490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#ifndef CONTENT_PUBLIC_COMMON_PAGE_STATE_H_ 690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#define CONTENT_PUBLIC_COMMON_PAGE_STATE_H_ 790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include <string> 990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include <vector> 1090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "content/common/content_export.h" 1290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class GURL; 1490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace base { 1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class FilePath; 1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace content { 2090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// The PageState class represents the information needed by the rendering 2290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// engine to reconstruct a web page (and its tree of frames), including for 2390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// example the URLs of the documents and the values of any form fields. This 2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// information is used when navigating back & forward through session history. 2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// 26010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)// The format of the encoded data is not exposed by the content API. 2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class CONTENT_EXPORT PageState { 2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) public: 2990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) static PageState CreateFromEncodedData(const std::string& data); 3090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) static PageState CreateFromURL(const GURL& url); 3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 3290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) static PageState CreateForTesting( 3390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const GURL& url, 3490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool body_contains_password_data, 3590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const char* optional_body_data, 3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const base::FilePath* optional_body_file_path); 3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 3890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) PageState(); 3990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 4090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool IsValid() const; 4190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) bool Equals(const PageState& page_state) const; 4290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) const std::string& ToEncodedData() const; 4390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 4490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::vector<base::FilePath> GetReferencedFiles() const; 4590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) PageState RemovePasswordData() const; 4690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) PageState RemoveScrollOffset() const; 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) PageState RemoveReferrer() const; 4890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 4990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) private: 5090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) PageState(const std::string& data); 5190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 5290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) std::string data_; 5390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}; 5490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 5590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Support DCHECK_EQ(a, b), etc. 5690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)inline bool operator==(const PageState& a, const PageState& b) { 5790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return a.Equals(b); 5890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 5990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)inline bool operator!=(const PageState& a, const PageState& b) { 6090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) return !(a == b); 6190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 6290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 6390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} // namespace content 6490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 6590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#endif // CONTENT_PUBLIC_COMMON_PAGE_STATE_H_ 66