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

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

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
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"
16 #include "chrome/browser/infobars/infobar_service.h" 17 #include "chrome/browser/infobars/infobar_service.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/shell_integration.h" 19 #include "chrome/browser/shell_integration.h"
19 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_finder.h" 21 #include "chrome/browser/ui/browser_finder.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 22 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/common/chrome_version_info.h" 23 #include "chrome/common/chrome_version_info.h"
23 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
24 #include "chrome/installer/util/master_preferences.h" 25 #include "chrome/installer/util/master_preferences.h"
25 #include "chrome/installer/util/master_preferences_constants.h" 26 #include "chrome/installer/util/master_preferences_constants.h"
(...skipping 25 matching lines...) Expand all
51 } 52 }
52 } else { 53 } else {
53 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefault", 1); 54 UMA_HISTOGRAM_COUNTS("DefaultBrowserWarning.SetAsDefault", 1);
54 ShellIntegration::SetAsDefaultBrowser(); 55 ShellIntegration::SetAsDefaultBrowser();
55 } 56 }
56 } 57 }
57 58
58 // The delegate for the infobar shown when Chrome is not the default browser. 59 // The delegate for the infobar shown when Chrome is not the default browser.
59 class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { 60 class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
60 public: 61 public:
61 // Creates a default browser infobar delegate and adds it to 62 // Creates a default browser infobar and delegate and adds the infobar to
62 // |infobar_service|. 63 // |infobar_service|.
63 static void Create(InfoBarService* infobar_service, 64 static void Create(InfoBarService* infobar_service,
64 PrefService* prefs, 65 PrefService* prefs,
65 bool interactive_flow_required); 66 bool interactive_flow_required);
66 67
67 private: 68 private:
68 DefaultBrowserInfoBarDelegate(InfoBarService* infobar_service, 69 DefaultBrowserInfoBarDelegate(PrefService* prefs,
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(scoped_ptr<InfoBarDelegate>( 108 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
109 new DefaultBrowserInfoBarDelegate(infobar_service, prefs, 109 scoped_ptr<ConfirmInfoBarDelegate>(new DefaultBrowserInfoBarDelegate(
110 interactive_flow_required))); 110 prefs, interactive_flow_required))));
111 } 111 }
112 112
113 DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate( 113 DefaultBrowserInfoBarDelegate::DefaultBrowserInfoBarDelegate(
114 InfoBarService* infobar_service,
115 PrefService* prefs, 114 PrefService* prefs,
116 bool interactive_flow_required) 115 bool interactive_flow_required)
117 : ConfirmInfoBarDelegate(infobar_service), 116 : ConfirmInfoBarDelegate(),
118 prefs_(prefs), 117 prefs_(prefs),
119 action_taken_(false), 118 action_taken_(false),
120 should_expire_(false), 119 should_expire_(false),
121 interactive_flow_required_(interactive_flow_required), 120 interactive_flow_required_(interactive_flow_required),
122 weak_factory_(this) { 121 weak_factory_(this) {
123 // We want the info-bar to stick-around for few seconds and then be hidden 122 // We want the info-bar to stick-around for few seconds and then be hidden
124 // on the next navigation after that. 123 // on the next navigation after that.
125 base::MessageLoop::current()->PostDelayedTask( 124 base::MessageLoop::current()->PostDelayedTask(
126 FROM_HERE, 125 FROM_HERE,
127 base::Bind(&DefaultBrowserInfoBarDelegate::AllowExpiry, 126 base::Bind(&DefaultBrowserInfoBarDelegate::AllowExpiry,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 258
260 } 259 }
261 260
262 #if !defined(OS_WIN) 261 #if !defined(OS_WIN)
263 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { 262 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) {
264 return false; 263 return false;
265 } 264 }
266 #endif 265 #endif
267 266
268 } // namespace chrome 267 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/startup/autolaunch_prompt_win.cc ('k') | chrome/browser/ui/startup/google_api_keys_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698