| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/login/eula_view.h" | 5 #include "chrome/browser/chromeos/login/eula_view.h" |
| 6 | 6 |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
| 12 #include "app/resource_bundle.h" | 12 #include "app/resource_bundle.h" |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chromeos/customization_document.h" | 16 #include "chrome/browser/chromeos/customization_document.h" |
| 17 #include "chrome/browser/chromeos/login/network_screen_delegate.h" | 17 #include "chrome/browser/chromeos/login/network_screen_delegate.h" |
| 18 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 18 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
| 19 #include "chrome/browser/chromeos/login/wizard_controller.h" | 19 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 20 #include "chrome/browser/options_util.h" | 20 #include "chrome/browser/options_util.h" |
| 21 #include "chrome/browser/prefs/pref_service.h" | |
| 22 #include "chrome/browser/profile_manager.h" | 21 #include "chrome/browser/profile_manager.h" |
| 23 #include "chrome/browser/renderer_host/site_instance.h" | 22 #include "chrome/browser/renderer_host/site_instance.h" |
| 24 #include "chrome/browser/tab_contents/tab_contents.h" | 23 #include "chrome/browser/tab_contents/tab_contents.h" |
| 25 #include "chrome/browser/views/dom_view.h" | 24 #include "chrome/browser/views/dom_view.h" |
| 26 #include "chrome/common/native_web_keyboard_event.h" | 25 #include "chrome/common/native_web_keyboard_event.h" |
| 27 #include "chrome/common/pref_names.h" | |
| 28 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 29 #include "chrome/installer/util/google_update_settings.h" | 27 #include "chrome/installer/util/google_update_settings.h" |
| 30 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
| 31 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 32 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
| 33 #include "views/controls/button/checkbox.h" | 31 #include "views/controls/button/checkbox.h" |
| 34 #include "views/controls/button/native_button.h" | 32 #include "views/controls/button/native_button.h" |
| 35 #include "views/controls/label.h" | 33 #include "views/controls/label.h" |
| 36 #include "views/grid_layout.h" | 34 #include "views/grid_layout.h" |
| 37 #include "views/layout_manager.h" | 35 #include "views/layout_manager.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } else { | 145 } else { |
| 148 LOG(INFO) << "No eula found for locale: " << locale; | 146 LOG(INFO) << "No eula found for locale: " << locale; |
| 149 } | 147 } |
| 150 } else { | 148 } else { |
| 151 LOG(ERROR) << "No manifest found."; | 149 LOG(ERROR) << "No manifest found."; |
| 152 } | 150 } |
| 153 return GURL(); | 151 return GURL(); |
| 154 } | 152 } |
| 155 | 153 |
| 156 void EulaView::Init() { | 154 void EulaView::Init() { |
| 157 // Handle preference that enables crash/statistics reporting. We do | |
| 158 // not monitor its change in background since we are in OOBE wizard. | |
| 159 metrics_reporting_enabled_.Init(prefs::kMetricsReportingEnabled, | |
| 160 g_browser_process->local_state(), NULL); | |
| 161 | |
| 162 // Use rounded rect background. | 155 // Use rounded rect background. |
| 163 views::Painter* painter = CreateWizardPainter( | 156 views::Painter* painter = CreateWizardPainter( |
| 164 &BorderDefinition::kScreenBorder); | 157 &BorderDefinition::kScreenBorder); |
| 165 set_background( | 158 set_background( |
| 166 views::Background::CreateBackgroundPainter(true, painter)); | 159 views::Background::CreateBackgroundPainter(true, painter)); |
| 167 | 160 |
| 168 // Layout created controls. | 161 // Layout created controls. |
| 169 views::GridLayout* layout = new views::GridLayout(this); | 162 views::GridLayout* layout = new views::GridLayout(this); |
| 170 SetLayoutManager(layout); | 163 SetLayoutManager(layout); |
| 171 SetUpGridLayout(layout); | 164 SetUpGridLayout(layout); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 187 box_view->SetLayoutManager(new FillLayoutWithBorder()); | 180 box_view->SetLayoutManager(new FillLayoutWithBorder()); |
| 188 layout->AddView(box_view); | 181 layout->AddView(box_view); |
| 189 | 182 |
| 190 google_eula_view_ = new DOMView(); | 183 google_eula_view_ = new DOMView(); |
| 191 box_view->AddChildView(google_eula_view_); | 184 box_view->AddChildView(google_eula_view_); |
| 192 | 185 |
| 193 layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing); | 186 layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing); |
| 194 layout->StartRow(0, SINGLE_CONTROL_WITH_SHIFT_ROW); | 187 layout->StartRow(0, SINGLE_CONTROL_WITH_SHIFT_ROW); |
| 195 usage_statistics_checkbox_ = new views::Checkbox(); | 188 usage_statistics_checkbox_ = new views::Checkbox(); |
| 196 usage_statistics_checkbox_->SetMultiLine(true); | 189 usage_statistics_checkbox_->SetMultiLine(true); |
| 197 usage_statistics_checkbox_->SetChecked( | 190 |
| 198 metrics_reporting_enabled_.GetValue()); | 191 // TODO(zelidrag): http://crosbug/6367 - Change default settings for checked |
| 192 // and enabled state of usage_statistics_checkbox_ before the product is |
| 193 // released. |
| 194 usage_statistics_checkbox_->SetChecked(true); |
| 199 layout->AddView(usage_statistics_checkbox_); | 195 layout->AddView(usage_statistics_checkbox_); |
| 200 usage_statistics_checkbox_->SetEnabled( | 196 usage_statistics_checkbox_->SetEnabled(false); |
| 201 metrics_reporting_enabled_.IsManaged()); | |
| 202 | 197 |
| 203 layout->StartRow(0, SINGLE_LINK_WITH_SHIFT_ROW); | 198 layout->StartRow(0, SINGLE_LINK_WITH_SHIFT_ROW); |
| 204 learn_more_link_ = new views::Link(); | 199 learn_more_link_ = new views::Link(); |
| 205 learn_more_link_->SetController(this); | 200 learn_more_link_->SetController(this); |
| 206 layout->AddView(learn_more_link_); | 201 layout->AddView(learn_more_link_); |
| 207 | 202 |
| 208 layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing); | 203 layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing); |
| 209 layout->StartRow(0, SINGLE_CONTROL_ROW); | 204 layout->StartRow(0, SINGLE_CONTROL_ROW); |
| 210 oem_eula_label_ = new views::Label(std::wstring(), label_font); | 205 oem_eula_label_ = new views::Label(std::wstring(), label_font); |
| 211 layout->AddView(oem_eula_label_, 1, 1, | 206 layout->AddView(oem_eula_label_, 1, 1, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 Layout(); | 281 Layout(); |
| 287 } | 282 } |
| 288 | 283 |
| 289 //////////////////////////////////////////////////////////////////////////////// | 284 //////////////////////////////////////////////////////////////////////////////// |
| 290 // views::ButtonListener implementation: | 285 // views::ButtonListener implementation: |
| 291 | 286 |
| 292 void EulaView::ButtonPressed(views::Button* sender, const views::Event& event) { | 287 void EulaView::ButtonPressed(views::Button* sender, const views::Event& event) { |
| 293 if (sender == continue_button_) { | 288 if (sender == continue_button_) { |
| 294 if (usage_statistics_checkbox_) { | 289 if (usage_statistics_checkbox_) { |
| 295 bool enable_reporting = usage_statistics_checkbox_->checked(); | 290 bool enable_reporting = usage_statistics_checkbox_->checked(); |
| 296 if (metrics_reporting_enabled_.GetValue() != enable_reporting) { | 291 enable_reporting = |
| 297 enable_reporting = | 292 OptionsUtil::ResolveMetricsReportingEnabled(enable_reporting); |
| 298 OptionsUtil::ResolveMetricsReportingEnabled(enable_reporting); | |
| 299 metrics_reporting_enabled_.SetValueIfNotManaged(enable_reporting); | |
| 300 #if defined(USE_LINUX_BREAKPAD) | 293 #if defined(USE_LINUX_BREAKPAD) |
| 301 if (enable_reporting) | 294 if (enable_reporting) |
| 302 InitCrashReporter(); | 295 InitCrashReporter(); |
| 303 #endif | 296 #endif |
| 304 } | |
| 305 } | 297 } |
| 306 observer_->OnExit(ScreenObserver::EULA_ACCEPTED); | 298 observer_->OnExit(ScreenObserver::EULA_ACCEPTED); |
| 307 } | 299 } |
| 308 // TODO(glotov): handle cancel button. | 300 // TODO(glotov): handle cancel button. |
| 309 } | 301 } |
| 310 | 302 |
| 311 //////////////////////////////////////////////////////////////////////////////// | 303 //////////////////////////////////////////////////////////////////////////////// |
| 312 // views::LinkController implementation: | 304 // views::LinkController implementation: |
| 313 | 305 |
| 314 void EulaView::LinkActivated(views::Link* source, int event_flags) { | 306 void EulaView::LinkActivated(views::Link* source, int event_flags) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 340 } | 332 } |
| 341 } | 333 } |
| 342 | 334 |
| 343 void EulaView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 335 void EulaView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
| 344 views::Widget* widget = GetWidget(); | 336 views::Widget* widget = GetWidget(); |
| 345 if (widget && event.os_event && !event.skip_in_browser) | 337 if (widget && event.os_event && !event.skip_in_browser) |
| 346 static_cast<views::WidgetGtk*>(widget)->HandleKeyboardEvent(event.os_event); | 338 static_cast<views::WidgetGtk*>(widget)->HandleKeyboardEvent(event.os_event); |
| 347 } | 339 } |
| 348 | 340 |
| 349 } // namespace chromeos | 341 } // namespace chromeos |
| OLD | NEW |