OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_TABS_PINNED_TAB_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_UI_TABS_PINNED_TAB_SERVICE_H_ |
6 #define CHROME_BROWSER_UI_TABS_PINNED_TAB_SERVICE_H_ | 6 #define CHROME_BROWSER_UI_TABS_PINNED_TAB_SERVICE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/scoped_observer.h" |
| 11 #include "chrome/browser/ui/browser_list.h" |
| 12 #include "chrome/browser/ui/browser_list_observer.h" |
10 #include "components/keyed_service/core/keyed_service.h" | 13 #include "components/keyed_service/core/keyed_service.h" |
11 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
13 | 16 |
14 class Profile; | 17 class Profile; |
15 | 18 |
16 // PinnedTabService is responsible for updating preferences with the set of | 19 // PinnedTabService is responsible for updating preferences with the set of |
17 // pinned tabs to restore at startup. PinnedTabService listens for the | 20 // pinned tabs to restore at startup. PinnedTabService listens for the |
18 // appropriate set of notifications to know it should update preferences. | 21 // appropriate set of notifications to know it should update preferences. |
19 class PinnedTabService : public content::NotificationObserver, | 22 class PinnedTabService : public content::NotificationObserver, |
| 23 public chrome::BrowserListObserver, |
20 public KeyedService { | 24 public KeyedService { |
21 public: | 25 public: |
22 explicit PinnedTabService(Profile* profile); | 26 explicit PinnedTabService(Profile* profile); |
| 27 ~PinnedTabService() override; |
23 | 28 |
24 private: | 29 private: |
25 // content::NotificationObserver. | 30 // content::NotificationObserver. |
26 void Observe(int type, | 31 void Observe(int type, |
27 const content::NotificationSource& source, | 32 const content::NotificationSource& source, |
28 const content::NotificationDetails& details) override; | 33 const content::NotificationDetails& details) override; |
29 | 34 |
| 35 // chrome::BrowserListObserver: |
| 36 void OnBrowserClosing(Browser* browser) override; |
| 37 |
30 Profile* profile_; | 38 Profile* profile_; |
31 | 39 |
32 // True if we should save the pinned tabs when a browser window closes or the | 40 // True if we should save the pinned tabs when a browser window closes or the |
33 // user exits the application. | 41 // user exits the application. |
34 bool save_pinned_tabs_; | 42 bool save_pinned_tabs_; |
35 | 43 |
36 // True if there is at least one normal browser for our profile. | 44 // True if there is at least one normal browser for our profile. |
37 bool has_normal_browser_; | 45 bool has_normal_browser_; |
38 | 46 |
39 content::NotificationRegistrar registrar_; | 47 content::NotificationRegistrar registrar_; |
40 | 48 |
| 49 ScopedObserver<BrowserList, BrowserListObserver> browser_list_observer_; |
| 50 |
41 DISALLOW_COPY_AND_ASSIGN(PinnedTabService); | 51 DISALLOW_COPY_AND_ASSIGN(PinnedTabService); |
42 }; | 52 }; |
43 | 53 |
44 #endif // CHROME_BROWSER_UI_TABS_PINNED_TAB_SERVICE_H_ | 54 #endif // CHROME_BROWSER_UI_TABS_PINNED_TAB_SERVICE_H_ |
OLD | NEW |