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 "chrome/browser/ui/gtk/gtk_util.h" |
10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.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 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 void InitBrowserDetailStyle(GtkWidget* entry, GtkStyle* label_style, | 16 void InitBrowserDetailStyle(GtkWidget* entry, GtkStyle* label_style, |
16 GtkStyle* dialog_style) { | 17 GtkStyle* dialog_style) { |
17 gtk_widget_modify_fg(entry, GTK_STATE_NORMAL, | 18 gtk_widget_modify_fg(entry, GTK_STATE_NORMAL, |
18 &label_style->fg[GTK_STATE_NORMAL]); | 19 &label_style->fg[GTK_STATE_NORMAL]); |
19 gtk_widget_modify_fg(entry, GTK_STATE_INSENSITIVE, | 20 gtk_widget_modify_fg(entry, GTK_STATE_INSENSITIVE, |
20 &label_style->fg[GTK_STATE_INSENSITIVE]); | 21 &label_style->fg[GTK_STATE_INSENSITIVE]); |
21 // GTK_NO_WINDOW widgets like GtkLabel don't draw their own background, so we | 22 // GTK_NO_WINDOW widgets like GtkLabel don't draw their own background, so we |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 | 534 |
534 gtk_entry_set_text( | 535 gtk_entry_set_text( |
535 GTK_ENTRY(self->database_name_entry_), | 536 GTK_ENTRY(self->database_name_entry_), |
536 database_info.database_name.empty() ? | 537 database_info.database_name.empty() ? |
537 l10n_util::GetStringUTF8( | 538 l10n_util::GetStringUTF8( |
538 IDS_COOKIES_WEB_DATABASE_UNNAMED_NAME).c_str() : | 539 IDS_COOKIES_WEB_DATABASE_UNNAMED_NAME).c_str() : |
539 database_info.database_name.c_str()); | 540 database_info.database_name.c_str()); |
540 gtk_entry_set_text(GTK_ENTRY(self->database_description_entry_), | 541 gtk_entry_set_text(GTK_ENTRY(self->database_description_entry_), |
541 database_info.description.c_str()); | 542 database_info.description.c_str()); |
542 gtk_entry_set_text(GTK_ENTRY(self->database_size_entry_), | 543 gtk_entry_set_text(GTK_ENTRY(self->database_size_entry_), |
543 UTF16ToUTF8(FormatBytes( | 544 UTF16ToUTF8(ui::FormatBytes( |
544 database_info.size, | 545 database_info.size, |
545 GetByteDisplayUnits(database_info.size), | 546 ui::DATA_UNITS_NATURAL, |
546 true)).c_str()); | 547 true)).c_str()); |
547 gtk_entry_set_text(GTK_ENTRY(self->database_last_modified_entry_), | 548 gtk_entry_set_text(GTK_ENTRY(self->database_last_modified_entry_), |
548 UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime( | 549 UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime( |
549 database_info.last_modified)).c_str()); | 550 database_info.last_modified)).c_str()); |
550 SetDatabaseDetailsSensitivity(self, TRUE); | 551 SetDatabaseDetailsSensitivity(self, TRUE); |
551 } | 552 } |
552 | 553 |
553 // Switches the display to showing the passed in local storage data. | 554 // Switches the display to showing the passed in local storage data. |
554 void gtk_chrome_cookie_view_display_local_storage( | 555 void gtk_chrome_cookie_view_display_local_storage( |
555 GtkChromeCookieView* self, | 556 GtkChromeCookieView* self, |
556 const BrowsingDataLocalStorageHelper::LocalStorageInfo& | 557 const BrowsingDataLocalStorageHelper::LocalStorageInfo& |
557 local_storage_info) { | 558 local_storage_info) { |
558 UpdateVisibleDetailedInfo(self, self->local_storage_details_table_); | 559 UpdateVisibleDetailedInfo(self, self->local_storage_details_table_); |
559 | 560 |
560 gtk_entry_set_text(GTK_ENTRY(self->local_storage_origin_entry_), | 561 gtk_entry_set_text(GTK_ENTRY(self->local_storage_origin_entry_), |
561 local_storage_info.origin.c_str()); | 562 local_storage_info.origin.c_str()); |
562 gtk_entry_set_text(GTK_ENTRY(self->local_storage_size_entry_), | 563 gtk_entry_set_text(GTK_ENTRY(self->local_storage_size_entry_), |
563 UTF16ToUTF8(FormatBytes( | 564 UTF16ToUTF8(ui::FormatBytes( |
564 local_storage_info.size, | 565 local_storage_info.size, |
565 GetByteDisplayUnits(local_storage_info.size), | 566 ui::DATA_UNITS_NATURAL, |
566 true)).c_str()); | 567 true)).c_str()); |
567 gtk_entry_set_text(GTK_ENTRY(self->local_storage_last_modified_entry_), | 568 gtk_entry_set_text(GTK_ENTRY(self->local_storage_last_modified_entry_), |
568 UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime( | 569 UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime( |
569 local_storage_info.last_modified)).c_str()); | 570 local_storage_info.last_modified)).c_str()); |
570 SetLocalStorageDetailsSensitivity(self, TRUE); | 571 SetLocalStorageDetailsSensitivity(self, TRUE); |
571 } | 572 } |
572 | 573 |
573 // Switches the display to showing the passed in app cache. | 574 // Switches the display to showing the passed in app cache. |
574 void gtk_chrome_cookie_view_display_app_cache( | 575 void gtk_chrome_cookie_view_display_app_cache( |
575 GtkChromeCookieView* self, | 576 GtkChromeCookieView* self, |
576 const appcache::AppCacheInfo& info) { | 577 const appcache::AppCacheInfo& info) { |
577 UpdateVisibleDetailedInfo(self, self->appcache_details_table_); | 578 UpdateVisibleDetailedInfo(self, self->appcache_details_table_); |
578 | 579 |
579 gtk_entry_set_text(GTK_ENTRY(self->appcache_manifest_entry_), | 580 gtk_entry_set_text(GTK_ENTRY(self->appcache_manifest_entry_), |
580 info.manifest_url.spec().c_str()); | 581 info.manifest_url.spec().c_str()); |
581 gtk_entry_set_text(GTK_ENTRY(self->appcache_size_entry_), | 582 gtk_entry_set_text(GTK_ENTRY(self->appcache_size_entry_), |
582 UTF16ToUTF8(FormatBytes( | 583 UTF16ToUTF8(ui::FormatBytes( |
583 info.size, | 584 info.size, |
584 GetByteDisplayUnits(info.size), | 585 ui::DATA_UNITS_NATURAL, |
585 true)).c_str()); | 586 true)).c_str()); |
586 gtk_entry_set_text(GTK_ENTRY(self->appcache_created_entry_), | 587 gtk_entry_set_text(GTK_ENTRY(self->appcache_created_entry_), |
587 UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime( | 588 UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime( |
588 info.creation_time)).c_str()); | 589 info.creation_time)).c_str()); |
589 gtk_entry_set_text(GTK_ENTRY(self->appcache_last_accessed_entry_), | 590 gtk_entry_set_text(GTK_ENTRY(self->appcache_last_accessed_entry_), |
590 UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime( | 591 UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime( |
591 info.last_access_time)).c_str()); | 592 info.last_access_time)).c_str()); |
592 SetAppCacheDetailsSensitivity(self, TRUE); | 593 SetAppCacheDetailsSensitivity(self, TRUE); |
593 } | 594 } |
594 | 595 |
595 // Switches the display to showing the passed in IndexedDB data. | 596 // Switches the display to showing the passed in IndexedDB data. |
596 void gtk_chrome_cookie_view_display_indexed_db( | 597 void gtk_chrome_cookie_view_display_indexed_db( |
597 GtkChromeCookieView* self, | 598 GtkChromeCookieView* self, |
598 const BrowsingDataIndexedDBHelper::IndexedDBInfo& indexed_db_info) { | 599 const BrowsingDataIndexedDBHelper::IndexedDBInfo& indexed_db_info) { |
599 UpdateVisibleDetailedInfo(self, self->indexed_db_details_table_); | 600 UpdateVisibleDetailedInfo(self, self->indexed_db_details_table_); |
600 | 601 |
601 gtk_entry_set_text(GTK_ENTRY(self->indexed_db_origin_entry_), | 602 gtk_entry_set_text(GTK_ENTRY(self->indexed_db_origin_entry_), |
602 indexed_db_info.origin.c_str()); | 603 indexed_db_info.origin.c_str()); |
603 gtk_entry_set_text(GTK_ENTRY(self->indexed_db_size_entry_), | 604 gtk_entry_set_text(GTK_ENTRY(self->indexed_db_size_entry_), |
604 UTF16ToUTF8(FormatBytes( | 605 UTF16ToUTF8(ui::FormatBytes( |
605 indexed_db_info.size, | 606 indexed_db_info.size, |
606 GetByteDisplayUnits(indexed_db_info.size), | 607 ui::DATA_UNITS_NATURAL, |
607 true)).c_str()); | 608 true)).c_str()); |
608 gtk_entry_set_text(GTK_ENTRY(self->indexed_db_last_modified_entry_), | 609 gtk_entry_set_text(GTK_ENTRY(self->indexed_db_last_modified_entry_), |
609 UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime( | 610 UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime( |
610 indexed_db_info.last_modified)).c_str()); | 611 indexed_db_info.last_modified)).c_str()); |
611 SetLocalStorageDetailsSensitivity(self, TRUE); | 612 SetLocalStorageDetailsSensitivity(self, TRUE); |
612 } | 613 } |
613 | 614 |
614 void gtk_chrome_cookie_view_display_local_storage_item( | 615 void gtk_chrome_cookie_view_display_local_storage_item( |
615 GtkChromeCookieView* self, | 616 GtkChromeCookieView* self, |
616 const std::string& host, | 617 const std::string& host, |
(...skipping 18 matching lines...) Expand all Loading... |
635 unsigned long estimated_size) { | 636 unsigned long estimated_size) { |
636 UpdateVisibleDetailedInfo(self, self->database_accessed_table_); | 637 UpdateVisibleDetailedInfo(self, self->database_accessed_table_); |
637 | 638 |
638 gtk_entry_set_text(GTK_ENTRY(self->database_accessed_origin_entry_), | 639 gtk_entry_set_text(GTK_ENTRY(self->database_accessed_origin_entry_), |
639 host.c_str()); | 640 host.c_str()); |
640 gtk_entry_set_text(GTK_ENTRY(self->database_accessed_name_entry_), | 641 gtk_entry_set_text(GTK_ENTRY(self->database_accessed_name_entry_), |
641 UTF16ToUTF8(database_name).c_str()); | 642 UTF16ToUTF8(database_name).c_str()); |
642 gtk_entry_set_text(GTK_ENTRY(self->database_accessed_description_entry_), | 643 gtk_entry_set_text(GTK_ENTRY(self->database_accessed_description_entry_), |
643 UTF16ToUTF8(display_name).c_str()); | 644 UTF16ToUTF8(display_name).c_str()); |
644 gtk_entry_set_text(GTK_ENTRY(self->database_accessed_size_entry_), | 645 gtk_entry_set_text(GTK_ENTRY(self->database_accessed_size_entry_), |
645 UTF16ToUTF8(FormatBytes( | 646 UTF16ToUTF8(ui::FormatBytes( |
646 estimated_size, | 647 estimated_size, |
647 GetByteDisplayUnits(estimated_size), | 648 ui::DATA_UNITS_NATURAL, |
648 true)).c_str()); | 649 true)).c_str()); |
649 SetDatabaseAccessedSensitivity(self, TRUE); | 650 SetDatabaseAccessedSensitivity(self, TRUE); |
650 } | 651 } |
651 | 652 |
652 void gtk_chrome_cookie_view_display_appcache_created( | 653 void gtk_chrome_cookie_view_display_appcache_created( |
653 GtkChromeCookieView* self, | 654 GtkChromeCookieView* self, |
654 const GURL& manifest_url) { | 655 const GURL& manifest_url) { |
655 UpdateVisibleDetailedInfo(self, self->appcache_created_table_); | 656 UpdateVisibleDetailedInfo(self, self->appcache_created_table_); |
656 gtk_entry_set_text(GTK_ENTRY(self->appcache_created_manifest_entry_), | 657 gtk_entry_set_text(GTK_ENTRY(self->appcache_created_manifest_entry_), |
657 manifest_url.spec().c_str()); | 658 manifest_url.spec().c_str()); |
658 SetAppCacheCreatedSensitivity(self, TRUE); | 659 SetAppCacheCreatedSensitivity(self, TRUE); |
659 } | 660 } |
660 | 661 |
661 bool gtk_chrome_cookie_view_session_expires(GtkChromeCookieView* self) { | 662 bool gtk_chrome_cookie_view_session_expires(GtkChromeCookieView* self) { |
662 if (self->cookie_expires_entry_) | 663 if (self->cookie_expires_entry_) |
663 return false; | 664 return false; |
664 | 665 |
665 GtkListStore* store = self->cookie_expires_combobox_store_; | 666 GtkListStore* store = self->cookie_expires_combobox_store_; |
666 int store_size = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL); | 667 int store_size = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL); |
667 if (store_size == 1) | 668 if (store_size == 1) |
668 return false; | 669 return false; |
669 | 670 |
670 DCHECK_EQ(2, store_size); | 671 DCHECK_EQ(2, store_size); |
671 | 672 |
672 int selected = gtk_combo_box_get_active(GTK_COMBO_BOX( | 673 int selected = gtk_combo_box_get_active(GTK_COMBO_BOX( |
673 self->cookie_expires_combobox_)); | 674 self->cookie_expires_combobox_)); |
674 return selected == 1; | 675 return selected == 1; |
675 } | 676 } |
OLD | NEW |