OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_PAGE_STATE_H__ | |
6 #define CHROME_BROWSER_PAGE_STATE_H__ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/scoped_ptr.h" | |
11 #include "base/values.h" | |
12 | |
13 class GURL; | |
14 | |
15 ///////////////////////////////////////////////////////////////////////////// | |
16 // | |
17 // PageState | |
18 // | |
19 // PageState represents a collection of key value pairs that can be | |
20 // represented as an url or a byte array. It is used by synthetic pages such | |
21 // as the destination tab to store and parse navigation states | |
22 // | |
23 ///////////////////////////////////////////////////////////////////////////// | |
24 class PageState { | |
25 public: | |
26 PageState() : state_(new DictionaryValue) {} | |
27 ~PageState() {} | |
28 | |
29 // Init with the provided url | |
30 void InitWithURL(const GURL& url); | |
31 | |
32 // Init with the provided bytes | |
33 void InitWithBytes(const std::string& bytes); | |
34 | |
35 // Return a string representing this state | |
36 void GetByteRepresentation(std::string* out) const; | |
37 | |
38 // Conveniences to set and retreive an int | |
39 void SetIntProperty(const std::wstring& key, int value); | |
40 bool GetIntProperty(const std::wstring& key, int* value) const; | |
41 | |
42 // Conveniences to set and retreive an int64. | |
43 void SetInt64Property(const std::wstring& key, int64 value); | |
44 bool GetInt64Property(const std::wstring& key, int64* value) const; | |
45 | |
46 // Set / Get string properties | |
47 void SetProperty(const std::wstring& key, const std::wstring& value); | |
48 bool GetProperty(const std::wstring& key, std::wstring* value) const; | |
49 | |
50 // Creates a copy of this page state. It is up to the caller to delete the | |
51 // returned value. | |
52 PageState* Copy() const; | |
53 | |
54 private: | |
55 | |
56 // our actual state collection | |
57 scoped_ptr<DictionaryValue> state_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(PageState); | |
60 }; | |
61 | |
62 | |
63 #endif // CHROME_BROWSER_PAGE_STATE_H__ | |
OLD | NEW |