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

Side by Side Diff: chrome/browser/views/options/content_page_view.cc

Issue 337034: Remove the browser_sync flag. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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/options/content_page_view.h ('k') | chrome/browser/views/toolbar_view.cc » ('j') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 18 matching lines...) Expand all
29 #include "views/grid_layout.h" 29 #include "views/grid_layout.h"
30 #include "views/standard_layout.h" 30 #include "views/standard_layout.h"
31 #include "views/widget/widget.h" 31 #include "views/widget/widget.h"
32 #include "views/window/window.h" 32 #include "views/window/window.h"
33 33
34 namespace { 34 namespace {
35 35
36 const int kPasswordSavingRadioGroup = 1; 36 const int kPasswordSavingRadioGroup = 1;
37 const int kFormAutofillRadioGroup = 2; 37 const int kFormAutofillRadioGroup = 2;
38 38
39 #if defined(BROWSER_SYNC)
40 // Background color for the status label when it's showing an error. 39 // Background color for the status label when it's showing an error.
41 static const SkColor kSyncLabelErrorBgColor = SkColorSetRGB(0xff, 0x9a, 0x9a); 40 static const SkColor kSyncLabelErrorBgColor = SkColorSetRGB(0xff, 0x9a, 0x9a);
42 41
43 static views::Background* CreateErrorBackground() { 42 static views::Background* CreateErrorBackground() {
44 return views::Background::CreateSolidBackground(kSyncLabelErrorBgColor); 43 return views::Background::CreateSolidBackground(kSyncLabelErrorBgColor);
45 } 44 }
46 #endif 45
47 } // namespace 46 } // namespace
48 47
49 ContentPageView::ContentPageView(Profile* profile) 48 ContentPageView::ContentPageView(Profile* profile)
50 : passwords_exceptions_button_(NULL), 49 : passwords_exceptions_button_(NULL),
51 passwords_group_(NULL), 50 passwords_group_(NULL),
52 passwords_asktosave_radio_(NULL), 51 passwords_asktosave_radio_(NULL),
53 passwords_neversave_radio_(NULL), 52 passwords_neversave_radio_(NULL),
54 form_autofill_asktosave_radio_(NULL), 53 form_autofill_asktosave_radio_(NULL),
55 form_autofill_neversave_radio_(NULL), 54 form_autofill_neversave_radio_(NULL),
56 themes_group_(NULL), 55 themes_group_(NULL),
57 themes_reset_button_(NULL), 56 themes_reset_button_(NULL),
58 themes_gallery_link_(NULL), 57 themes_gallery_link_(NULL),
59 browsing_data_label_(NULL), 58 browsing_data_label_(NULL),
60 browsing_data_group_(NULL), 59 browsing_data_group_(NULL),
61 import_button_(NULL), 60 import_button_(NULL),
62 clear_data_button_(NULL), 61 clear_data_button_(NULL),
63 #if defined(BROWSER_SYNC)
64 sync_group_(NULL), 62 sync_group_(NULL),
65 sync_status_label_(NULL), 63 sync_status_label_(NULL),
66 sync_action_link_(NULL), 64 sync_action_link_(NULL),
67 sync_start_stop_button_(NULL), 65 sync_start_stop_button_(NULL),
68 sync_service_(NULL), 66 sync_service_(NULL),
69 #endif
70 OptionsPageView(profile) { 67 OptionsPageView(profile) {
71 #if defined(BROWSER_SYNC)
72 if (profile->GetProfileSyncService()) { 68 if (profile->GetProfileSyncService()) {
73 sync_service_ = profile->GetProfileSyncService(); 69 sync_service_ = profile->GetProfileSyncService();
74 sync_service_->AddObserver(this); 70 sync_service_->AddObserver(this);
75 #endif
76 } 71 }
77 } 72 }
78 73
79 ContentPageView::~ContentPageView() { 74 ContentPageView::~ContentPageView() {
80 #if defined(BROWSER_SYNC)
81 if (sync_service_) 75 if (sync_service_)
82 sync_service_->RemoveObserver(this); 76 sync_service_->RemoveObserver(this);
83 #endif
84 } 77 }
85 78
86 /////////////////////////////////////////////////////////////////////////////// 79 ///////////////////////////////////////////////////////////////////////////////
87 // ContentPageView, views::ButtonListener implementation: 80 // ContentPageView, views::ButtonListener implementation:
88 81
89 void ContentPageView::ButtonPressed( 82 void ContentPageView::ButtonPressed(
90 views::Button* sender, const views::Event& event) { 83 views::Button* sender, const views::Event& event) {
91 if (sender == passwords_asktosave_radio_ || 84 if (sender == passwords_asktosave_radio_ ||
92 sender == passwords_neversave_radio_) { 85 sender == passwords_neversave_radio_) {
93 bool enabled = passwords_asktosave_radio_->checked(); 86 bool enabled = passwords_asktosave_radio_->checked();
(...skipping 25 matching lines...) Expand all
119 } else if (sender == import_button_) { 112 } else if (sender == import_button_) {
120 views::Window::CreateChromeWindow( 113 views::Window::CreateChromeWindow(
121 GetWindow()->GetNativeWindow(), 114 GetWindow()->GetNativeWindow(),
122 gfx::Rect(), 115 gfx::Rect(),
123 new ImporterView(profile()))->Show(); 116 new ImporterView(profile()))->Show();
124 } else if (sender == clear_data_button_) { 117 } else if (sender == clear_data_button_) {
125 views::Window::CreateChromeWindow( 118 views::Window::CreateChromeWindow(
126 GetWindow()->GetNativeWindow(), 119 GetWindow()->GetNativeWindow(),
127 gfx::Rect(), 120 gfx::Rect(),
128 new ClearBrowsingDataView(profile()))->Show(); 121 new ClearBrowsingDataView(profile()))->Show();
129 #if defined(BROWSER_SYNC)
130 } else if (sender == sync_start_stop_button_) { 122 } else if (sender == sync_start_stop_button_) {
131 DCHECK(sync_service_); 123 DCHECK(sync_service_);
132 124
133 if (sync_service_->HasSyncSetupCompleted()) { 125 if (sync_service_->HasSyncSetupCompleted()) {
134 ConfirmMessageBoxDialog::RunWithCustomConfiguration( 126 ConfirmMessageBoxDialog::RunWithCustomConfiguration(
135 GetWindow()->GetNativeWindow(), 127 GetWindow()->GetNativeWindow(),
136 this, 128 this,
137 l10n_util::GetString(IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL), 129 l10n_util::GetString(IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL),
138 l10n_util::GetString(IDS_SYNC_STOP_SYNCING_BUTTON_LABEL), 130 l10n_util::GetString(IDS_SYNC_STOP_SYNCING_BUTTON_LABEL),
139 l10n_util::GetString(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL), 131 l10n_util::GetString(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL),
140 l10n_util::GetString(IDS_CANCEL), 132 l10n_util::GetString(IDS_CANCEL),
141 gfx::Size(views::Window::GetLocalizedContentsSize( 133 gfx::Size(views::Window::GetLocalizedContentsSize(
142 IDS_CONFIRM_STOP_SYNCING_DIALOG_WIDTH_CHARS, 134 IDS_CONFIRM_STOP_SYNCING_DIALOG_WIDTH_CHARS,
143 IDS_CONFIRM_STOP_SYNCING_DIALOG_HEIGHT_LINES))); 135 IDS_CONFIRM_STOP_SYNCING_DIALOG_HEIGHT_LINES)));
144 return; 136 return;
145 } else { 137 } else {
146 sync_service_->EnableForUser(); 138 sync_service_->EnableForUser();
147 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS); 139 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS);
148 } 140 }
149 #endif
150 } 141 }
151 } 142 }
152 143
153 void ContentPageView::LinkActivated(views::Link* source, int event_flags) { 144 void ContentPageView::LinkActivated(views::Link* source, int event_flags) {
154 if (source == themes_gallery_link_) { 145 if (source == themes_gallery_link_) {
155 UserMetricsRecordAction(L"Options_ThemesGallery", profile()->GetPrefs()); 146 UserMetricsRecordAction(L"Options_ThemesGallery", profile()->GetPrefs());
156 Browser* browser = BrowserList::GetLastActive(); 147 Browser* browser = BrowserList::GetLastActive();
157 browser->OpenURL(GURL(l10n_util::GetString(IDS_THEMES_GALLERY_URL)), 148 browser->OpenURL(GURL(l10n_util::GetString(IDS_THEMES_GALLERY_URL)),
158 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); 149 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK);
159 browser->window()->Activate(); 150 browser->window()->Activate();
160 return; 151 return;
161 } 152 }
162 #if defined(BROWSER_SYNC)
163 DCHECK_EQ(source, sync_action_link_); 153 DCHECK_EQ(source, sync_action_link_);
164 DCHECK(sync_service_); 154 DCHECK(sync_service_);
165 sync_service_->ShowLoginDialog(); 155 sync_service_->ShowLoginDialog();
166 #endif
167 } 156 }
168 157
169 //////////////////////////////////////////////////////////////////////////////// 158 ////////////////////////////////////////////////////////////////////////////////
170 // ContentPageView, OptionsPageView implementation: 159 // ContentPageView, OptionsPageView implementation:
171 160
172 void ContentPageView::InitControlLayout() { 161 void ContentPageView::InitControlLayout() {
173 using views::GridLayout; 162 using views::GridLayout;
174 using views::ColumnSet; 163 using views::ColumnSet;
175 164
176 GridLayout* layout = new GridLayout(this); 165 GridLayout* layout = new GridLayout(this);
177 layout->SetInsets(5, 5, 5, 5); 166 layout->SetInsets(5, 5, 5, 5);
178 SetLayoutManager(layout); 167 SetLayoutManager(layout);
179 168
180 const int single_column_view_set_id = 0; 169 const int single_column_view_set_id = 0;
181 ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id); 170 ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id);
182 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, 171 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
183 GridLayout::USE_PREF, 0, 0); 172 GridLayout::USE_PREF, 0, 0);
184 173
185 #if defined(BROWSER_SYNC)
186 if (sync_service_) { 174 if (sync_service_) {
187 layout->StartRow(0, single_column_view_set_id); 175 layout->StartRow(0, single_column_view_set_id);
188 InitSyncGroup(); 176 InitSyncGroup();
189 layout->AddView(sync_group_); 177 layout->AddView(sync_group_);
190 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 178 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
191 } 179 }
192 #endif
193 180
194 layout->StartRow(0, single_column_view_set_id); 181 layout->StartRow(0, single_column_view_set_id);
195 InitPasswordSavingGroup(); 182 InitPasswordSavingGroup();
196 layout->AddView(passwords_group_); 183 layout->AddView(passwords_group_);
197 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 184 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
198 185
199 layout->StartRow(0, single_column_view_set_id); 186 layout->StartRow(0, single_column_view_set_id);
200 InitFormAutofillGroup(); 187 InitFormAutofillGroup();
201 layout->AddView(form_autofill_group_); 188 layout->AddView(form_autofill_group_);
202 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 189 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 if (!pref_name || *pref_name == prefs::kCurrentThemeID) { 225 if (!pref_name || *pref_name == prefs::kCurrentThemeID) {
239 themes_reset_button_->SetEnabled( 226 themes_reset_button_->SetEnabled(
240 is_using_default_theme_.GetValue().length() > 0); 227 is_using_default_theme_.GetValue().length() > 0);
241 } 228 }
242 } 229 }
243 230
244 /////////////////////////////////////////////////////////////////////////////// 231 ///////////////////////////////////////////////////////////////////////////////
245 // ContentsPageView, views::View overrides: 232 // ContentsPageView, views::View overrides:
246 233
247 void ContentPageView::Layout() { 234 void ContentPageView::Layout() {
248 #if defined(BROWSER_SYNC)
249 if (is_initialized()) 235 if (is_initialized())
250 UpdateSyncControls(); 236 UpdateSyncControls();
251 #endif
252 // We need to Layout twice - once to get the width of the contents box... 237 // We need to Layout twice - once to get the width of the contents box...
253 View::Layout(); 238 View::Layout();
254 passwords_asktosave_radio_->SetBounds( 239 passwords_asktosave_radio_->SetBounds(
255 0, 0, passwords_group_->GetContentsWidth(), 0); 240 0, 0, passwords_group_->GetContentsWidth(), 0);
256 passwords_neversave_radio_->SetBounds( 241 passwords_neversave_radio_->SetBounds(
257 0, 0, passwords_group_->GetContentsWidth(), 0); 242 0, 0, passwords_group_->GetContentsWidth(), 0);
258 browsing_data_label_->SetBounds( 243 browsing_data_label_->SetBounds(
259 0, 0, browsing_data_group_->GetContentsWidth(), 0); 244 0, 0, browsing_data_group_->GetContentsWidth(), 0);
260 #if defined(BROWSER_SYNC)
261 if (is_initialized()) { 245 if (is_initialized()) {
262 sync_status_label_->SetBounds( 246 sync_status_label_->SetBounds(
263 0, 0, sync_group_->GetContentsWidth(), 0); 247 0, 0, sync_group_->GetContentsWidth(), 0);
264 } 248 }
265 #endif
266 // ... and twice to get the height of multi-line items correct. 249 // ... and twice to get the height of multi-line items correct.
267 View::Layout(); 250 View::Layout();
268 } 251 }
269 252
270 253
271 /////////////////////////////////////////////////////////////////////////////// 254 ///////////////////////////////////////////////////////////////////////////////
272 // ContentsPageView, ProfileSyncServiceObserver implementation: 255 // ContentsPageView, ProfileSyncServiceObserver implementation:
273 #if defined(BROWSER_SYNC) 256
274 void ContentPageView::OnStateChanged() { 257 void ContentPageView::OnStateChanged() {
275 // If the UI controls are not yet initialized, then don't do anything. This 258 // If the UI controls are not yet initialized, then don't do anything. This
276 // can happen if the Options dialog is up, but the Content tab is not yet 259 // can happen if the Options dialog is up, but the Content tab is not yet
277 // clicked. 260 // clicked.
278 if (is_initialized()) 261 if (is_initialized())
279 Layout(); 262 Layout();
280 } 263 }
281 #endif
282 264
283 /////////////////////////////////////////////////////////////////////////////// 265 ///////////////////////////////////////////////////////////////////////////////
284 // ContentPageView, private: 266 // ContentPageView, private:
285 267
286 void ContentPageView::InitPasswordSavingGroup() { 268 void ContentPageView::InitPasswordSavingGroup() {
287 passwords_asktosave_radio_ = new views::RadioButton( 269 passwords_asktosave_radio_ = new views::RadioButton(
288 l10n_util::GetString(IDS_OPTIONS_PASSWORDS_ASKTOSAVE), 270 l10n_util::GetString(IDS_OPTIONS_PASSWORDS_ASKTOSAVE),
289 kPasswordSavingRadioGroup); 271 kPasswordSavingRadioGroup);
290 passwords_asktosave_radio_->set_listener(this); 272 passwords_asktosave_radio_->set_listener(this);
291 passwords_asktosave_radio_->SetMultiLine(true); 273 passwords_asktosave_radio_->SetMultiLine(true);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 browsing_data_group_ = new OptionsGroupView( 414 browsing_data_group_ = new OptionsGroupView(
433 contents, l10n_util::GetString(IDS_OPTIONS_BROWSING_DATA_GROUP_NAME), 415 contents, l10n_util::GetString(IDS_OPTIONS_BROWSING_DATA_GROUP_NAME),
434 L"", true); 416 L"", true);
435 } 417 }
436 418
437 void ContentPageView::OnConfirmMessageAccept() { 419 void ContentPageView::OnConfirmMessageAccept() {
438 sync_service_->DisableForUser(); 420 sync_service_->DisableForUser();
439 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); 421 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
440 } 422 }
441 423
442 #if defined(BROWSER_SYNC)
443 void ContentPageView::InitSyncGroup() { 424 void ContentPageView::InitSyncGroup() {
444 sync_status_label_ = new views::Label; 425 sync_status_label_ = new views::Label;
445 sync_status_label_->SetMultiLine(true); 426 sync_status_label_->SetMultiLine(true);
446 sync_status_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 427 sync_status_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
447 428
448 sync_action_link_ = new views::Link(); 429 sync_action_link_ = new views::Link();
449 sync_action_link_->set_collapse_when_hidden(true); 430 sync_action_link_->set_collapse_when_hidden(true);
450 sync_action_link_->SetController(this); 431 sync_action_link_->SetController(this);
451 432
452 sync_start_stop_button_ = new views::NativeButton(this, std::wstring()); 433 sync_start_stop_button_ = new views::NativeButton(this, std::wstring());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 sync_action_link_->SetText(link_label); 477 sync_action_link_->SetText(link_label);
497 sync_action_link_->SetVisible(!link_label.empty()); 478 sync_action_link_->SetVisible(!link_label.empty());
498 if (status_has_error) { 479 if (status_has_error) {
499 sync_status_label_->set_background(CreateErrorBackground()); 480 sync_status_label_->set_background(CreateErrorBackground());
500 sync_action_link_->set_background(CreateErrorBackground()); 481 sync_action_link_->set_background(CreateErrorBackground());
501 } else { 482 } else {
502 sync_status_label_->set_background(NULL); 483 sync_status_label_->set_background(NULL);
503 sync_action_link_->set_background(NULL); 484 sync_action_link_->set_background(NULL);
504 } 485 }
505 } 486 }
506
507 #endif // defined(BROWSER_SYNC)
OLDNEW
« no previous file with comments | « chrome/browser/views/options/content_page_view.h ('k') | chrome/browser/views/toolbar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698