| OLD | NEW |
| 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/views/sync/one_click_signin_bubble_view.h" | 5 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | |
| 11 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| 12 #include "chrome/grit/chromium_strings.h" | 11 #include "chrome/grit/chromium_strings.h" |
| 13 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
| 14 #include "components/google/core/browser/google_util.h" | 13 #include "components/google/core/browser/google_util.h" |
| 15 #include "grit/components_strings.h" | 14 #include "grit/components_strings.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/events/keycodes/keyboard_codes.h" | 17 #include "ui/events/keycodes/keyboard_codes.h" |
| 19 #include "ui/resources/grit/ui_resources.h" | 18 #include "ui/resources/grit/ui_resources.h" |
| 20 #include "ui/views/controls/button/image_button.h" | 19 #include "ui/views/controls/button/image_button.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 200 |
| 202 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | 201 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); |
| 203 | 202 |
| 204 layout->StartRow(0, COLUMN_SET_CONTROLS); | 203 layout->StartRow(0, COLUMN_SET_CONTROLS); |
| 205 | 204 |
| 206 InitLearnMoreLink(); | 205 InitLearnMoreLink(); |
| 207 layout->AddView(learn_more_link_); | 206 layout->AddView(learn_more_link_); |
| 208 } | 207 } |
| 209 | 208 |
| 210 void OneClickSigninBubbleView::InitDialogContent(views::GridLayout* layout) { | 209 void OneClickSigninBubbleView::InitDialogContent(views::GridLayout* layout) { |
| 211 OneClickSigninHelper::LogConfirmHistogramValue( | 210 signin_metrics::LogSigninConfirmHistogramValue( |
| 212 signin_metrics::HISTOGRAM_CONFIRM_SHOWN); | 211 signin_metrics::HISTOGRAM_CONFIRM_SHOWN); |
| 213 | 212 |
| 214 // Column set for title bar. | 213 // Column set for title bar. |
| 215 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_TITLE_BAR); | 214 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_TITLE_BAR); |
| 216 cs->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0, | 215 cs->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0, |
| 217 views::GridLayout::USE_PREF, 0, 0); | 216 views::GridLayout::USE_PREF, 0, 0); |
| 218 cs->AddPaddingColumn(1, views::kUnrelatedControlHorizontalSpacing); | 217 cs->AddPaddingColumn(1, views::kUnrelatedControlHorizontalSpacing); |
| 219 cs->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, 0, | 218 cs->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, 0, |
| 220 views::GridLayout::USE_PREF, 0, 0); | 219 views::GridLayout::USE_PREF, 0, 0); |
| 221 | 220 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 } | 311 } |
| 313 | 312 |
| 314 bool OneClickSigninBubbleView::AcceleratorPressed( | 313 bool OneClickSigninBubbleView::AcceleratorPressed( |
| 315 const ui::Accelerator& accelerator) { | 314 const ui::Accelerator& accelerator) { |
| 316 if (accelerator.key_code() == ui::VKEY_RETURN || | 315 if (accelerator.key_code() == ui::VKEY_RETURN || |
| 317 accelerator.key_code() == ui::VKEY_ESCAPE) { | 316 accelerator.key_code() == ui::VKEY_ESCAPE) { |
| 318 OneClickSigninBubbleView::Hide(); | 317 OneClickSigninBubbleView::Hide(); |
| 319 | 318 |
| 320 if (is_sync_dialog_) { | 319 if (is_sync_dialog_) { |
| 321 if (accelerator.key_code() == ui::VKEY_RETURN) { | 320 if (accelerator.key_code() == ui::VKEY_RETURN) { |
| 322 OneClickSigninHelper::LogConfirmHistogramValue( | 321 signin_metrics::LogSigninConfirmHistogramValue( |
| 323 clicked_learn_more_ ? | 322 clicked_learn_more_ ? |
| 324 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_RETURN : | 323 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_RETURN : |
| 325 signin_metrics::HISTOGRAM_CONFIRM_RETURN); | 324 signin_metrics::HISTOGRAM_CONFIRM_RETURN); |
| 326 | 325 |
| 327 base::ResetAndReturn(&start_sync_callback_).Run( | 326 base::ResetAndReturn(&start_sync_callback_).Run( |
| 328 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); | 327 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); |
| 329 } else if (accelerator.key_code() == ui::VKEY_ESCAPE) { | 328 } else if (accelerator.key_code() == ui::VKEY_ESCAPE) { |
| 330 OneClickSigninHelper::LogConfirmHistogramValue( | 329 signin_metrics::LogSigninConfirmHistogramValue( |
| 331 clicked_learn_more_ ? | 330 clicked_learn_more_ ? |
| 332 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_ESCAPE : | 331 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_ESCAPE : |
| 333 signin_metrics::HISTOGRAM_CONFIRM_ESCAPE); | 332 signin_metrics::HISTOGRAM_CONFIRM_ESCAPE); |
| 334 | 333 |
| 335 base::ResetAndReturn(&start_sync_callback_).Run( | 334 base::ResetAndReturn(&start_sync_callback_).Run( |
| 336 OneClickSigninSyncStarter::UNDO_SYNC); | 335 OneClickSigninSyncStarter::UNDO_SYNC); |
| 337 } | 336 } |
| 338 } | 337 } |
| 339 | 338 |
| 340 return true; | 339 return true; |
| 341 } | 340 } |
| 342 | 341 |
| 343 return BubbleDelegateView::AcceleratorPressed(accelerator); | 342 return BubbleDelegateView::AcceleratorPressed(accelerator); |
| 344 } | 343 } |
| 345 | 344 |
| 346 void OneClickSigninBubbleView::LinkClicked(views::Link* source, | 345 void OneClickSigninBubbleView::LinkClicked(views::Link* source, |
| 347 int event_flags) { | 346 int event_flags) { |
| 348 if (source == learn_more_link_) { | 347 if (source == learn_more_link_) { |
| 349 if (is_sync_dialog_ && !clicked_learn_more_) { | 348 if (is_sync_dialog_ && !clicked_learn_more_) { |
| 350 OneClickSigninHelper::LogConfirmHistogramValue( | 349 signin_metrics::LogSigninConfirmHistogramValue( |
| 351 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE); | 350 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE); |
| 352 clicked_learn_more_ = true; | 351 clicked_learn_more_ = true; |
| 353 } | 352 } |
| 354 delegate_->OnLearnMoreLinkClicked(is_sync_dialog_); | 353 delegate_->OnLearnMoreLinkClicked(is_sync_dialog_); |
| 355 | 354 |
| 356 // don't hide the modal dialog, as this is an informational link | 355 // don't hide the modal dialog, as this is an informational link |
| 357 if (is_sync_dialog_) | 356 if (is_sync_dialog_) |
| 358 return; | 357 return; |
| 359 } else if (advanced_link_ && source == advanced_link_) { | 358 } else if (advanced_link_ && source == advanced_link_) { |
| 360 if (is_sync_dialog_) { | 359 if (is_sync_dialog_) { |
| 361 OneClickSigninHelper::LogConfirmHistogramValue( | 360 signin_metrics::LogSigninConfirmHistogramValue( |
| 362 clicked_learn_more_ ? | 361 clicked_learn_more_ ? |
| 363 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_ADVANCED : | 362 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_ADVANCED : |
| 364 signin_metrics::HISTOGRAM_CONFIRM_ADVANCED); | 363 signin_metrics::HISTOGRAM_CONFIRM_ADVANCED); |
| 365 | 364 |
| 366 base::ResetAndReturn(&start_sync_callback_).Run( | 365 base::ResetAndReturn(&start_sync_callback_).Run( |
| 367 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 366 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
| 368 } else { | 367 } else { |
| 369 delegate_->OnAdvancedLinkClicked(); | 368 delegate_->OnAdvancedLinkClicked(); |
| 370 } | 369 } |
| 371 } | 370 } |
| 372 | 371 |
| 373 Hide(); | 372 Hide(); |
| 374 } | 373 } |
| 375 | 374 |
| 376 void OneClickSigninBubbleView::ButtonPressed(views::Button* sender, | 375 void OneClickSigninBubbleView::ButtonPressed(views::Button* sender, |
| 377 const ui::Event& event) { | 376 const ui::Event& event) { |
| 378 Hide(); | 377 Hide(); |
| 379 | 378 |
| 380 if (is_sync_dialog_) { | 379 if (is_sync_dialog_) { |
| 381 if (sender == ok_button_) | 380 if (sender == ok_button_) |
| 382 OneClickSigninHelper::LogConfirmHistogramValue( | 381 signin_metrics::LogSigninConfirmHistogramValue( |
| 383 clicked_learn_more_ ? | 382 clicked_learn_more_ ? |
| 384 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_OK : | 383 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_OK : |
| 385 signin_metrics::HISTOGRAM_CONFIRM_OK); | 384 signin_metrics::HISTOGRAM_CONFIRM_OK); |
| 386 | 385 |
| 387 if (sender == undo_button_) | 386 if (sender == undo_button_) |
| 388 OneClickSigninHelper::LogConfirmHistogramValue( | 387 signin_metrics::LogSigninConfirmHistogramValue( |
| 389 clicked_learn_more_ ? | 388 clicked_learn_more_ ? |
| 390 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_UNDO : | 389 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_UNDO : |
| 391 signin_metrics::HISTOGRAM_CONFIRM_UNDO); | 390 signin_metrics::HISTOGRAM_CONFIRM_UNDO); |
| 392 | 391 |
| 393 if (sender == close_button_) | 392 if (sender == close_button_) |
| 394 OneClickSigninHelper::LogConfirmHistogramValue( | 393 signin_metrics::LogSigninConfirmHistogramValue( |
| 395 clicked_learn_more_ ? | 394 clicked_learn_more_ ? |
| 396 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_CLOSE : | 395 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_CLOSE : |
| 397 signin_metrics::HISTOGRAM_CONFIRM_CLOSE); | 396 signin_metrics::HISTOGRAM_CONFIRM_CLOSE); |
| 398 | 397 |
| 399 base::ResetAndReturn(&start_sync_callback_).Run((sender == ok_button_) ? | 398 base::ResetAndReturn(&start_sync_callback_).Run((sender == ok_button_) ? |
| 400 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS : | 399 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS : |
| 401 OneClickSigninSyncStarter::UNDO_SYNC); | 400 OneClickSigninSyncStarter::UNDO_SYNC); |
| 402 } | 401 } |
| 403 } | 402 } |
| 404 | 403 |
| 405 void OneClickSigninBubbleView::WindowClosing() { | 404 void OneClickSigninBubbleView::WindowClosing() { |
| 406 // We have to reset |bubble_view_| here, not in our destructor, because | 405 // We have to reset |bubble_view_| here, not in our destructor, because |
| 407 // we'll be destroyed asynchronously and the shown state will be checked | 406 // we'll be destroyed asynchronously and the shown state will be checked |
| 408 // before then. | 407 // before then. |
| 409 DCHECK_EQ(bubble_view_, this); | 408 DCHECK_EQ(bubble_view_, this); |
| 410 bubble_view_ = NULL; | 409 bubble_view_ = NULL; |
| 411 | 410 |
| 412 if (is_sync_dialog_ && !start_sync_callback_.is_null()) { | 411 if (is_sync_dialog_ && !start_sync_callback_.is_null()) { |
| 413 base::ResetAndReturn(&start_sync_callback_).Run( | 412 base::ResetAndReturn(&start_sync_callback_).Run( |
| 414 OneClickSigninSyncStarter::UNDO_SYNC); | 413 OneClickSigninSyncStarter::UNDO_SYNC); |
| 415 } | 414 } |
| 416 } | 415 } |
| OLD | NEW |