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

Side by Side Diff: trunk/src/chrome/browser/ui/startup/default_browser_prompt.cc

Issue 102163002: Revert 238283 "Infobar system refactor." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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
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"
17 #include "chrome/browser/infobars/infobar_service.h" 16 #include "chrome/browser/infobars/infobar_service.h"
18 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/shell_integration.h" 18 #include "chrome/browser/shell_integration.h"
20 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_finder.h" 20 #include "chrome/browser/ui/browser_finder.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
23 #include "chrome/common/chrome_version_info.h" 22 #include "chrome/common/chrome_version_info.h"
24 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
25 #include "chrome/installer/util/master_preferences.h" 24 #include "chrome/installer/util/master_preferences.h"
26 #include "chrome/installer/util/master_preferences_constants.h" 25 #include "chrome/installer/util/master_preferences_constants.h"
(...skipping 25 matching lines...) Expand all
52 } 51 }
53 } else { 52 } else {
54 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefault", 1); 53 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefault", 1);
55 ShellIntegration::SetAsDefaultBrowser(); 54 ShellIntegration::SetAsDefaultBrowser();
56 } 55 }
57 } 56 }
58 57
59 // The delegate for the infobar shown when Chrome is not the default browser. 58 // The delegate for the infobar shown when Chrome is not the default browser.
60 class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { 59 class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
61 public: 60 public:
62 // Creates a default browser infobar and delegate and adds the infobar to 61 // Creates a default browser infobar delegate and adds it to
63 // |infobar_service|. 62 // |infobar_service|.
64 static void Create(InfoBarService* infobar_service, 63 static void Create(InfoBarService* infobar_service,
65 PrefService* prefs, 64 PrefService* prefs,
66 bool interactive_flow_required); 65 bool interactive_flow_required);
67 66
68 private: 67 private:
69 DefaultBrowserInfoBarDelegate(PrefService* prefs, 68 DefaultBrowserInfoBarDelegate(InfoBarService* infobar_service,
69 PrefService* prefs,
70 bool interactive_flow_required); 70 bool interactive_flow_required);
71 virtual ~DefaultBrowserInfoBarDelegate(); 71 virtual ~DefaultBrowserInfoBarDelegate();
72 72
73 void AllowExpiry() { should_expire_ = true; } 73 void AllowExpiry() { should_expire_ = true; }
74 74
75 // ConfirmInfoBarDelegate: 75 // ConfirmInfoBarDelegate:
76 virtual int GetIconID() const OVERRIDE; 76 virtual int GetIconID() const OVERRIDE;
77 virtual string16 GetMessageText() const OVERRIDE; 77 virtual string16 GetMessageText() const OVERRIDE;
78 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 78 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
79 virtual bool NeedElevation(InfoBarButton button) const OVERRIDE; 79 virtual bool NeedElevation(InfoBarButton button) const OVERRIDE;
(...skipping 18 matching lines...) Expand all
98 // Used to delay the expiration of the info-bar. 98 // Used to delay the expiration of the info-bar.
99 base::WeakPtrFactory<DefaultBrowserInfoBarDelegate> weak_factory_; 99 base::WeakPtrFactory<DefaultBrowserInfoBarDelegate> weak_factory_;
100 100
101 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserInfoBarDelegate); 101 DISALLOW_COPY_AND_ASSIGN(DefaultBrowserInfoBarDelegate);
102 }; 102 };
103 103
104 // static 104 // static
105 void DefaultBrowserInfoBarDelegate::Create(InfoBarService* infobar_service, 105 void DefaultBrowserInfoBarDelegate::Create(InfoBarService* infobar_service,
106 PrefService* prefs, 106 PrefService* prefs,
107 bool interactive_flow_required) { 107 bool interactive_flow_required) {
108 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( 108 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
109 scoped_ptr<ConfirmInfoBarDelegate>(new DefaultBrowserInfoBarDelegate( 109 new DefaultBrowserInfoBarDelegate(infobar_service, prefs,
110 prefs, interactive_flow_required)))); 110 interactive_flow_required)));
111 } 111 }
112 112
113 DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate( 113 DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate(
114 InfoBarService* infobar_service,
114 PrefService* prefs, 115 PrefService* prefs,
115 bool interactive_flow_required) 116 bool interactive_flow_required)
116 : ConfirmInfoBarDelegate(), 117 : ConfirmInfoBarDelegate(infobar_service),
117 prefs_(prefs), 118 prefs_(prefs),
118 action_taken_(false), 119 action_taken_(false),
119 should_expire_(false), 120 should_expire_(false),
120 interactive_flow_required_(interactive_flow_required), 121 interactive_flow_required_(interactive_flow_required),
121 weak_factory_(this) { 122 weak_factory_(this) {
122 // We want the info-bar to stick-around for few seconds and then be hidden 123 // We want the info-bar to stick-around for few seconds and then be hidden
123 // on the next navigation after that. 124 // on the next navigation after that.
124 base::MessageLoop::current()->PostDelayedTask( 125 base::MessageLoop::current()->PostDelayedTask(
125 FROM_HERE, 126 FROM_HERE,
126 base::Bind(&DefaultBrowserInfoBarDelegate::AllowExpiry, 127 base::Bind(&DefaultBrowserInfoBarDelegate::AllowExpiry,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698