summaryrefslogtreecommitdiffstats
path: root/ios/chrome/browser/browser_state/chrome_browser_state_removal_controller.h
blob: a59f1d759acf1b5ce55da2f7efad6a23a4434777 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_REMOVAL_CONTROLLER_H_
#define IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_REMOVAL_CONTROLLER_H_

#include <string>

// Controls the removal of extra browser states.
class ChromeBrowserStateRemovalController {
 public:
  static ChromeBrowserStateRemovalController* GetInstance();

  // Removes the browser states marked as not to keep if they exist. It also
  // converts the most recently used bookmarks file to an HTML representation.
  void RemoveBrowserStatesIfNecessary();

  // Returns whether a browser state has been removed. The value is conserved
  // across application restarts.
  bool HasBrowserStateBeenRemoved();

  // Returns the GAIA Id of the removed browser state if it was authenticated.
  // The value should not be trusted unless HasBrowserStateBeenRemoved() returns
  // true.
  const std::string& removed_browser_state_gaia_id() const {
    return removed_browser_state_gaia_id_;
  }

  // Returns whether the last used browser sate was changed during this session.
  bool has_changed_last_used_browser_state() const {
    return has_changed_last_used_browser_state_;
  }

 private:
  ChromeBrowserStateRemovalController();
  ~ChromeBrowserStateRemovalController();

  // Returns the relative path of the browser state path to keep. This value
  // was stored from the user choice.
  std::string GetBrowserStatePathToKeep();

  // Sets whether a browser state has been removed. The value is conserved
  // across application restarts.
  void SetHasBrowserStateBeenRemoved(bool value);

  // Returns the relative path of the last browser state used (during the
  // previous application run).
  std::string GetLastBrowserStatePathUsed();

  // Sets the relative path of the last browser state used.
  void SetLastBrowserStatePathUsed(const std::string& browser_state_path);

  // The GAIA Id of the removed browser state (if any).
  std::string removed_browser_state_gaia_id_;

  // Whether the last used browser state was changed.
  bool has_changed_last_used_browser_state_;
};

#endif  // IOS_CHROME_BROWSER_BROWSER_STATE_CHROME_BROWSER_STATE_REMOVAL_CONTROLLER_H_