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

Side by Side Diff: chrome/browser/views/first_run_view_base.cc

Issue 4244: Make Chrome default browser an opt-out instead of an opt-in on first run. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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
« no previous file with comments | « chrome/browser/views/first_run_view_base.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/views/first_run_view_base.h" 5 #include "chrome/browser/views/first_run_view_base.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
10 #include "base/thread.h" 10 #include "base/thread.h"
11 #include "chrome/app/theme/theme_resources.h" 11 #include "chrome/app/theme/theme_resources.h"
12 #include "chrome/browser/browser_list.h" 12 #include "chrome/browser/browser_list.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/first_run.h" 14 #include "chrome/browser/first_run.h"
15 #include "chrome/browser/shell_integration.h"
16 #include "chrome/browser/user_metrics.h"
15 #include "chrome/browser/views/standard_layout.h" 17 #include "chrome/browser/views/standard_layout.h"
16 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/l10n_util.h" 19 #include "chrome/common/l10n_util.h"
18 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
19 #include "chrome/common/pref_service.h" 21 #include "chrome/common/pref_service.h"
20 #include "chrome/common/resource_bundle.h" 22 #include "chrome/common/resource_bundle.h"
21 #include "chrome/views/background.h" 23 #include "chrome/views/background.h"
24 #include "chrome/views/checkbox.h"
22 #include "chrome/views/client_view.h" 25 #include "chrome/views/client_view.h"
23 #include "chrome/views/image_view.h" 26 #include "chrome/views/image_view.h"
24 #include "chrome/views/label.h" 27 #include "chrome/views/label.h"
25 #include "chrome/views/throbber.h" 28 #include "chrome/views/throbber.h"
26 #include "chrome/views/separator.h" 29 #include "chrome/views/separator.h"
27 #include "chrome/views/window.h" 30 #include "chrome/views/window.h"
28 31
32 #include "chromium_strings.h"
29 #include "generated_resources.h" 33 #include "generated_resources.h"
30 34
31 FirstRunViewBase::FirstRunViewBase(Profile* profile) 35 FirstRunViewBase::FirstRunViewBase(Profile* profile)
32 : preferred_width_(0), 36 : preferred_width_(0),
33 background_image_(NULL), 37 background_image_(NULL),
34 separator_1_(NULL), 38 separator_1_(NULL),
39 default_browser_(NULL),
35 separator_2_(NULL), 40 separator_2_(NULL),
36 importer_host_(NULL), 41 importer_host_(NULL),
37 profile_(profile) { 42 profile_(profile) {
38 DCHECK(profile); 43 DCHECK(profile);
39 SetupControls(); 44 SetupControls();
40 } 45 }
41 46
42 FirstRunViewBase::~FirstRunViewBase() { 47 FirstRunViewBase::~FirstRunViewBase() {
43 // Register and set the "show first run information bubble" state so that the 48 // Register and set the "show first run information bubble" state so that the
44 // browser can read it later. 49 // browser can read it later.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (UILayoutIsRightToLeft()) 89 if (UILayoutIsRightToLeft())
85 background_image_->SetImage(rb.GetBitmapNamed(IDR_WIZARD_ICON_RTL)); 90 background_image_->SetImage(rb.GetBitmapNamed(IDR_WIZARD_ICON_RTL));
86 91
87 background_image_->SetBackground(bkg); 92 background_image_->SetBackground(bkg);
88 AddChildView(background_image_); 93 AddChildView(background_image_);
89 94
90 // The first separator marks the end of the image. 95 // The first separator marks the end of the image.
91 separator_1_ = new ChromeViews::Separator; 96 separator_1_ = new ChromeViews::Separator;
92 AddChildView(separator_1_); 97 AddChildView(separator_1_);
93 98
99 // The "make us default browser" check box.
100 default_browser_ = new ChromeViews::CheckBox(
101 l10n_util::GetString(IDS_FR_CUSTOMIZE_DEFAULT_BROWSER));
102 default_browser_->SetMultiLine(true);
103 AddChildView(default_browser_);
104
94 // The second separator marks the start of buttons. 105 // The second separator marks the start of buttons.
95 separator_2_ = new ChromeViews::Separator; 106 separator_2_ = new ChromeViews::Separator;
96 AddChildView(separator_2_); 107 AddChildView(separator_2_);
97 } 108 }
98 109
99 void FirstRunViewBase::AdjustDialogWidth(const ChromeViews::View* sub_view) { 110 void FirstRunViewBase::AdjustDialogWidth(const ChromeViews::View* sub_view) {
100 CRect bounds; 111 CRect bounds;
101 sub_view->GetBounds(&bounds); 112 sub_view->GetBounds(&bounds);
102 preferred_width_ = 113 preferred_width_ =
103 std::max(preferred_width_, 114 std::max(preferred_width_,
(...skipping 13 matching lines...) Expand all
117 CSize pref_size; 128 CSize pref_size;
118 background_image_->GetPreferredSize(&pref_size); 129 background_image_->GetPreferredSize(&pref_size);
119 background_image_->SetBounds(0, 0, canvas.cx, pref_size.cy); 130 background_image_->SetBounds(0, 0, canvas.cx, pref_size.cy);
120 131
121 int next_v_space = background_image_->y() + 132 int next_v_space = background_image_->y() +
122 background_image_->height() - 2; 133 background_image_->height() - 2;
123 134
124 separator_1_->GetPreferredSize(&pref_size); 135 separator_1_->GetPreferredSize(&pref_size);
125 separator_1_->SetBounds(0 , next_v_space, canvas.cx + 1, pref_size.cy); 136 separator_1_->SetBounds(0 , next_v_space, canvas.cx + 1, pref_size.cy);
126 137
127 next_v_space = canvas.cy - kPanelSubVerticalSpacing; 138 next_v_space = canvas.cy - kPanelSubVerticalSpacing - 2 * kVertSpacing;
128 separator_2_->GetPreferredSize(&pref_size); 139 separator_2_->GetPreferredSize(&pref_size);
129 separator_2_->SetBounds(kPanelHorizMargin , next_v_space, 140 separator_2_->SetBounds(kPanelHorizMargin , next_v_space,
130 canvas.cx - 2*kPanelHorizMargin, pref_size.cy); 141 canvas.cx - 2 * kPanelHorizMargin, pref_size.cy);
142
143 next_v_space = separator_2_->y() + separator_2_->height() + kVertSpacing;
144
145 int width = canvas.cx - 2 * kPanelHorizMargin;
146 int height = default_browser_->GetHeightForWidth(width);
147 default_browser_->SetBounds(kPanelHorizMargin, next_v_space, width, height);
148 AdjustDialogWidth(default_browser_);
131 } 149 }
132 150
133 bool FirstRunViewBase::CanResize() const { 151 bool FirstRunViewBase::CanResize() const {
134 return false; 152 return false;
135 } 153 }
136 154
137 bool FirstRunViewBase::CanMaximize() const { 155 bool FirstRunViewBase::CanMaximize() const {
138 return false; 156 return false;
139 } 157 }
140 158
141 bool FirstRunViewBase::IsAlwaysOnTop() const { 159 bool FirstRunViewBase::IsAlwaysOnTop() const {
142 return false; 160 return false;
143 } 161 }
144 162
145 bool FirstRunViewBase::HasAlwaysOnTopMenu() const { 163 bool FirstRunViewBase::HasAlwaysOnTopMenu() const {
146 return false; 164 return false;
147 } 165 }
148 166
167 std::wstring FirstRunViewBase::GetDialogButtonLabel(DialogButton button) const {
168 if (DIALOGBUTTON_OK == button)
169 return l10n_util::GetString(IDS_FIRSTRUN_DLG_OK);
170 // The other buttons get the default text.
171 return std::wstring();
172 }
173
149 int FirstRunViewBase::GetDefaultImportItems() const { 174 int FirstRunViewBase::GetDefaultImportItems() const {
150 // It is best to avoid importing cookies because there is a bug that make 175 // It is best to avoid importing cookies because there is a bug that make
151 // the process take way too much time among other issues. So for the time 176 // the process take way too much time among other issues. So for the time
152 // being we say: TODO(CPU): Bug 1196875 177 // being we say: TODO(CPU): Bug 1196875
153 return HISTORY | FAVORITES | PASSWORDS | SEARCH_ENGINES | HOME_PAGE; 178 return HISTORY | FAVORITES | PASSWORDS | SEARCH_ENGINES | HOME_PAGE;
154 }; 179 };
155 180
156 void FirstRunViewBase::DisableButtons() { 181 void FirstRunViewBase::DisableButtons() {
157 window()->EnableClose(false); 182 window()->EnableClose(false);
158 ChromeViews::DialogClientView* dcv = GetDialogClientView(); 183 ChromeViews::DialogClientView* dcv = GetDialogClientView();
159 dcv->ok_button()->SetEnabled(false); 184 dcv->ok_button()->SetEnabled(false);
160 dcv->cancel_button()->SetEnabled(false); 185 dcv->cancel_button()->SetEnabled(false);
186 default_browser_->SetEnabled(false);
161 } 187 }
162 188
163 bool FirstRunViewBase::CreateDesktopShortcut() { 189 bool FirstRunViewBase::CreateDesktopShortcut() {
164 return FirstRun::CreateChromeDesktopShortcut(); 190 return FirstRun::CreateChromeDesktopShortcut();
165 } 191 }
166 192
167 bool FirstRunViewBase::CreateQuickLaunchShortcut() { 193 bool FirstRunViewBase::CreateQuickLaunchShortcut() {
168 return FirstRun::CreateChromeQuickLaunchShortcut(); 194 return FirstRun::CreateChromeQuickLaunchShortcut();
169 } 195 }
170 196
197 bool FirstRunViewBase::SetDefaultBrowser() {
198 UserMetrics::RecordAction(L"FirstRun_Do_DefBrowser", profile_);
199 return ShellIntegration::SetAsDefaultBrowser();
200 }
201
171 bool FirstRunViewBase::FirstRunComplete() { 202 bool FirstRunViewBase::FirstRunComplete() {
172 return FirstRun::CreateSentinel(); 203 return FirstRun::CreateSentinel();
173 } 204 }
174
OLDNEW
« no previous file with comments | « chrome/browser/views/first_run_view_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698