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 #include "chrome/browser/ui/startup/obsolete_os_prompt.h" | 5 #include "chrome/browser/ui/startup/obsolete_os_prompt.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/infobars/infobar_tab_helper.h" | 9 #include "chrome/browser/infobars/infobar_tab_helper.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_tabstrip.h" |
12 #include "chrome/browser/ui/cocoa/obsolete_os.h" | 13 #include "chrome/browser/ui/cocoa/obsolete_os.h" |
13 #include "chrome/browser/ui/startup/obsolete_os_info_bar.h" | 14 #include "chrome/browser/ui/startup/obsolete_os_info_bar.h" |
14 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
17 | 18 |
18 namespace browser { | 19 namespace browser { |
19 | 20 |
20 void RegisterObsoleteOSInfobarPrefs(PrefService* local_state) { | 21 void RegisterObsoleteOSInfobarPrefs(PrefService* local_state) { |
21 local_state->RegisterDoublePref( | 22 local_state->RegisterDoublePref( |
(...skipping 16 matching lines...) Expand all Loading... |
38 if (local_state->HasPrefPath(prefs::kMacLeopardObsoleteInfobarLastShown)) { | 39 if (local_state->HasPrefPath(prefs::kMacLeopardObsoleteInfobarLastShown)) { |
39 double time_double = | 40 double time_double = |
40 local_state->GetDouble(prefs::kMacLeopardObsoleteInfobarLastShown); | 41 local_state->GetDouble(prefs::kMacLeopardObsoleteInfobarLastShown); |
41 base::Time last_shown(base::Time::FromDoubleT(time_double)); | 42 base::Time last_shown(base::Time::FromDoubleT(time_double)); |
42 | 43 |
43 base::TimeDelta a_week(base::TimeDelta::FromDays(7)); | 44 base::TimeDelta a_week(base::TimeDelta::FromDays(7)); |
44 if (last_shown >= time_now - a_week) | 45 if (last_shown >= time_now - a_week) |
45 return; | 46 return; |
46 } | 47 } |
47 | 48 |
48 TabContents* tab = browser->GetActiveTabContents(); | 49 TabContents* tab = chrome::GetActiveTabContents(browser); |
49 if (!tab) | 50 if (!tab) |
50 return; | 51 return; |
51 tab->infobar_tab_helper()->AddInfoBar( | 52 tab->infobar_tab_helper()->AddInfoBar( |
52 new ObsoleteOSInfoBar( | 53 new ObsoleteOSInfoBar( |
53 tab->infobar_tab_helper(), | 54 tab->infobar_tab_helper(), |
54 LocalizedObsoleteOSString(), | 55 LocalizedObsoleteOSString(), |
55 GURL(chrome::kMacLeopardObsoleteURL))); | 56 GURL(chrome::kMacLeopardObsoleteURL))); |
56 | 57 |
57 local_state->SetDouble(prefs::kMacLeopardObsoleteInfobarLastShown, | 58 local_state->SetDouble(prefs::kMacLeopardObsoleteInfobarLastShown, |
58 time_now.ToDoubleT()); | 59 time_now.ToDoubleT()); |
59 } | 60 } |
60 | 61 |
61 } // namespace browser | 62 } // namespace browser |
OLD | NEW |