Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: chrome/browser/tabs/pinned_tab_service.cc

Issue 1026005: Makes pinned tab restore on startup if you haven't enabled session (Closed)
Patch Set: check Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/tabs/pinned_tab_service.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/tabs/pinned_tab_service.h"
6
7 #include "chrome/browser/browser.h"
8 #include "chrome/browser/profile.h"
9 #include "chrome/browser/tabs/pinned_tab_codec.h"
10 #include "chrome/common/notification_service.h"
11 #include "chrome/common/notification_type.h"
12
13 PinnedTabService::PinnedTabService(Profile* profile)
14 : profile_(profile),
15 got_exiting_(false) {
16 registrar_.Add(this, NotificationType::BROWSER_CLOSING,
17 NotificationService::AllSources());
18 registrar_.Add(this, NotificationType::APP_EXITING,
19 NotificationService::AllSources());
20 }
21
22 void PinnedTabService::Observe(NotificationType type,
23 const NotificationSource& source,
24 const NotificationDetails& details) {
25 if (got_exiting_)
26 return;
27
28 switch (type.value) {
29 case NotificationType::BROWSER_CLOSING: {
30 Browser* browser = Source<Browser>(source).ptr();
31 if (browser->profile() == profile_ && *(Details<bool>(details)).ptr())
32 GotExit();
33 break;
34 }
35
36 case NotificationType::APP_EXITING: {
37 GotExit();
38 break;
39 }
40
41 default:
42 NOTREACHED();
43 }
44 }
45
46 void PinnedTabService::GotExit() {
47 DCHECK(!got_exiting_);
48 got_exiting_ = true;
49 PinnedTabCodec::WritePinnedTabs(profile_);
50 }
OLDNEW
« no previous file with comments | « chrome/browser/tabs/pinned_tab_service.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698