| 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 #include "chrome/browser/tabs/pinned_tab_service.h" | 5 #include "chrome/browser/tabs/pinned_tab_service.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/tabs/pinned_tab_codec.h" | 8 #include "chrome/browser/tabs/pinned_tab_codec.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/ui/browser_list.h" |
| 11 #include "chrome/common/chrome_notification_types.h" | 11 #include "chrome/common/chrome_notification_types.h" |
| 12 #include "content/common/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
| 13 | 13 |
| 14 static bool IsLastNormalBrowser(Browser* browser) { | 14 static bool IsLastNormalBrowser(Browser* browser) { |
| 15 for (BrowserList::const_iterator i = BrowserList::begin(); | 15 for (BrowserList::const_iterator i = BrowserList::begin(); |
| 16 i != BrowserList::end(); ++i) { | 16 i != BrowserList::end(); ++i) { |
| 17 if (*i != browser && (*i)->is_type_tabbed() && | 17 if (*i != browser && (*i)->is_type_tabbed() && |
| 18 (*i)->profile() == browser->profile()) { | 18 (*i)->profile() == browser->profile()) { |
| 19 return false; | 19 return false; |
| 20 } | 20 } |
| 21 } | 21 } |
| 22 return true; | 22 return true; |
| 23 } | 23 } |
| 24 | 24 |
| 25 PinnedTabService::PinnedTabService(Profile* profile) | 25 PinnedTabService::PinnedTabService(Profile* profile) |
| 26 : profile_(profile), | 26 : profile_(profile), |
| 27 got_exiting_(false), | 27 got_exiting_(false), |
| 28 has_normal_browser_(false) { | 28 has_normal_browser_(false) { |
| 29 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED, | 29 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED, |
| 30 NotificationService::AllBrowserContextsAndSources()); | 30 content::NotificationService::AllBrowserContextsAndSources()); |
| 31 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING, | 31 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSING, |
| 32 NotificationService::AllSources()); | 32 content::NotificationService::AllSources()); |
| 33 registrar_.Add(this, content::NOTIFICATION_APP_EXITING, | 33 registrar_.Add(this, content::NOTIFICATION_APP_EXITING, |
| 34 NotificationService::AllSources()); | 34 content::NotificationService::AllSources()); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void PinnedTabService::Observe(int type, | 37 void PinnedTabService::Observe(int type, |
| 38 const content::NotificationSource& source, | 38 const content::NotificationSource& source, |
| 39 const content::NotificationDetails& details) { | 39 const content::NotificationDetails& details) { |
| 40 if (got_exiting_) | 40 if (got_exiting_) |
| 41 return; | 41 return; |
| 42 | 42 |
| 43 switch (type) { | 43 switch (type) { |
| 44 case chrome::NOTIFICATION_BROWSER_OPENED: { | 44 case chrome::NOTIFICATION_BROWSER_OPENED: { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 72 default: | 72 default: |
| 73 NOTREACHED(); | 73 NOTREACHED(); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 void PinnedTabService::GotExit() { | 77 void PinnedTabService::GotExit() { |
| 78 DCHECK(!got_exiting_); | 78 DCHECK(!got_exiting_); |
| 79 got_exiting_ = true; | 79 got_exiting_ = true; |
| 80 PinnedTabCodec::WritePinnedTabs(profile_); | 80 PinnedTabCodec::WritePinnedTabs(profile_); |
| 81 } | 81 } |
| OLD | NEW |