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/default_browser_prompt.h" | 5 #include "chrome/browser/ui/startup/default_browser_prompt.h" |
6 | 6 |
7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/version.h" | 12 #include "base/version.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/first_run/first_run.h" | 14 #include "chrome/browser/first_run/first_run.h" |
15 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 15 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
16 #include "chrome/browser/infobars/infobar.h" | 16 #include "chrome/browser/infobars/infobar.h" |
| 17 #include "chrome/browser/infobars/infobar_manager.h" |
17 #include "chrome/browser/infobars/infobar_service.h" | 18 #include "chrome/browser/infobars/infobar_service.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/shell_integration.h" | 20 #include "chrome/browser/shell_integration.h" |
20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_finder.h" | 22 #include "chrome/browser/ui/browser_finder.h" |
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
23 #include "chrome/common/chrome_version_info.h" | 24 #include "chrome/common/chrome_version_info.h" |
24 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
25 #include "chrome/installer/util/master_preferences.h" | 26 #include "chrome/installer/util/master_preferences.h" |
26 #include "chrome/installer/util/master_preferences_constants.h" | 27 #include "chrome/installer/util/master_preferences_constants.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 73 |
73 void AllowExpiry() { should_expire_ = true; } | 74 void AllowExpiry() { should_expire_ = true; } |
74 | 75 |
75 // ConfirmInfoBarDelegate: | 76 // ConfirmInfoBarDelegate: |
76 virtual int GetIconID() const OVERRIDE; | 77 virtual int GetIconID() const OVERRIDE; |
77 virtual base::string16 GetMessageText() const OVERRIDE; | 78 virtual base::string16 GetMessageText() const OVERRIDE; |
78 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 79 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
79 virtual bool NeedElevation(InfoBarButton button) const OVERRIDE; | 80 virtual bool NeedElevation(InfoBarButton button) const OVERRIDE; |
80 virtual bool Accept() OVERRIDE; | 81 virtual bool Accept() OVERRIDE; |
81 virtual bool Cancel() OVERRIDE; | 82 virtual bool Cancel() OVERRIDE; |
82 virtual bool ShouldExpireInternal( | 83 virtual bool ShouldExpireInternal(const NavigationDetails& details) const |
83 const content::LoadCommittedDetails& details) const OVERRIDE; | 84 OVERRIDE; |
84 | 85 |
85 // The prefs to use. | 86 // The prefs to use. |
86 PrefService* prefs_; | 87 PrefService* prefs_; |
87 | 88 |
88 // Whether the user clicked one of the buttons. | 89 // Whether the user clicked one of the buttons. |
89 bool action_taken_; | 90 bool action_taken_; |
90 | 91 |
91 // Whether the info-bar should be dismissed on the next navigation. | 92 // Whether the info-bar should be dismissed on the next navigation. |
92 bool should_expire_; | 93 bool should_expire_; |
93 | 94 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 165 |
165 bool DefaultBrowserInfoBarDelegate::Cancel() { | 166 bool DefaultBrowserInfoBarDelegate::Cancel() { |
166 action_taken_ = true; | 167 action_taken_ = true; |
167 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.DontSetAsDefault", 1); | 168 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.DontSetAsDefault", 1); |
168 // User clicked "Don't ask me again", remember that. | 169 // User clicked "Don't ask me again", remember that. |
169 prefs_->SetBoolean(prefs::kCheckDefaultBrowser, false); | 170 prefs_->SetBoolean(prefs::kCheckDefaultBrowser, false); |
170 return true; | 171 return true; |
171 } | 172 } |
172 | 173 |
173 bool DefaultBrowserInfoBarDelegate::ShouldExpireInternal( | 174 bool DefaultBrowserInfoBarDelegate::ShouldExpireInternal( |
174 const content::LoadCommittedDetails& details) const { | 175 const NavigationDetails& details) const { |
175 return should_expire_; | 176 return should_expire_; |
176 } | 177 } |
177 | 178 |
178 void NotifyNotDefaultBrowserCallback(chrome::HostDesktopType desktop_type) { | 179 void NotifyNotDefaultBrowserCallback(chrome::HostDesktopType desktop_type) { |
179 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); | 180 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); |
180 if (!browser) | 181 if (!browser) |
181 return; // Reached during ui tests. | 182 return; // Reached during ui tests. |
182 | 183 |
183 // In ChromeBot tests, there might be a race. This line appears to get | 184 // In ChromeBot tests, there might be a race. This line appears to get |
184 // called during shutdown and |tab| can be NULL. | 185 // called during shutdown and |tab| can be NULL. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 259 |
259 } | 260 } |
260 | 261 |
261 #if !defined(OS_WIN) | 262 #if !defined(OS_WIN) |
262 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { | 263 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { |
263 return false; | 264 return false; |
264 } | 265 } |
265 #endif | 266 #endif |
266 | 267 |
267 } // namespace chrome | 268 } // namespace chrome |
OLD | NEW |