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

Side by Side Diff: chrome/browser/ui/gtk/options/content_page_gtk.cc

Issue 6307019: Cleanup: remove unused internet and system pages for chrome os options. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Remove ifdef code in content_page_gtk.cc Created 9 years, 10 months 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/ui/gtk/gtk_util.cc ('k') | chrome/browser/ui/gtk/options/options_window_gtk.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/gtk/options/content_page_gtk.h" 5 #include "chrome/browser/ui/gtk/options/content_page_gtk.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/common/notification_service.h" 24 #include "chrome/common/notification_service.h"
25 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
27 #include "gfx/gtk_util.h" 27 #include "gfx/gtk_util.h"
28 #include "grit/app_resources.h" 28 #include "grit/app_resources.h"
29 #include "grit/chromium_strings.h" 29 #include "grit/chromium_strings.h"
30 #include "grit/generated_resources.h" 30 #include "grit/generated_resources.h"
31 #include "grit/locale_settings.h" 31 #include "grit/locale_settings.h"
32 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
33 33
34 #if defined(OS_CHROMEOS)
35 #include "chrome/browser/chromeos/options/options_window_view.h"
36 #endif // defined(OS_CHROMEOS)
37
38 namespace { 34 namespace {
39 35
40 // Background color for the status label when it's showing an error. 36 // Background color for the status label when it's showing an error.
41 static const GdkColor kSyncLabelErrorBgColor = GDK_COLOR_RGB(0xff, 0x9a, 0x9a); 37 static const GdkColor kSyncLabelErrorBgColor = GDK_COLOR_RGB(0xff, 0x9a, 0x9a);
42 38
43 // Helper for WrapLabelAtAllocationHack. 39 // Helper for WrapLabelAtAllocationHack.
44 void OnLabelAllocate(GtkWidget* label, GtkAllocation* allocation) { 40 void OnLabelAllocate(GtkWidget* label, GtkAllocation* allocation) {
45 gtk_util::SetLabelWidth(label, allocation->width); 41 gtk_util::SetLabelWidth(label, allocation->width);
46 42
47 // Disconnect ourselves. Repeatedly resizing based on allocation causes 43 // Disconnect ourselves. Repeatedly resizing based on allocation causes
(...skipping 15 matching lines...) Expand all
63 59
64 } // anonymous namespace 60 } // anonymous namespace
65 61
66 /////////////////////////////////////////////////////////////////////////////// 62 ///////////////////////////////////////////////////////////////////////////////
67 // ContentPageGtk, public: 63 // ContentPageGtk, public:
68 64
69 ContentPageGtk::ContentPageGtk(Profile* profile) 65 ContentPageGtk::ContentPageGtk(Profile* profile)
70 : OptionsPageBase(profile), 66 : OptionsPageBase(profile),
71 sync_status_label_background_(NULL), 67 sync_status_label_background_(NULL),
72 sync_status_label_(NULL), 68 sync_status_label_(NULL),
73 #if !defined(OS_CHROMEOS)
74 sync_action_link_background_(NULL), 69 sync_action_link_background_(NULL),
75 sync_action_link_(NULL), 70 sync_action_link_(NULL),
76 #endif
77 sync_start_stop_button_(NULL), 71 sync_start_stop_button_(NULL),
78 sync_customize_button_(NULL), 72 sync_customize_button_(NULL),
79 privacy_dashboard_link_(NULL), 73 privacy_dashboard_link_(NULL),
80 initializing_(true), 74 initializing_(true),
81 sync_service_(NULL), 75 sync_service_(NULL),
82 managed_prefs_banner_(profile->GetPrefs(), OPTIONS_PAGE_CONTENT) { 76 managed_prefs_banner_(profile->GetPrefs(), OPTIONS_PAGE_CONTENT) {
83 if (profile->GetProfileSyncService()) { 77 if (profile->GetProfileSyncService()) {
84 sync_service_ = profile->GetProfileSyncService(); 78 sync_service_ = profile->GetProfileSyncService();
85 sync_service_->AddObserver(this); 79 sync_service_->AddObserver(this);
86 } 80 }
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 sync_status_label_background_ = gtk_event_box_new(); 328 sync_status_label_background_ = gtk_event_box_new();
335 sync_status_label_ = gtk_label_new(""); 329 sync_status_label_ = gtk_label_new("");
336 WrapLabelAtAllocationHack(sync_status_label_); 330 WrapLabelAtAllocationHack(sync_status_label_);
337 331
338 gtk_misc_set_alignment(GTK_MISC(sync_status_label_), 0, 0.5); 332 gtk_misc_set_alignment(GTK_MISC(sync_status_label_), 0, 0.5);
339 gtk_box_pack_start(GTK_BOX(vbox), sync_status_label_background_, FALSE, 333 gtk_box_pack_start(GTK_BOX(vbox), sync_status_label_background_, FALSE,
340 FALSE, 0); 334 FALSE, 0);
341 gtk_container_add(GTK_CONTAINER(sync_status_label_background_), 335 gtk_container_add(GTK_CONTAINER(sync_status_label_background_),
342 sync_status_label_); 336 sync_status_label_);
343 337
344 #if !defined(OS_CHROMEOS)
345 // Sync action link. 338 // Sync action link.
346 GtkWidget* link_hbox = gtk_hbox_new(FALSE, gtk_util::kLabelSpacing); 339 GtkWidget* link_hbox = gtk_hbox_new(FALSE, gtk_util::kLabelSpacing);
347 sync_action_link_background_ = gtk_event_box_new(); 340 sync_action_link_background_ = gtk_event_box_new();
348 sync_action_link_ = gtk_chrome_link_button_new(""); 341 sync_action_link_ = gtk_chrome_link_button_new("");
349 g_signal_connect(sync_action_link_, "clicked", 342 g_signal_connect(sync_action_link_, "clicked",
350 G_CALLBACK(OnSyncActionLinkClickedThunk), this); 343 G_CALLBACK(OnSyncActionLinkClickedThunk), this);
351 gtk_box_pack_start(GTK_BOX(vbox), link_hbox, FALSE, FALSE, 0); 344 gtk_box_pack_start(GTK_BOX(vbox), link_hbox, FALSE, FALSE, 0);
352 gtk_box_pack_start(GTK_BOX(link_hbox), sync_action_link_background_, FALSE, 345 gtk_box_pack_start(GTK_BOX(link_hbox), sync_action_link_background_, FALSE,
353 FALSE, 0); 346 FALSE, 0);
354 gtk_container_add(GTK_CONTAINER(sync_action_link_background_), 347 gtk_container_add(GTK_CONTAINER(sync_action_link_background_),
355 sync_action_link_); 348 sync_action_link_);
356 gtk_widget_hide(sync_action_link_background_); 349 gtk_widget_hide(sync_action_link_background_);
357 #endif
358 350
359 // Add the sync button into its own horizontal box so it does not 351 // Add the sync button into its own horizontal box so it does not
360 // depend on the spacing above. 352 // depend on the spacing above.
361 GtkWidget* button_hbox = gtk_hbox_new(FALSE, gtk_util::kLabelSpacing); 353 GtkWidget* button_hbox = gtk_hbox_new(FALSE, gtk_util::kLabelSpacing);
362 gtk_container_add(GTK_CONTAINER(vbox), button_hbox); 354 gtk_container_add(GTK_CONTAINER(vbox), button_hbox);
363 sync_start_stop_button_ = gtk_button_new_with_label(""); 355 sync_start_stop_button_ = gtk_button_new_with_label("");
364 g_signal_connect(sync_start_stop_button_, "clicked", 356 g_signal_connect(sync_start_stop_button_, "clicked",
365 G_CALLBACK(OnSyncStartStopButtonClickedThunk), this); 357 G_CALLBACK(OnSyncStartStopButtonClickedThunk), this);
366 gtk_box_pack_start(GTK_BOX(button_hbox), sync_start_stop_button_, FALSE, 358 gtk_box_pack_start(GTK_BOX(button_hbox), sync_start_stop_button_, FALSE,
367 FALSE, 0); 359 FALSE, 0);
(...skipping 29 matching lines...) Expand all
397 string16 link_label; 389 string16 link_label;
398 std::string customize_button_label; 390 std::string customize_button_label;
399 bool managed = sync_service_->IsManaged(); 391 bool managed = sync_service_->IsManaged();
400 bool sync_setup_completed = sync_service_->HasSyncSetupCompleted(); 392 bool sync_setup_completed = sync_service_->HasSyncSetupCompleted();
401 bool status_has_error = sync_ui_util::GetStatusLabels(sync_service_, 393 bool status_has_error = sync_ui_util::GetStatusLabels(sync_service_,
402 &status_label, &link_label) == sync_ui_util::SYNC_ERROR; 394 &status_label, &link_label) == sync_ui_util::SYNC_ERROR;
403 customize_button_label = 395 customize_button_label =
404 l10n_util::GetStringUTF8(IDS_SYNC_CUSTOMIZE_BUTTON_LABEL); 396 l10n_util::GetStringUTF8(IDS_SYNC_CUSTOMIZE_BUTTON_LABEL);
405 397
406 std::string start_stop_button_label; 398 std::string start_stop_button_label;
407 bool is_start_stop_button_visible = false;
408 bool is_start_stop_button_sensitive = false; 399 bool is_start_stop_button_sensitive = false;
409 if (sync_setup_completed) { 400 if (sync_setup_completed) {
410 start_stop_button_label = 401 start_stop_button_label =
411 l10n_util::GetStringUTF8(IDS_SYNC_STOP_SYNCING_BUTTON_LABEL); 402 l10n_util::GetStringUTF8(IDS_SYNC_STOP_SYNCING_BUTTON_LABEL);
412 #if defined(OS_CHROMEOS)
413 is_start_stop_button_visible = false;
414 #else
415 is_start_stop_button_visible = true;
416 #endif
417 is_start_stop_button_sensitive = !managed; 403 is_start_stop_button_sensitive = !managed;
418 } else if (sync_service_->SetupInProgress()) { 404 } else if (sync_service_->SetupInProgress()) {
419 start_stop_button_label = 405 start_stop_button_label =
420 l10n_util::GetStringUTF8(IDS_SYNC_NTP_SETUP_IN_PROGRESS); 406 l10n_util::GetStringUTF8(IDS_SYNC_NTP_SETUP_IN_PROGRESS);
421 is_start_stop_button_visible = true;
422 is_start_stop_button_sensitive = false; 407 is_start_stop_button_sensitive = false;
423 } else { 408 } else {
424 start_stop_button_label = 409 start_stop_button_label =
425 l10n_util::GetStringUTF8(IDS_SYNC_START_SYNC_BUTTON_LABEL); 410 l10n_util::GetStringUTF8(IDS_SYNC_START_SYNC_BUTTON_LABEL);
426 is_start_stop_button_visible = true;
427 is_start_stop_button_sensitive = !managed; 411 is_start_stop_button_sensitive = !managed;
428 } 412 }
429 gtk_widget_set_no_show_all(sync_start_stop_button_, 413 gtk_widget_set_no_show_all(sync_start_stop_button_, FALSE);
430 !is_start_stop_button_visible); 414 gtk_widget_show(sync_start_stop_button_);
431 if (is_start_stop_button_visible)
432 gtk_widget_show(sync_start_stop_button_);
433 else
434 gtk_widget_hide(sync_start_stop_button_);
435 gtk_widget_set_sensitive(sync_start_stop_button_, 415 gtk_widget_set_sensitive(sync_start_stop_button_,
436 is_start_stop_button_sensitive); 416 is_start_stop_button_sensitive);
437 gtk_button_set_label(GTK_BUTTON(sync_start_stop_button_), 417 gtk_button_set_label(GTK_BUTTON(sync_start_stop_button_),
438 start_stop_button_label.c_str()); 418 start_stop_button_label.c_str());
439 419
440 gtk_label_set_label(GTK_LABEL(sync_status_label_), 420 gtk_label_set_label(GTK_LABEL(sync_status_label_),
441 UTF16ToUTF8(status_label).c_str()); 421 UTF16ToUTF8(status_label).c_str());
442 422
443 gtk_widget_set_child_visible(sync_customize_button_, 423 gtk_widget_set_child_visible(sync_customize_button_,
444 sync_setup_completed && !status_has_error); 424 sync_setup_completed && !status_has_error);
445 gtk_button_set_label(GTK_BUTTON(sync_customize_button_), 425 gtk_button_set_label(GTK_BUTTON(sync_customize_button_),
446 customize_button_label.c_str()); 426 customize_button_label.c_str());
447 gtk_widget_set_sensitive(sync_customize_button_, !managed); 427 gtk_widget_set_sensitive(sync_customize_button_, !managed);
448 #if !defined(OS_CHROMEOS)
449 gtk_chrome_link_button_set_label(GTK_CHROME_LINK_BUTTON(sync_action_link_), 428 gtk_chrome_link_button_set_label(GTK_CHROME_LINK_BUTTON(sync_action_link_),
450 UTF16ToUTF8(link_label).c_str()); 429 UTF16ToUTF8(link_label).c_str());
451 if (link_label.empty()) { 430 if (link_label.empty()) {
452 gtk_widget_set_no_show_all(sync_action_link_background_, TRUE); 431 gtk_widget_set_no_show_all(sync_action_link_background_, TRUE);
453 gtk_widget_hide(sync_action_link_background_); 432 gtk_widget_hide(sync_action_link_background_);
454 } else { 433 } else {
455 gtk_widget_set_no_show_all(sync_action_link_background_, FALSE); 434 gtk_widget_set_no_show_all(sync_action_link_background_, FALSE);
456 gtk_widget_show(sync_action_link_background_); 435 gtk_widget_show(sync_action_link_background_);
457 } 436 }
458 gtk_widget_set_sensitive(sync_action_link_, !managed); 437 gtk_widget_set_sensitive(sync_action_link_, !managed);
459 #endif
460 if (status_has_error) { 438 if (status_has_error) {
461 gtk_widget_modify_bg(sync_status_label_background_, GTK_STATE_NORMAL, 439 gtk_widget_modify_bg(sync_status_label_background_, GTK_STATE_NORMAL,
462 &kSyncLabelErrorBgColor); 440 &kSyncLabelErrorBgColor);
463 #if !defined(OS_CHROMEOS)
464 gtk_widget_modify_bg(sync_action_link_background_, GTK_STATE_NORMAL, 441 gtk_widget_modify_bg(sync_action_link_background_, GTK_STATE_NORMAL,
465 &kSyncLabelErrorBgColor); 442 &kSyncLabelErrorBgColor);
466 #endif
467 } else { 443 } else {
468 gtk_widget_modify_bg(sync_status_label_background_, GTK_STATE_NORMAL, NULL); 444 gtk_widget_modify_bg(sync_status_label_background_, GTK_STATE_NORMAL, NULL);
469 #if !defined(OS_CHROMEOS)
470 gtk_widget_modify_bg(sync_action_link_background_, GTK_STATE_NORMAL, NULL); 445 gtk_widget_modify_bg(sync_action_link_background_, GTK_STATE_NORMAL, NULL);
471 #endif
472 } 446 }
473 } 447 }
474 448
475 void ContentPageGtk::OnAutoFillButtonClicked(GtkWidget* widget) { 449 void ContentPageGtk::OnAutoFillButtonClicked(GtkWidget* widget) {
476 ShowAutoFillDialog(NULL, profile()->GetPersonalDataManager(), profile()); 450 ShowAutoFillDialog(NULL, profile()->GetPersonalDataManager(), profile());
477 } 451 }
478 452
479 void ContentPageGtk::OnImportButtonClicked(GtkWidget* widget) { 453 void ContentPageGtk::OnImportButtonClicked(GtkWidget* widget) {
480 ImportDialogGtk::Show( 454 ImportDialogGtk::Show(
481 GTK_WINDOW(gtk_widget_get_toplevel(widget)), 455 GTK_WINDOW(gtk_widget_get_toplevel(widget)),
482 profile(), importer::ALL); 456 profile(), importer::ALL);
483 } 457 }
484 458
485 void ContentPageGtk::OnGtkThemeButtonClicked(GtkWidget* widget) { 459 void ContentPageGtk::OnGtkThemeButtonClicked(GtkWidget* widget) {
486 UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet"), 460 UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet"),
487 profile()->GetPrefs()); 461 profile()->GetPrefs());
488 profile()->SetNativeTheme(); 462 profile()->SetNativeTheme();
489 } 463 }
490 464
491 void ContentPageGtk::OnResetDefaultThemeButtonClicked(GtkWidget* widget) { 465 void ContentPageGtk::OnResetDefaultThemeButtonClicked(GtkWidget* widget) {
492 UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset"), 466 UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset"),
493 profile()->GetPrefs()); 467 profile()->GetPrefs());
494 profile()->ClearTheme(); 468 profile()->ClearTheme();
495 } 469 }
496 470
497 void ContentPageGtk::OnGetThemesButtonClicked(GtkWidget* widget) { 471 void ContentPageGtk::OnGetThemesButtonClicked(GtkWidget* widget) {
498 UserMetricsRecordAction(UserMetricsAction("Options_ThemesGallery"), 472 UserMetricsRecordAction(UserMetricsAction("Options_ThemesGallery"),
499 profile()->GetPrefs()); 473 profile()->GetPrefs());
500 #if defined(OS_CHROMEOS)
501 // Close options dialog for ChromeOS becuase it is always stacked on top
502 // of browser window and blocks user's view.
503 chromeos::CloseOptionsWindow();
504 #endif // defined(OS_CHROMEOS)
505
506 BrowserList::GetLastActive()->OpenThemeGalleryTabAndActivate(); 474 BrowserList::GetLastActive()->OpenThemeGalleryTabAndActivate();
507 } 475 }
508 476
509 void ContentPageGtk::OnSystemTitleBarRadioToggled(GtkWidget* widget) { 477 void ContentPageGtk::OnSystemTitleBarRadioToggled(GtkWidget* widget) {
510 DCHECK(browser_defaults::kCanToggleSystemTitleBar); 478 DCHECK(browser_defaults::kCanToggleSystemTitleBar);
511 if (initializing_) 479 if (initializing_)
512 return; 480 return;
513 481
514 // We get two signals when selecting a radio button, one for the old radio 482 // We get two signals when selecting a radio button, one for the old radio
515 // being toggled off and one for the new one being toggled on. Ignore the 483 // being toggled off and one for the new one being toggled on. Ignore the
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 if (response == GTK_RESPONSE_ACCEPT) { 577 if (response == GTK_RESPONSE_ACCEPT) {
610 sync_service_->DisableForUser(); 578 sync_service_->DisableForUser();
611 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); 579 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
612 } 580 }
613 gtk_widget_destroy(widget); 581 gtk_widget_destroy(widget);
614 } 582 }
615 583
616 void ContentPageGtk::OnPrivacyDashboardLinkClicked(GtkWidget* widget) { 584 void ContentPageGtk::OnPrivacyDashboardLinkClicked(GtkWidget* widget) {
617 BrowserList::GetLastActive()->OpenPrivacyDashboardTabAndActivate(); 585 BrowserList::GetLastActive()->OpenPrivacyDashboardTabAndActivate();
618 } 586 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/gtk_util.cc ('k') | chrome/browser/ui/gtk/options/options_window_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698