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/views/options/content_page_view.h" | 5 #include "chrome/browser/views/options/content_page_view.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 #include <vsstyle.h> | 9 #include <vsstyle.h> |
10 #include <vssym32.h> | 10 #include <vssym32.h> |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 themes_group_(NULL), | 66 themes_group_(NULL), |
67 themes_reset_button_(NULL), | 67 themes_reset_button_(NULL), |
68 themes_gallery_link_(NULL), | 68 themes_gallery_link_(NULL), |
69 browsing_data_group_(NULL), | 69 browsing_data_group_(NULL), |
70 import_button_(NULL), | 70 import_button_(NULL), |
71 sync_group_(NULL), | 71 sync_group_(NULL), |
72 sync_action_link_(NULL), | 72 sync_action_link_(NULL), |
73 sync_status_label_(NULL), | 73 sync_status_label_(NULL), |
74 sync_start_stop_button_(NULL), | 74 sync_start_stop_button_(NULL), |
75 sync_customize_button_(NULL), | 75 sync_customize_button_(NULL), |
| 76 privacy_dashboard_link_(NULL), |
76 sync_service_(NULL), | 77 sync_service_(NULL), |
77 OptionsPageView(profile) { | 78 OptionsPageView(profile) { |
78 if (profile->GetProfileSyncService()) { | 79 if (profile->GetProfileSyncService()) { |
79 sync_service_ = profile->GetProfileSyncService(); | 80 sync_service_ = profile->GetProfileSyncService(); |
80 sync_service_->AddObserver(this); | 81 sync_service_->AddObserver(this); |
81 } | 82 } |
82 } | 83 } |
83 | 84 |
84 ContentPageView::~ContentPageView() { | 85 ContentPageView::~ContentPageView() { |
85 if (sync_service_) | 86 if (sync_service_) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 162 } |
162 } | 163 } |
163 | 164 |
164 void ContentPageView::LinkActivated(views::Link* source, int event_flags) { | 165 void ContentPageView::LinkActivated(views::Link* source, int event_flags) { |
165 if (source == themes_gallery_link_) { | 166 if (source == themes_gallery_link_) { |
166 UserMetricsRecordAction(UserMetricsAction("Options_ThemesGallery"), | 167 UserMetricsRecordAction(UserMetricsAction("Options_ThemesGallery"), |
167 profile()->GetPrefs()); | 168 profile()->GetPrefs()); |
168 BrowserList::GetLastActive()->OpenThemeGalleryTabAndActivate(); | 169 BrowserList::GetLastActive()->OpenThemeGalleryTabAndActivate(); |
169 return; | 170 return; |
170 } | 171 } |
171 DCHECK_EQ(source, sync_action_link_); | 172 if (source == sync_action_link_) { |
172 DCHECK(sync_service_); | 173 DCHECK(sync_service_); |
173 sync_service_->ShowLoginDialog(); | 174 sync_service_->ShowLoginDialog(); |
| 175 return; |
| 176 } |
| 177 if (source == privacy_dashboard_link_) { |
| 178 BrowserList::GetLastActive()->OpenPrivacyDashboardTabAndActivate(); |
| 179 return; |
| 180 } |
| 181 NOTREACHED() << "Invalid link source."; |
174 } | 182 } |
175 | 183 |
176 //////////////////////////////////////////////////////////////////////////////// | 184 //////////////////////////////////////////////////////////////////////////////// |
177 // ContentPageView, OptionsPageView implementation: | 185 // ContentPageView, OptionsPageView implementation: |
178 | 186 |
179 void ContentPageView::InitControlLayout() { | 187 void ContentPageView::InitControlLayout() { |
180 using views::GridLayout; | 188 using views::GridLayout; |
181 using views::ColumnSet; | 189 using views::ColumnSet; |
182 | 190 |
183 GridLayout* layout = new GridLayout(this); | 191 GridLayout* layout = new GridLayout(this); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 432 |
425 void ContentPageView::InitSyncGroup() { | 433 void ContentPageView::InitSyncGroup() { |
426 sync_status_label_ = new views::Label; | 434 sync_status_label_ = new views::Label; |
427 sync_status_label_->SetMultiLine(true); | 435 sync_status_label_->SetMultiLine(true); |
428 sync_status_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 436 sync_status_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
429 | 437 |
430 sync_action_link_ = new views::Link(); | 438 sync_action_link_ = new views::Link(); |
431 sync_action_link_->set_collapse_when_hidden(true); | 439 sync_action_link_->set_collapse_when_hidden(true); |
432 sync_action_link_->SetController(this); | 440 sync_action_link_->SetController(this); |
433 | 441 |
| 442 privacy_dashboard_link_ = new views::Link(); |
| 443 privacy_dashboard_link_->set_collapse_when_hidden(true); |
| 444 privacy_dashboard_link_->SetController(this); |
| 445 privacy_dashboard_link_->SetText( |
| 446 l10n_util::GetString(IDS_SYNC_PRIVACY_DASHBOARD_LINK_LABEL)); |
| 447 privacy_dashboard_link_->SetVisible( |
| 448 CommandLine::ForCurrentProcess()->HasSwitch( |
| 449 switches::kShowPrivacyDashboardLink)); |
| 450 |
434 sync_start_stop_button_ = new views::NativeButton(this, std::wstring()); | 451 sync_start_stop_button_ = new views::NativeButton(this, std::wstring()); |
435 sync_customize_button_ = new views::NativeButton(this, std::wstring()); | 452 sync_customize_button_ = new views::NativeButton(this, std::wstring()); |
436 | 453 |
437 using views::GridLayout; | 454 using views::GridLayout; |
438 using views::ColumnSet; | 455 using views::ColumnSet; |
439 | 456 |
440 views::View* contents = new views::View; | 457 views::View* contents = new views::View; |
441 GridLayout* layout = new GridLayout(contents); | 458 GridLayout* layout = new GridLayout(contents); |
442 contents->SetLayoutManager(layout); | 459 contents->SetLayoutManager(layout); |
443 | 460 |
444 const int single_column_view_set_id = 0; | 461 const int single_column_view_set_id = 0; |
445 ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id); | 462 ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id); |
446 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, | 463 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, |
447 GridLayout::USE_PREF, 0, 0); | 464 GridLayout::USE_PREF, 0, 0); |
448 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); | 465 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); |
449 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1, | 466 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1, |
450 GridLayout::USE_PREF, 0, 0); | 467 GridLayout::USE_PREF, 0, 0); |
451 | 468 |
452 layout->StartRow(0, single_column_view_set_id); | 469 layout->StartRow(0, single_column_view_set_id); |
453 layout->AddView(sync_status_label_, 3, 1, | 470 layout->AddView(sync_status_label_, 3, 1, |
454 GridLayout::FILL, GridLayout::LEADING); | 471 GridLayout::FILL, GridLayout::LEADING); |
455 layout->StartRow(0, single_column_view_set_id); | 472 layout->StartRow(0, single_column_view_set_id); |
456 layout->AddView(sync_action_link_, 3, 1); | 473 layout->AddView(sync_action_link_, 3, 1); |
457 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 474 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
458 layout->StartRow(0, single_column_view_set_id); | 475 layout->StartRow(0, single_column_view_set_id); |
459 layout->AddView(sync_start_stop_button_); | 476 layout->AddView(sync_start_stop_button_); |
460 layout->AddView(sync_customize_button_); | 477 layout->AddView(sync_customize_button_); |
| 478 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 479 layout->StartRow(0, single_column_view_set_id); |
| 480 layout->AddView(privacy_dashboard_link_, 3, 1); |
461 | 481 |
462 sync_group_ = new OptionsGroupView(contents, | 482 sync_group_ = new OptionsGroupView(contents, |
463 l10n_util::GetString(IDS_SYNC_OPTIONS_GROUP_NAME), std::wstring(), true); | 483 l10n_util::GetString(IDS_SYNC_OPTIONS_GROUP_NAME), std::wstring(), true); |
464 } | 484 } |
465 | 485 |
466 void ContentPageView::UpdateSyncControls() { | 486 void ContentPageView::UpdateSyncControls() { |
467 DCHECK(sync_service_); | 487 DCHECK(sync_service_); |
468 std::wstring status_label; | 488 std::wstring status_label; |
469 std::wstring link_label; | 489 std::wstring link_label; |
470 std::wstring customize_button_label; | 490 std::wstring customize_button_label; |
(...skipping 20 matching lines...) Expand all Loading... |
491 sync_action_link_->SetVisible(!link_label.empty()); | 511 sync_action_link_->SetVisible(!link_label.empty()); |
492 | 512 |
493 if (status_has_error) { | 513 if (status_has_error) { |
494 sync_status_label_->set_background(CreateErrorBackground()); | 514 sync_status_label_->set_background(CreateErrorBackground()); |
495 sync_action_link_->set_background(CreateErrorBackground()); | 515 sync_action_link_->set_background(CreateErrorBackground()); |
496 } else { | 516 } else { |
497 sync_status_label_->set_background(NULL); | 517 sync_status_label_->set_background(NULL); |
498 sync_action_link_->set_background(NULL); | 518 sync_action_link_->set_background(NULL); |
499 } | 519 } |
500 } | 520 } |
OLD | NEW |