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/gtk/website_settings_popup_gtk.h" | 5 #include "chrome/browser/ui/gtk/website_settings_popup_gtk.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/certificate_viewer.h" | 10 #include "chrome/browser/certificate_viewer.h" |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 // Add a label for the permission type. | 379 // Add a label for the permission type. |
380 GtkWidget* label = CreateTextLabel(UTF16ToUTF8( | 380 GtkWidget* label = CreateTextLabel(UTF16ToUTF8( |
381 WebsiteSettingsUI::PermissionTypeToUIString(permission->type)), 250); | 381 WebsiteSettingsUI::PermissionTypeToUIString(permission->type)), 250); |
382 GtkWidget* hbox = gtk_hbox_new(FALSE, 0); | 382 GtkWidget* hbox = gtk_hbox_new(FALSE, 0); |
383 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | 383 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
384 | 384 |
385 GtkListStore* store = | 385 GtkListStore* store = |
386 gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT); | 386 gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT); |
387 GtkTreeIter iter; | 387 GtkTreeIter iter; |
388 // Add option for permission "Global Default" to the combobox model. | 388 // Add option for permission "Global Default" to the combobox model. |
389 std::string setting_str = l10n_util::GetStringFUTF8( | 389 std::string setting_str; |
390 IDS_WEBSITE_SETTINGS_DEFAULT_PERMISSION_LABEL, | 390 switch (permission->default_setting) { |
391 WebsiteSettingsUI::PermissionValueToUIString( | 391 case CONTENT_SETTING_ALLOW: |
392 permission->default_setting)); | 392 setting_str = l10n_util::GetStringUTF8( |
| 393 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ALLOW); |
| 394 break; |
| 395 case CONTENT_SETTING_BLOCK: |
| 396 setting_str = l10n_util::GetStringUTF8( |
| 397 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_BLOCK); |
| 398 break; |
| 399 case CONTENT_SETTING_ASK: |
| 400 setting_str = l10n_util::GetStringUTF8( |
| 401 IDS_WEBSITE_SETTINGS_MENU_ITEM_DEFAULT_ASK); |
| 402 break; |
| 403 default: |
| 404 break; |
| 405 } |
393 gtk_list_store_append(store, &iter); | 406 gtk_list_store_append(store, &iter); |
394 gtk_list_store_set(store, &iter, 0, setting_str.c_str(), 1, | 407 gtk_list_store_set(store, &iter, 0, setting_str.c_str(), 1, |
395 CONTENT_SETTING_DEFAULT, 2, permission->type, -1); | 408 CONTENT_SETTING_DEFAULT, 2, permission->type, -1); |
396 GtkWidget* combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); | 409 GtkWidget* combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); |
397 // Add option for permission "Allow" to the combobox model. | 410 // Add option for permission "Allow" to the combobox model. |
398 setting_str = l10n_util::GetStringFUTF8( | 411 setting_str = l10n_util::GetStringUTF8( |
399 IDS_WEBSITE_SETTINGS_PERMISSION_LABEL, | 412 IDS_WEBSITE_SETTINGS_MENU_ITEM_ALLOW); |
400 WebsiteSettingsUI::PermissionValueToUIString(CONTENT_SETTING_ALLOW)); | |
401 gtk_list_store_append(store, &iter); | 413 gtk_list_store_append(store, &iter); |
402 gtk_list_store_set(store, &iter, 0, setting_str.c_str(), 1, | 414 gtk_list_store_set(store, &iter, 0, setting_str.c_str(), 1, |
403 CONTENT_SETTING_ALLOW, 2, permission->type, -1); | 415 CONTENT_SETTING_ALLOW, 2, permission->type, -1); |
404 // The content settings type fullscreen does not support the concept of | 416 // The content settings type fullscreen does not support the concept of |
405 // blocking. | 417 // blocking. |
406 if (permission->type != CONTENT_SETTINGS_TYPE_FULLSCREEN) { | 418 if (permission->type != CONTENT_SETTINGS_TYPE_FULLSCREEN) { |
407 // Add option for permission "BLOCK" to the combobox model. | 419 // Add option for permission "BLOCK" to the combobox model. |
408 setting_str = l10n_util::GetStringFUTF8( | 420 setting_str = l10n_util::GetStringUTF8( |
409 IDS_WEBSITE_SETTINGS_PERMISSION_LABEL, | 421 IDS_WEBSITE_SETTINGS_MENU_ITEM_BLOCK); |
410 WebsiteSettingsUI::PermissionValueToUIString(CONTENT_SETTING_BLOCK)); | |
411 gtk_list_store_append(store, &iter); | 422 gtk_list_store_append(store, &iter); |
412 gtk_list_store_set(store, &iter, 0, setting_str.c_str(), 1, | 423 gtk_list_store_set(store, &iter, 0, setting_str.c_str(), 1, |
413 CONTENT_SETTING_BLOCK, 2, permission->type, -1); | 424 CONTENT_SETTING_BLOCK, 2, permission->type, -1); |
414 } | 425 } |
415 // Remove reference to the store to prevent leaking. | 426 // Remove reference to the store to prevent leaking. |
416 g_object_unref(G_OBJECT(store)); | 427 g_object_unref(G_OBJECT(store)); |
417 | 428 |
418 GtkCellRenderer* cell = gtk_cell_renderer_text_new(); | 429 GtkCellRenderer* cell = gtk_cell_renderer_text_new(); |
419 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_box), cell, TRUE ); | 430 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_box), cell, TRUE ); |
420 gtk_cell_layout_set_attributes( | 431 gtk_cell_layout_set_attributes( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 presenter_->OnSitePermissionChanged(ContentSettingsType(type), | 520 presenter_->OnSitePermissionChanged(ContentSettingsType(type), |
510 ContentSetting(value)); | 521 ContentSetting(value)); |
511 } | 522 } |
512 | 523 |
513 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) { | 524 void WebsiteSettingsPopupGtk::OnViewCertLinkClicked(GtkWidget* widget) { |
514 DCHECK_NE(cert_id_, 0); | 525 DCHECK_NE(cert_id_, 0); |
515 ShowCertificateViewerByID( | 526 ShowCertificateViewerByID( |
516 tab_contents_->web_contents(), GTK_WINDOW(parent_), cert_id_); | 527 tab_contents_->web_contents(), GTK_WINDOW(parent_), cert_id_); |
517 bubble_->Close(); | 528 bubble_->Close(); |
518 } | 529 } |
OLD | NEW |