| OLD | NEW |
| 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.h" | 5 #include "chrome/browser/views/first_run_view.h" |
| 6 | 6 |
| 7 #include "chrome/app/locales/locale_settings.h" | 7 #include "chrome/app/locales/locale_settings.h" |
| 8 #include "chrome/app/theme/theme_resources.h" | 8 #include "chrome/app/theme/theme_resources.h" |
| 9 #include "chrome/browser/importer/importer.h" | 9 #include "chrome/browser/importer/importer.h" |
| 10 #include "chrome/browser/first_run.h" | 10 #include "chrome/browser/first_run.h" |
| 11 #include "chrome/browser/views/first_run_customize_view.h" | 11 #include "chrome/browser/views/first_run_customize_view.h" |
| 12 #include "chrome/browser/views/standard_layout.h" | 12 #include "chrome/browser/views/standard_layout.h" |
| 13 #include "chrome/browser/user_metrics.h" | 13 #include "chrome/browser/user_metrics.h" |
| 14 #include "chrome/common/l10n_util.h" | 14 #include "chrome/common/l10n_util.h" |
| 15 #include "chrome/common/resource_bundle.h" | 15 #include "chrome/common/resource_bundle.h" |
| 16 #include "chrome/views/checkbox.h" |
| 16 #include "chrome/views/image_view.h" | 17 #include "chrome/views/image_view.h" |
| 17 #include "chrome/views/label.h" | 18 #include "chrome/views/label.h" |
| 18 #include "chrome/views/throbber.h" | 19 #include "chrome/views/throbber.h" |
| 19 #include "chrome/views/separator.h" | 20 #include "chrome/views/separator.h" |
| 20 #include "chrome/views/window.h" | 21 #include "chrome/views/window.h" |
| 21 | 22 |
| 22 #include "chromium_strings.h" | 23 #include "chromium_strings.h" |
| 23 #include "generated_resources.h" | 24 #include "generated_resources.h" |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 48 FirstRunComplete(); | 49 FirstRunComplete(); |
| 49 | 50 |
| 50 // Exit the message loop we were started with so that startup can continue. | 51 // Exit the message loop we were started with so that startup can continue. |
| 51 MessageLoop::current()->Quit(); | 52 MessageLoop::current()->Quit(); |
| 52 } | 53 } |
| 53 | 54 |
| 54 void FirstRunView::SetupControls() { | 55 void FirstRunView::SetupControls() { |
| 55 using ChromeViews::Label; | 56 using ChromeViews::Label; |
| 56 using ChromeViews::Link; | 57 using ChromeViews::Link; |
| 57 | 58 |
| 59 default_browser_->SetIsSelected(true); |
| 60 |
| 58 welcome_label_ = new Label(l10n_util::GetString(IDS_FIRSTRUN_DLG_TEXT)); | 61 welcome_label_ = new Label(l10n_util::GetString(IDS_FIRSTRUN_DLG_TEXT)); |
| 59 welcome_label_->SetMultiLine(true); | 62 welcome_label_->SetMultiLine(true); |
| 60 welcome_label_->SetHorizontalAlignment(Label::ALIGN_LEFT); | 63 welcome_label_->SetHorizontalAlignment(Label::ALIGN_LEFT); |
| 61 welcome_label_->SizeToFit(0); | 64 welcome_label_->SizeToFit(0); |
| 62 AddChildView(welcome_label_); | 65 AddChildView(welcome_label_); |
| 63 | 66 |
| 64 actions_label_ = new Label(l10n_util::GetString(IDS_FIRSTRUN_DLG_DETAIL)); | 67 actions_label_ = new Label(l10n_util::GetString(IDS_FIRSTRUN_DLG_DETAIL)); |
| 65 actions_label_->SetHorizontalAlignment(Label::ALIGN_LEFT); | 68 actions_label_->SetHorizontalAlignment(Label::ALIGN_LEFT); |
| 66 AddChildView(actions_label_); | 69 AddChildView(actions_label_); |
| 67 | 70 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 143 |
| 141 next_v_space = actions_shorcuts_->y() + | 144 next_v_space = actions_shorcuts_->y() + |
| 142 actions_shorcuts_->height() + | 145 actions_shorcuts_->height() + |
| 143 kUnrelatedControlVerticalSpacing; | 146 kUnrelatedControlVerticalSpacing; |
| 144 | 147 |
| 145 customize_link_->GetPreferredSize(&pref_size); | 148 customize_link_->GetPreferredSize(&pref_size); |
| 146 customize_link_->SetBounds(kPanelHorizMargin, next_v_space, | 149 customize_link_->SetBounds(kPanelHorizMargin, next_v_space, |
| 147 pref_size.cx, pref_size.cy); | 150 pref_size.cx, pref_size.cy); |
| 148 } | 151 } |
| 149 | 152 |
| 150 std::wstring FirstRunView::GetDialogButtonLabel(DialogButton button) const { | |
| 151 if (DIALOGBUTTON_OK == button) | |
| 152 return l10n_util::GetString(IDS_FIRSTRUN_DLG_OK); | |
| 153 // The other buttons get the default text. | |
| 154 return std::wstring(); | |
| 155 } | |
| 156 | |
| 157 void FirstRunView::OpenCustomizeDialog() { | 153 void FirstRunView::OpenCustomizeDialog() { |
| 158 // The customize dialog now owns the importer host object. | 154 // The customize dialog now owns the importer host object. |
| 159 ChromeViews::Window::CreateChromeWindow( | 155 ChromeViews::Window::CreateChromeWindow( |
| 160 window()->GetHWND(), | 156 window()->GetHWND(), |
| 161 gfx::Rect(), | 157 gfx::Rect(), |
| 162 new FirstRunCustomizeView(profile_, importer_host_, this))->Show(); | 158 new FirstRunCustomizeView(profile_, |
| 159 importer_host_, |
| 160 this, |
| 161 default_browser_->IsSelected()))->Show(); |
| 163 } | 162 } |
| 164 | 163 |
| 165 void FirstRunView::LinkActivated(ChromeViews::Link* source, int event_flags) { | 164 void FirstRunView::LinkActivated(ChromeViews::Link* source, int event_flags) { |
| 166 OpenCustomizeDialog(); | 165 OpenCustomizeDialog(); |
| 167 } | 166 } |
| 168 | 167 |
| 169 std::wstring FirstRunView::GetWindowTitle() const { | 168 std::wstring FirstRunView::GetWindowTitle() const { |
| 170 return l10n_util::GetString(IDS_FIRSTRUN_DLG_TITLE); | 169 return l10n_util::GetString(IDS_FIRSTRUN_DLG_TITLE); |
| 171 } | 170 } |
| 172 | 171 |
| 173 ChromeViews::View* FirstRunView::GetContentsView() { | 172 ChromeViews::View* FirstRunView::GetContentsView() { |
| 174 return this; | 173 return this; |
| 175 } | 174 } |
| 176 | 175 |
| 177 bool FirstRunView::Accept() { | 176 bool FirstRunView::Accept() { |
| 178 if (!IsDialogButtonEnabled(DIALOGBUTTON_OK)) | 177 if (!IsDialogButtonEnabled(DIALOGBUTTON_OK)) |
| 179 return false; | 178 return false; |
| 180 | 179 |
| 181 DisableButtons(); | 180 DisableButtons(); |
| 182 customize_link_->SetEnabled(false); | 181 customize_link_->SetEnabled(false); |
| 183 CreateDesktopShortcut(); | 182 CreateDesktopShortcut(); |
| 184 CreateQuickLaunchShortcut(); | 183 CreateQuickLaunchShortcut(); |
| 184 if (default_browser_->IsSelected()) |
| 185 SetDefaultBrowser(); |
| 185 // Index 0 is the default browser. | 186 // Index 0 is the default browser. |
| 186 FirstRun::ImportSettings(profile_, 0, GetDefaultImportItems(), | 187 FirstRun::ImportSettings(profile_, 0, GetDefaultImportItems(), |
| 187 window()->GetHWND()); | 188 window()->GetHWND()); |
| 188 UserMetrics::RecordAction(L"FirstRunDef_Accept", profile_); | 189 UserMetrics::RecordAction(L"FirstRunDef_Accept", profile_); |
| 189 | 190 |
| 190 return true; | 191 return true; |
| 191 } | 192 } |
| 192 | 193 |
| 193 bool FirstRunView::Cancel() { | 194 bool FirstRunView::Cancel() { |
| 194 UserMetrics::RecordAction(L"FirstRunDef_Cancel", profile_); | 195 UserMetrics::RecordAction(L"FirstRunDef_Cancel", profile_); |
| 195 return true; | 196 return true; |
| 196 } | 197 } |
| 197 | 198 |
| 198 // Notification from the customize dialog that the user accepted. Since all | 199 // Notification from the customize dialog that the user accepted. Since all |
| 199 // the work is done there we got nothing else to do. | 200 // the work is done there we got nothing else to do. |
| 200 void FirstRunView::CustomizeAccepted() { | 201 void FirstRunView::CustomizeAccepted() { |
| 201 window()->Close(); | 202 window()->Close(); |
| 202 } | 203 } |
| 203 | 204 |
| 204 // Notification from the customize dialog that the user cancelled. | 205 // Notification from the customize dialog that the user cancelled. |
| 205 void FirstRunView::CustomizeCanceled() { | 206 void FirstRunView::CustomizeCanceled() { |
| 206 UserMetrics::RecordAction(L"FirstRunCustom_Cancel", profile_); | 207 UserMetrics::RecordAction(L"FirstRunCustom_Cancel", profile_); |
| 207 } | 208 } |
| 208 | 209 |
| OLD | NEW |