| 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_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ | 6 #define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // it means the session could not be restored. | 175 // it means the session could not be restored. |
| 176 // | 176 // |
| 177 // The created request does NOT directly invoke the callback, rather the | 177 // The created request does NOT directly invoke the callback, rather the |
| 178 // callback invokes OnGotSessionCommands from which we map the | 178 // callback invokes OnGotSessionCommands from which we map the |
| 179 // SessionCommands to browser state, then notify the callback. | 179 // SessionCommands to browser state, then notify the callback. |
| 180 Handle GetCurrentSession(CancelableRequestConsumerBase* consumer, | 180 Handle GetCurrentSession(CancelableRequestConsumerBase* consumer, |
| 181 SessionCallback* callback); | 181 SessionCallback* callback); |
| 182 | 182 |
| 183 // Overridden from BaseSessionService because we want some UMA reporting on | 183 // Overridden from BaseSessionService because we want some UMA reporting on |
| 184 // session update activities. | 184 // session update activities. |
| 185 virtual void Save(); | 185 virtual void Save() OVERRIDE; |
| 186 | 186 |
| 187 private: | 187 private: |
| 188 typedef std::map<SessionID::id_type, std::pair<int, int> > IdToRange; | 188 typedef std::map<SessionID::id_type, std::pair<int, int> > IdToRange; |
| 189 typedef std::map<SessionID::id_type, SessionTab*> IdToSessionTab; | 189 typedef std::map<SessionID::id_type, SessionTab*> IdToSessionTab; |
| 190 typedef std::map<SessionID::id_type, SessionWindow*> IdToSessionWindow; | 190 typedef std::map<SessionID::id_type, SessionWindow*> IdToSessionWindow; |
| 191 | 191 |
| 192 | 192 |
| 193 // These types mirror Browser::Type, but are re-defined here because these | 193 // These types mirror Browser::Type, but are re-defined here because these |
| 194 // specific enumeration _values_ are written into the session database and | 194 // specific enumeration _values_ are written into the session database and |
| 195 // are needed to maintain forward compatibility. | 195 // are needed to maintain forward compatibility. |
| 196 // Note that we only store browsers of type TYPE_TABBED and TYPE_POPUP. | 196 // Note that we only store browsers of type TYPE_TABBED and TYPE_POPUP. |
| 197 enum WindowType { | 197 enum WindowType { |
| 198 TYPE_TABBED = 0, | 198 TYPE_TABBED = 0, |
| 199 TYPE_POPUP = 1 | 199 TYPE_POPUP = 1 |
| 200 }; | 200 }; |
| 201 | 201 |
| 202 void Init(); | 202 void Init(); |
| 203 | 203 |
| 204 // Implementation of RestoreIfNecessary. If |browser| is non-null and we need | 204 // Implementation of RestoreIfNecessary. If |browser| is non-null and we need |
| 205 // to restore, the tabs are added to it, otherwise a new browser is created. | 205 // to restore, the tabs are added to it, otherwise a new browser is created. |
| 206 bool RestoreIfNecessary(const std::vector<GURL>& urls_to_open, | 206 bool RestoreIfNecessary(const std::vector<GURL>& urls_to_open, |
| 207 Browser* browser); | 207 Browser* browser); |
| 208 | 208 |
| 209 virtual void Observe(int type, | 209 virtual void Observe(int type, |
| 210 const content::NotificationSource& source, | 210 const content::NotificationSource& source, |
| 211 const content::NotificationDetails& details); | 211 const content::NotificationDetails& details) OVERRIDE; |
| 212 | 212 |
| 213 // Sets the application extension id of the specified tab. | 213 // Sets the application extension id of the specified tab. |
| 214 void SetTabExtensionAppID(const SessionID& window_id, | 214 void SetTabExtensionAppID(const SessionID& window_id, |
| 215 const SessionID& tab_id, | 215 const SessionID& tab_id, |
| 216 const std::string& extension_app_id); | 216 const std::string& extension_app_id); |
| 217 | 217 |
| 218 // Methods to create the various commands. It is up to the caller to delete | 218 // Methods to create the various commands. It is up to the caller to delete |
| 219 // the returned the SessionCommand* object. | 219 // the returned the SessionCommand* object. |
| 220 SessionCommand* CreateSetSelectedTabInWindow(const SessionID& window_id, | 220 SessionCommand* CreateSetSelectedTabInWindow(const SessionID& window_id, |
| 221 int index); | 221 int index); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 // from the state of the browser. | 343 // from the state of the browser. |
| 344 void ScheduleReset(); | 344 void ScheduleReset(); |
| 345 | 345 |
| 346 // Searches for a pending command that can be replaced with command. | 346 // Searches for a pending command that can be replaced with command. |
| 347 // If one is found, pending command is removed, command is added to | 347 // If one is found, pending command is removed, command is added to |
| 348 // the pending commands and true is returned. | 348 // the pending commands and true is returned. |
| 349 bool ReplacePendingCommand(SessionCommand* command); | 349 bool ReplacePendingCommand(SessionCommand* command); |
| 350 | 350 |
| 351 // Schedules the specified command. This method takes ownership of the | 351 // Schedules the specified command. This method takes ownership of the |
| 352 // command. | 352 // command. |
| 353 virtual void ScheduleCommand(SessionCommand* command); | 353 virtual void ScheduleCommand(SessionCommand* command) OVERRIDE; |
| 354 | 354 |
| 355 // Converts all pending tab/window closes to commands and schedules them. | 355 // Converts all pending tab/window closes to commands and schedules them. |
| 356 void CommitPendingCloses(); | 356 void CommitPendingCloses(); |
| 357 | 357 |
| 358 // Returns true if there is only one window open with a single tab that shares | 358 // Returns true if there is only one window open with a single tab that shares |
| 359 // our profile. | 359 // our profile. |
| 360 bool IsOnlyOneTabLeft(); | 360 bool IsOnlyOneTabLeft(); |
| 361 | 361 |
| 362 // Returns true if there are open trackable browser windows whose ids do | 362 // Returns true if there are open trackable browser windows whose ids do |
| 363 // match |window_id| with our profile. A trackable window is a window from | 363 // match |window_id| with our profile. A trackable window is a window from |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 | 452 |
| 453 // Constants used in calculating histogram data. | 453 // Constants used in calculating histogram data. |
| 454 const base::TimeDelta save_delay_in_millis_; | 454 const base::TimeDelta save_delay_in_millis_; |
| 455 const base::TimeDelta save_delay_in_mins_; | 455 const base::TimeDelta save_delay_in_mins_; |
| 456 const base::TimeDelta save_delay_in_hrs_; | 456 const base::TimeDelta save_delay_in_hrs_; |
| 457 | 457 |
| 458 DISALLOW_COPY_AND_ASSIGN(SessionService); | 458 DISALLOW_COPY_AND_ASSIGN(SessionService); |
| 459 }; | 459 }; |
| 460 | 460 |
| 461 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ | 461 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_H_ |
| OLD | NEW |