OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SESSIONS_SESSION_TYPES_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_TYPES_H_ |
6 #define CHROME_BROWSER_SESSIONS_SESSION_TYPES_H_ | 6 #define CHROME_BROWSER_SESSIONS_SESSION_TYPES_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "chrome/browser/sessions/session_id.h" | 15 #include "chrome/browser/sessions/session_id.h" |
16 #include "content/common/page_transition_types.h" | 16 #include "content/public/common/page_transition_types.h" |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 #include "ui/base/ui_base_types.h" | 18 #include "ui/base/ui_base_types.h" |
19 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" |
20 | 20 |
21 class NavigationEntry; | 21 class NavigationEntry; |
22 class Profile; | 22 class Profile; |
23 | 23 |
24 // TabNavigation ------------------------------------------------------------- | 24 // TabNavigation ------------------------------------------------------------- |
25 | 25 |
26 // TabNavigation corresponds to the parts of NavigationEntry needed to restore | 26 // TabNavigation corresponds to the parts of NavigationEntry needed to restore |
27 // the NavigationEntry during session restore and tab restore. | 27 // the NavigationEntry during session restore and tab restore. |
28 // | 28 // |
29 // TabNavigation is cheap and supports copy semantics. | 29 // TabNavigation is cheap and supports copy semantics. |
30 class TabNavigation { | 30 class TabNavigation { |
31 public: | 31 public: |
32 enum TypeMask { | 32 enum TypeMask { |
33 HAS_POST_DATA = 1 | 33 HAS_POST_DATA = 1 |
34 }; | 34 }; |
35 | 35 |
36 TabNavigation(); | 36 TabNavigation(); |
37 TabNavigation(int index, | 37 TabNavigation(int index, |
38 const GURL& virtual_url, | 38 const GURL& virtual_url, |
39 const GURL& referrer, | 39 const GURL& referrer, |
40 const string16& title, | 40 const string16& title, |
41 const std::string& state, | 41 const std::string& state, |
42 PageTransition::Type transition); | 42 content::PageTransition transition); |
43 TabNavigation(const TabNavigation& tab); | 43 TabNavigation(const TabNavigation& tab); |
44 ~TabNavigation(); | 44 ~TabNavigation(); |
45 TabNavigation& operator=(const TabNavigation& tab); | 45 TabNavigation& operator=(const TabNavigation& tab); |
46 | 46 |
47 // Converts this TabNavigation into a NavigationEntry with a page id of | 47 // Converts this TabNavigation into a NavigationEntry with a page id of |
48 // |page_id|. The caller owns the returned NavigationEntry. | 48 // |page_id|. The caller owns the returned NavigationEntry. |
49 NavigationEntry* ToNavigationEntry(int page_id, Profile* profile) const; | 49 NavigationEntry* ToNavigationEntry(int page_id, Profile* profile) const; |
50 | 50 |
51 // Resets this TabNavigation from |entry|. | 51 // Resets this TabNavigation from |entry|. |
52 void SetFromNavigationEntry(const NavigationEntry& entry); | 52 void SetFromNavigationEntry(const NavigationEntry& entry); |
53 | 53 |
54 // Virtual URL of the page. See NavigationEntry::virtual_url() for details. | 54 // Virtual URL of the page. See NavigationEntry::virtual_url() for details. |
55 void set_virtual_url(const GURL& url) { virtual_url_ = url; } | 55 void set_virtual_url(const GURL& url) { virtual_url_ = url; } |
56 const GURL& virtual_url() const { return virtual_url_; } | 56 const GURL& virtual_url() const { return virtual_url_; } |
57 | 57 |
58 // The referrer. | 58 // The referrer. |
59 const GURL& referrer() const { return referrer_; } | 59 const GURL& referrer() const { return referrer_; } |
60 | 60 |
61 // The title of the page. | 61 // The title of the page. |
62 const string16& title() const { return title_; } | 62 const string16& title() const { return title_; } |
63 | 63 |
64 // State bits. | 64 // State bits. |
65 const std::string& state() const { return state_; } | 65 const std::string& state() const { return state_; } |
66 | 66 |
67 // Transition type. | 67 // Transition type. |
68 void set_transition(PageTransition::Type transition) { | 68 void set_transition(content::PageTransition transition) { |
69 transition_ = transition; | 69 transition_ = transition; |
70 } | 70 } |
71 PageTransition::Type transition() const { return transition_; } | 71 content::PageTransition transition() const { return transition_; } |
72 | 72 |
73 // A mask used for arbitrary boolean values needed to represent a | 73 // A mask used for arbitrary boolean values needed to represent a |
74 // NavigationEntry. Currently only contains HAS_POST_DATA or 0. | 74 // NavigationEntry. Currently only contains HAS_POST_DATA or 0. |
75 void set_type_mask(int type_mask) { type_mask_ = type_mask; } | 75 void set_type_mask(int type_mask) { type_mask_ = type_mask; } |
76 int type_mask() const { return type_mask_; } | 76 int type_mask() const { return type_mask_; } |
77 | 77 |
78 // The index in the NavigationController. If this is -1, it means this | 78 // The index in the NavigationController. If this is -1, it means this |
79 // TabNavigation is bogus. | 79 // TabNavigation is bogus. |
80 // | 80 // |
81 // This is used when determining the selected TabNavigation and only useful | 81 // This is used when determining the selected TabNavigation and only useful |
82 // by BaseSessionService and SessionService. | 82 // by BaseSessionService and SessionService. |
83 void set_index(int index) { index_ = index; } | 83 void set_index(int index) { index_ = index; } |
84 int index() const { return index_; } | 84 int index() const { return index_; } |
85 | 85 |
86 // Converts a set of TabNavigations into a set of NavigationEntrys. The | 86 // Converts a set of TabNavigations into a set of NavigationEntrys. The |
87 // caller owns the NavigationEntrys. | 87 // caller owns the NavigationEntrys. |
88 static void CreateNavigationEntriesFromTabNavigations( | 88 static void CreateNavigationEntriesFromTabNavigations( |
89 Profile* profile, | 89 Profile* profile, |
90 const std::vector<TabNavigation>& navigations, | 90 const std::vector<TabNavigation>& navigations, |
91 std::vector<NavigationEntry*>* entries); | 91 std::vector<NavigationEntry*>* entries); |
92 | 92 |
93 private: | 93 private: |
94 friend class BaseSessionService; | 94 friend class BaseSessionService; |
95 | 95 |
96 GURL virtual_url_; | 96 GURL virtual_url_; |
97 GURL referrer_; | 97 GURL referrer_; |
98 string16 title_; | 98 string16 title_; |
99 std::string state_; | 99 std::string state_; |
100 PageTransition::Type transition_; | 100 content::PageTransition transition_; |
101 int type_mask_; | 101 int type_mask_; |
102 | 102 |
103 int index_; | 103 int index_; |
104 }; | 104 }; |
105 | 105 |
106 // SessionTab ---------------------------------------------------------------- | 106 // SessionTab ---------------------------------------------------------------- |
107 | 107 |
108 // SessionTab corresponds to a NavigationController. | 108 // SessionTab corresponds to a NavigationController. |
109 struct SessionTab { | 109 struct SessionTab { |
110 SessionTab(); | 110 SessionTab(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 std::vector<SessionTab*> tabs; | 191 std::vector<SessionTab*> tabs; |
192 | 192 |
193 // Is the window maximized, minimized, or normal? | 193 // Is the window maximized, minimized, or normal? |
194 ui::WindowShowState show_state; | 194 ui::WindowShowState show_state; |
195 | 195 |
196 private: | 196 private: |
197 DISALLOW_COPY_AND_ASSIGN(SessionWindow); | 197 DISALLOW_COPY_AND_ASSIGN(SessionWindow); |
198 }; | 198 }; |
199 | 199 |
200 #endif // CHROME_BROWSER_SESSIONS_SESSION_TYPES_H_ | 200 #endif // CHROME_BROWSER_SESSIONS_SESSION_TYPES_H_ |
OLD | NEW |