Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: chrome/browser/ui/startup/obsolete_os_prompt_mac.cc

Issue 10837158: mac: Delete more 10.5-only code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/startup/obsolete_os_prompt.h"
6
7 #include "base/time.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/infobars/infobar_tab_helper.h"
10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_tabstrip.h"
13 #include "chrome/browser/ui/cocoa/obsolete_os.h"
14 #include "chrome/browser/ui/startup/obsolete_os_info_bar.h"
15 #include "chrome/browser/ui/tab_contents/tab_contents.h"
16 #include "chrome/common/pref_names.h"
17 #include "chrome/common/url_constants.h"
18
19 namespace chrome {
20
21 void RegisterObsoleteOSInfobarPrefs(PrefService* local_state) {
22 local_state->RegisterDoublePref(
23 prefs::kMacLeopardObsoleteInfobarLastShown,
24 0,
25 PrefService::UNSYNCABLE_PREF);
26 }
27
28 void ShowObsoleteOSPrompt(Browser* browser) {
29 if (!IsOSObsoleteOrNearlySo())
30 return;
31
32 PrefService* local_state = g_browser_process->local_state();
33 if (!local_state)
34 return;
35
36 // Only show the infobar if the user has not been shown it for more than a
37 // week.
38 base::Time time_now(base::Time::Now());
39 if (local_state->HasPrefPath(prefs::kMacLeopardObsoleteInfobarLastShown)) {
40 double time_double =
41 local_state->GetDouble(prefs::kMacLeopardObsoleteInfobarLastShown);
42 base::Time last_shown(base::Time::FromDoubleT(time_double));
43
44 base::TimeDelta a_week(base::TimeDelta::FromDays(7));
45 if (last_shown >= time_now - a_week)
46 return;
47 }
48
49 TabContents* tab = chrome::GetActiveTabContents(browser);
50 if (!tab)
51 return;
52 tab->infobar_tab_helper()->AddInfoBar(
53 new ObsoleteOSInfoBar(
54 tab->infobar_tab_helper(),
55 LocalizedObsoleteOSString(),
56 GURL(chrome::kMacLeopardObsoleteURL)));
57
58 local_state->SetDouble(prefs::kMacLeopardObsoleteInfobarLastShown,
59 time_now.ToDoubleT());
60 }
61
62 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698