| OLD | NEW |
| 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/gtk_chrome_cookie_view.h" | 5 #include "chrome/browser/ui/gtk/gtk_chrome_cookie_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/time_formatting.h" | 7 #include "base/i18n/time_formatting.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 9 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| 10 #include "ui/base/gtk/gtk_hig_constants.h" | |
| 11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
| 12 #include "ui/base/text/bytes_formatting.h" | 12 #include "ui/base/text/bytes_formatting.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 void InitBrowserDetailStyle(GtkWidget* entry, GtkStyle* label_style, | 16 void InitBrowserDetailStyle(GtkWidget* entry, GtkStyle* label_style, |
| 17 GtkStyle* dialog_style) { | 17 GtkStyle* dialog_style) { |
| 18 gtk_widget_modify_fg(entry, GTK_STATE_NORMAL, | 18 gtk_widget_modify_fg(entry, GTK_STATE_NORMAL, |
| 19 &label_style->fg[GTK_STATE_NORMAL]); | 19 &label_style->fg[GTK_STATE_NORMAL]); |
| 20 gtk_widget_modify_fg(entry, GTK_STATE_INSENSITIVE, | 20 gtk_widget_modify_fg(entry, GTK_STATE_INSENSITIVE, |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 288 |
| 289 void BuildWidgets(GtkChromeCookieView *self, gboolean editable_expiration) { | 289 void BuildWidgets(GtkChromeCookieView *self, gboolean editable_expiration) { |
| 290 self->table_box_ = gtk_vbox_new(FALSE, 0); | 290 self->table_box_ = gtk_vbox_new(FALSE, 0); |
| 291 gtk_widget_set_no_show_all(self->table_box_, TRUE); | 291 gtk_widget_set_no_show_all(self->table_box_, TRUE); |
| 292 | 292 |
| 293 // Cookie details. | 293 // Cookie details. |
| 294 self->cookie_details_table_ = gtk_table_new(7, 2, FALSE); | 294 self->cookie_details_table_ = gtk_table_new(7, 2, FALSE); |
| 295 gtk_container_add(GTK_CONTAINER(self->table_box_), | 295 gtk_container_add(GTK_CONTAINER(self->table_box_), |
| 296 self->cookie_details_table_); | 296 self->cookie_details_table_); |
| 297 gtk_table_set_col_spacing(GTK_TABLE(self->cookie_details_table_), 0, | 297 gtk_table_set_col_spacing(GTK_TABLE(self->cookie_details_table_), 0, |
| 298 ui::kLabelSpacing); | 298 gtk_util::kLabelSpacing); |
| 299 | 299 |
| 300 int row = 0; | 300 int row = 0; |
| 301 self->first_label_ = InitDetailRow(row++, IDS_COOKIES_COOKIE_NAME_LABEL, | 301 self->first_label_ = InitDetailRow(row++, IDS_COOKIES_COOKIE_NAME_LABEL, |
| 302 self->cookie_details_table_, &self->cookie_name_entry_); | 302 self->cookie_details_table_, &self->cookie_name_entry_); |
| 303 InitDetailRow(row++, IDS_COOKIES_COOKIE_CONTENT_LABEL, | 303 InitDetailRow(row++, IDS_COOKIES_COOKIE_CONTENT_LABEL, |
| 304 self->cookie_details_table_, &self->cookie_content_entry_); | 304 self->cookie_details_table_, &self->cookie_content_entry_); |
| 305 InitDetailRow(row++, IDS_COOKIES_COOKIE_DOMAIN_LABEL, | 305 InitDetailRow(row++, IDS_COOKIES_COOKIE_DOMAIN_LABEL, |
| 306 self->cookie_details_table_, &self->cookie_domain_entry_); | 306 self->cookie_details_table_, &self->cookie_domain_entry_); |
| 307 InitDetailRow(row++, IDS_COOKIES_COOKIE_PATH_LABEL, | 307 InitDetailRow(row++, IDS_COOKIES_COOKIE_PATH_LABEL, |
| 308 self->cookie_details_table_, &self->cookie_path_entry_); | 308 self->cookie_details_table_, &self->cookie_path_entry_); |
| 309 InitDetailRow(row++, IDS_COOKIES_COOKIE_SENDFOR_LABEL, | 309 InitDetailRow(row++, IDS_COOKIES_COOKIE_SENDFOR_LABEL, |
| 310 self->cookie_details_table_, &self->cookie_send_for_entry_); | 310 self->cookie_details_table_, &self->cookie_send_for_entry_); |
| 311 InitDetailRow(row++, IDS_COOKIES_COOKIE_CREATED_LABEL, | 311 InitDetailRow(row++, IDS_COOKIES_COOKIE_CREATED_LABEL, |
| 312 self->cookie_details_table_, &self->cookie_created_entry_); | 312 self->cookie_details_table_, &self->cookie_created_entry_); |
| 313 if (editable_expiration) { | 313 if (editable_expiration) { |
| 314 InitComboboxRow(row++, IDS_COOKIES_COOKIE_EXPIRES_LABEL, | 314 InitComboboxRow(row++, IDS_COOKIES_COOKIE_EXPIRES_LABEL, |
| 315 self->cookie_details_table_, | 315 self->cookie_details_table_, |
| 316 &self->cookie_expires_combobox_, | 316 &self->cookie_expires_combobox_, |
| 317 &self->cookie_expires_combobox_store_); | 317 &self->cookie_expires_combobox_store_); |
| 318 } else { | 318 } else { |
| 319 InitDetailRow(row++, IDS_COOKIES_COOKIE_EXPIRES_LABEL, | 319 InitDetailRow(row++, IDS_COOKIES_COOKIE_EXPIRES_LABEL, |
| 320 self->cookie_details_table_, &self->cookie_expires_entry_); | 320 self->cookie_details_table_, &self->cookie_expires_entry_); |
| 321 } | 321 } |
| 322 | 322 |
| 323 // Database details. | 323 // Database details. |
| 324 self->database_details_table_ = gtk_table_new(4, 2, FALSE); | 324 self->database_details_table_ = gtk_table_new(4, 2, FALSE); |
| 325 gtk_container_add(GTK_CONTAINER(self->table_box_), | 325 gtk_container_add(GTK_CONTAINER(self->table_box_), |
| 326 self->database_details_table_); | 326 self->database_details_table_); |
| 327 gtk_table_set_col_spacing(GTK_TABLE(self->database_details_table_), 0, | 327 gtk_table_set_col_spacing(GTK_TABLE(self->database_details_table_), 0, |
| 328 ui::kLabelSpacing); | 328 gtk_util::kLabelSpacing); |
| 329 | 329 |
| 330 InitDetailRow(row++, IDS_COOKIES_COOKIE_NAME_LABEL, | 330 InitDetailRow(row++, IDS_COOKIES_COOKIE_NAME_LABEL, |
| 331 self->database_details_table_, &self->database_name_entry_); | 331 self->database_details_table_, &self->database_name_entry_); |
| 332 InitDetailRow(row++, IDS_COOKIES_WEB_DATABASE_DESCRIPTION_LABEL, | 332 InitDetailRow(row++, IDS_COOKIES_WEB_DATABASE_DESCRIPTION_LABEL, |
| 333 self->database_details_table_, | 333 self->database_details_table_, |
| 334 &self->database_description_entry_); | 334 &self->database_description_entry_); |
| 335 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL, | 335 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL, |
| 336 self->database_details_table_, &self->database_size_entry_); | 336 self->database_details_table_, &self->database_size_entry_); |
| 337 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL, | 337 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL, |
| 338 self->database_details_table_, | 338 self->database_details_table_, |
| 339 &self->database_last_modified_entry_); | 339 &self->database_last_modified_entry_); |
| 340 | 340 |
| 341 // Local storage details. | 341 // Local storage details. |
| 342 self->local_storage_details_table_ = gtk_table_new(3, 2, FALSE); | 342 self->local_storage_details_table_ = gtk_table_new(3, 2, FALSE); |
| 343 gtk_container_add(GTK_CONTAINER(self->table_box_), | 343 gtk_container_add(GTK_CONTAINER(self->table_box_), |
| 344 self->local_storage_details_table_); | 344 self->local_storage_details_table_); |
| 345 gtk_table_set_col_spacing(GTK_TABLE(self->local_storage_details_table_), 0, | 345 gtk_table_set_col_spacing(GTK_TABLE(self->local_storage_details_table_), 0, |
| 346 ui::kLabelSpacing); | 346 gtk_util::kLabelSpacing); |
| 347 | 347 |
| 348 row = 0; | 348 row = 0; |
| 349 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL, | 349 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL, |
| 350 self->local_storage_details_table_, | 350 self->local_storage_details_table_, |
| 351 &self->local_storage_origin_entry_); | 351 &self->local_storage_origin_entry_); |
| 352 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL, | 352 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL, |
| 353 self->local_storage_details_table_, | 353 self->local_storage_details_table_, |
| 354 &self->local_storage_size_entry_); | 354 &self->local_storage_size_entry_); |
| 355 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL, | 355 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL, |
| 356 self->local_storage_details_table_, | 356 self->local_storage_details_table_, |
| 357 &self->local_storage_last_modified_entry_); | 357 &self->local_storage_last_modified_entry_); |
| 358 | 358 |
| 359 // AppCache details. | 359 // AppCache details. |
| 360 self->appcache_details_table_ = gtk_table_new(4, 2, FALSE); | 360 self->appcache_details_table_ = gtk_table_new(4, 2, FALSE); |
| 361 gtk_container_add(GTK_CONTAINER(self->table_box_), | 361 gtk_container_add(GTK_CONTAINER(self->table_box_), |
| 362 self->appcache_details_table_); | 362 self->appcache_details_table_); |
| 363 gtk_table_set_col_spacing(GTK_TABLE(self->appcache_details_table_), 0, | 363 gtk_table_set_col_spacing(GTK_TABLE(self->appcache_details_table_), 0, |
| 364 ui::kLabelSpacing); | 364 gtk_util::kLabelSpacing); |
| 365 | 365 |
| 366 row = 0; | 366 row = 0; |
| 367 InitDetailRow(row++, IDS_COOKIES_APPLICATION_CACHE_MANIFEST_LABEL, | 367 InitDetailRow(row++, IDS_COOKIES_APPLICATION_CACHE_MANIFEST_LABEL, |
| 368 self->appcache_details_table_, | 368 self->appcache_details_table_, |
| 369 &self->appcache_manifest_entry_); | 369 &self->appcache_manifest_entry_); |
| 370 InitDetailRow(row++, IDS_COOKIES_SIZE_LABEL, | 370 InitDetailRow(row++, IDS_COOKIES_SIZE_LABEL, |
| 371 self->appcache_details_table_, &self->appcache_size_entry_); | 371 self->appcache_details_table_, &self->appcache_size_entry_); |
| 372 InitDetailRow(row++, IDS_COOKIES_COOKIE_CREATED_LABEL, | 372 InitDetailRow(row++, IDS_COOKIES_COOKIE_CREATED_LABEL, |
| 373 self->appcache_details_table_, &self->appcache_created_entry_); | 373 self->appcache_details_table_, &self->appcache_created_entry_); |
| 374 InitDetailRow(row++, IDS_COOKIES_LAST_ACCESSED_LABEL, | 374 InitDetailRow(row++, IDS_COOKIES_LAST_ACCESSED_LABEL, |
| 375 self->appcache_details_table_, | 375 self->appcache_details_table_, |
| 376 &self->appcache_last_accessed_entry_); | 376 &self->appcache_last_accessed_entry_); |
| 377 | 377 |
| 378 // IndexedDB details. | 378 // IndexedDB details. |
| 379 self->indexed_db_details_table_ = gtk_table_new(4, 2, FALSE); | 379 self->indexed_db_details_table_ = gtk_table_new(4, 2, FALSE); |
| 380 gtk_container_add(GTK_CONTAINER(self->table_box_), | 380 gtk_container_add(GTK_CONTAINER(self->table_box_), |
| 381 self->indexed_db_details_table_); | 381 self->indexed_db_details_table_); |
| 382 gtk_table_set_col_spacing(GTK_TABLE(self->indexed_db_details_table_), 0, | 382 gtk_table_set_col_spacing(GTK_TABLE(self->indexed_db_details_table_), 0, |
| 383 ui::kLabelSpacing); | 383 gtk_util::kLabelSpacing); |
| 384 | 384 |
| 385 row = 0; | 385 row = 0; |
| 386 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL, | 386 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL, |
| 387 self->indexed_db_details_table_, | 387 self->indexed_db_details_table_, |
| 388 &self->indexed_db_origin_entry_); | 388 &self->indexed_db_origin_entry_); |
| 389 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL, | 389 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL, |
| 390 self->indexed_db_details_table_, &self->indexed_db_size_entry_); | 390 self->indexed_db_details_table_, &self->indexed_db_size_entry_); |
| 391 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL, | 391 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL, |
| 392 self->indexed_db_details_table_, | 392 self->indexed_db_details_table_, |
| 393 &self->indexed_db_last_modified_entry_); | 393 &self->indexed_db_last_modified_entry_); |
| 394 | 394 |
| 395 // Local storage item. | 395 // Local storage item. |
| 396 self->local_storage_item_table_ = gtk_table_new(3, 2, FALSE); | 396 self->local_storage_item_table_ = gtk_table_new(3, 2, FALSE); |
| 397 gtk_container_add(GTK_CONTAINER(self->table_box_), | 397 gtk_container_add(GTK_CONTAINER(self->table_box_), |
| 398 self->local_storage_item_table_); | 398 self->local_storage_item_table_); |
| 399 gtk_table_set_col_spacing(GTK_TABLE(self->local_storage_item_table_), 0, | 399 gtk_table_set_col_spacing(GTK_TABLE(self->local_storage_item_table_), 0, |
| 400 ui::kLabelSpacing); | 400 gtk_util::kLabelSpacing); |
| 401 | 401 |
| 402 row = 0; | 402 row = 0; |
| 403 InitDetailRow(row++, IDS_COOKIES_COOKIE_DOMAIN_LABEL, | 403 InitDetailRow(row++, IDS_COOKIES_COOKIE_DOMAIN_LABEL, |
| 404 self->local_storage_item_table_, | 404 self->local_storage_item_table_, |
| 405 &self->local_storage_item_origin_entry_); | 405 &self->local_storage_item_origin_entry_); |
| 406 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_KEY_LABEL, | 406 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_KEY_LABEL, |
| 407 self->local_storage_item_table_, | 407 self->local_storage_item_table_, |
| 408 &self->local_storage_item_key_entry_); | 408 &self->local_storage_item_key_entry_); |
| 409 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_VALUE_LABEL, | 409 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_VALUE_LABEL, |
| 410 self->local_storage_item_table_, | 410 self->local_storage_item_table_, |
| 411 &self->local_storage_item_value_entry_); | 411 &self->local_storage_item_value_entry_); |
| 412 | 412 |
| 413 // Database accessed prompt. | 413 // Database accessed prompt. |
| 414 self->database_accessed_table_ = gtk_table_new(2, 2, FALSE); | 414 self->database_accessed_table_ = gtk_table_new(2, 2, FALSE); |
| 415 gtk_container_add(GTK_CONTAINER(self->table_box_), | 415 gtk_container_add(GTK_CONTAINER(self->table_box_), |
| 416 self->database_accessed_table_); | 416 self->database_accessed_table_); |
| 417 gtk_table_set_col_spacing(GTK_TABLE(self->local_storage_item_table_), 0, | 417 gtk_table_set_col_spacing(GTK_TABLE(self->local_storage_item_table_), 0, |
| 418 ui::kLabelSpacing); | 418 gtk_util::kLabelSpacing); |
| 419 | 419 |
| 420 row = 0; | 420 row = 0; |
| 421 InitDetailRow(row++, IDS_COOKIES_COOKIE_DOMAIN_LABEL, | 421 InitDetailRow(row++, IDS_COOKIES_COOKIE_DOMAIN_LABEL, |
| 422 self->database_accessed_table_, | 422 self->database_accessed_table_, |
| 423 &self->database_accessed_origin_entry_); | 423 &self->database_accessed_origin_entry_); |
| 424 InitDetailRow(row++, IDS_COOKIES_WEB_DATABASE_NAME, | 424 InitDetailRow(row++, IDS_COOKIES_WEB_DATABASE_NAME, |
| 425 self->database_accessed_table_, | 425 self->database_accessed_table_, |
| 426 &self->database_accessed_name_entry_); | 426 &self->database_accessed_name_entry_); |
| 427 InitDetailRow(row++, IDS_COOKIES_WEB_DATABASE_DESCRIPTION_LABEL, | 427 InitDetailRow(row++, IDS_COOKIES_WEB_DATABASE_DESCRIPTION_LABEL, |
| 428 self->database_accessed_table_, | 428 self->database_accessed_table_, |
| 429 &self->database_accessed_description_entry_); | 429 &self->database_accessed_description_entry_); |
| 430 InitDetailRow(row++, IDS_COOKIES_SIZE_LABEL, | 430 InitDetailRow(row++, IDS_COOKIES_SIZE_LABEL, |
| 431 self->database_accessed_table_, | 431 self->database_accessed_table_, |
| 432 &self->database_accessed_size_entry_); | 432 &self->database_accessed_size_entry_); |
| 433 | 433 |
| 434 // AppCache created prompt. | 434 // AppCache created prompt. |
| 435 self->appcache_created_table_ = gtk_table_new(1, 2, FALSE); | 435 self->appcache_created_table_ = gtk_table_new(1, 2, FALSE); |
| 436 gtk_container_add(GTK_CONTAINER(self->table_box_), | 436 gtk_container_add(GTK_CONTAINER(self->table_box_), |
| 437 self->appcache_created_table_); | 437 self->appcache_created_table_); |
| 438 gtk_table_set_col_spacing(GTK_TABLE(self->appcache_created_table_), 0, | 438 gtk_table_set_col_spacing(GTK_TABLE(self->appcache_created_table_), 0, |
| 439 ui::kLabelSpacing); | 439 gtk_util::kLabelSpacing); |
| 440 row = 0; | 440 row = 0; |
| 441 InitDetailRow(row++, IDS_COOKIES_APPLICATION_CACHE_MANIFEST_LABEL, | 441 InitDetailRow(row++, IDS_COOKIES_APPLICATION_CACHE_MANIFEST_LABEL, |
| 442 self->appcache_created_table_, | 442 self->appcache_created_table_, |
| 443 &self->appcache_created_manifest_entry_); | 443 &self->appcache_created_manifest_entry_); |
| 444 | 444 |
| 445 gtk_frame_set_shadow_type(GTK_FRAME(self), GTK_SHADOW_ETCHED_IN); | 445 gtk_frame_set_shadow_type(GTK_FRAME(self), GTK_SHADOW_ETCHED_IN); |
| 446 gtk_container_add(GTK_CONTAINER(self), self->table_box_); | 446 gtk_container_add(GTK_CONTAINER(self), self->table_box_); |
| 447 } | 447 } |
| 448 | 448 |
| 449 GtkWidget* gtk_chrome_cookie_view_new(gboolean editable_expiration) { | 449 GtkWidget* gtk_chrome_cookie_view_new(gboolean editable_expiration) { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 int store_size = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL); | 654 int store_size = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL); |
| 655 if (store_size == 1) | 655 if (store_size == 1) |
| 656 return false; | 656 return false; |
| 657 | 657 |
| 658 DCHECK_EQ(2, store_size); | 658 DCHECK_EQ(2, store_size); |
| 659 | 659 |
| 660 int selected = gtk_combo_box_get_active(GTK_COMBO_BOX( | 660 int selected = gtk_combo_box_get_active(GTK_COMBO_BOX( |
| 661 self->cookie_expires_combobox_)); | 661 self->cookie_expires_combobox_)); |
| 662 return selected == 1; | 662 return selected == 1; |
| 663 } | 663 } |
| OLD | NEW |