| 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/collected_cookies_gtk.h" | 5 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/cookie_settings.h" |
| 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 11 #include "chrome/browser/cookies_tree_model.h" | 11 #include "chrome/browser/cookies_tree_model.h" |
| 12 #include "chrome/browser/infobars/infobar_tab_helper.h" | 12 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" | 15 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
| 15 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" | 16 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" |
| 16 #include "chrome/browser/ui/gtk/gtk_chrome_cookie_view.h" | 17 #include "chrome/browser/ui/gtk/gtk_chrome_cookie_view.h" |
| 17 #include "chrome/browser/ui/gtk/gtk_util.h" | 18 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 19 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/pref_names.h" |
| 20 #include "content/common/notification_source.h" | 22 #include "content/common/notification_source.h" |
| 21 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 22 #include "ui/base/gtk/gtk_hig_constants.h" | 24 #include "ui/base/gtk/gtk_hig_constants.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 // Width and height of the cookie tree view. | 28 // Width and height of the cookie tree view. |
| 27 const int kTreeViewWidth = 450; | 29 const int kTreeViewWidth = 450; |
| 28 const int kTreeViewHeight = 150; | 30 const int kTreeViewHeight = 150; |
| 29 | 31 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 233 |
| 232 // Wrap the vbox inside an hbox so that we can specify padding along the | 234 // Wrap the vbox inside an hbox so that we can specify padding along the |
| 233 // horizontal axis. | 235 // horizontal axis. |
| 234 GtkWidget* box = gtk_hbox_new(FALSE, 0); | 236 GtkWidget* box = gtk_hbox_new(FALSE, 0); |
| 235 gtk_box_pack_start(GTK_BOX(box), cookie_list_vbox, TRUE, TRUE, | 237 gtk_box_pack_start(GTK_BOX(box), cookie_list_vbox, TRUE, TRUE, |
| 236 ui::kControlSpacing); | 238 ui::kControlSpacing); |
| 237 return box; | 239 return box; |
| 238 } | 240 } |
| 239 | 241 |
| 240 GtkWidget* CollectedCookiesGtk::CreateBlockedPane() { | 242 GtkWidget* CollectedCookiesGtk::CreateBlockedPane() { |
| 241 HostContentSettingsMap* host_content_settings_map = | 243 PrefService* prefs = wrapper_->profile()->GetPrefs(); |
| 242 wrapper_->profile()->GetHostContentSettingsMap(); | |
| 243 | 244 |
| 244 GtkWidget* cookie_list_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing); | 245 GtkWidget* cookie_list_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing); |
| 245 | 246 |
| 246 GtkWidget* label = gtk_label_new( | 247 GtkWidget* label = gtk_label_new( |
| 247 l10n_util::GetStringUTF8( | 248 l10n_util::GetStringUTF8( |
| 248 host_content_settings_map->BlockThirdPartyCookies() ? | 249 prefs->GetBoolean(prefs::kBlockThirdPartyCookies) ? |
| 249 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED : | 250 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED : |
| 250 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL).c_str()); | 251 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL).c_str()); |
| 251 gtk_widget_set_size_request(label, kTreeViewWidth, -1); | 252 gtk_widget_set_size_request(label, kTreeViewWidth, -1); |
| 252 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | 253 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
| 253 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | 254 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| 254 gtk_box_pack_start(GTK_BOX(cookie_list_vbox), label, TRUE, TRUE, | 255 gtk_box_pack_start(GTK_BOX(cookie_list_vbox), label, TRUE, TRUE, |
| 255 ui::kControlSpacing); | 256 ui::kControlSpacing); |
| 256 | 257 |
| 257 GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL); | 258 GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL); |
| 258 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), | 259 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 CookieTreeNode::DetailedInfo::TYPE_ORIGIN) | 453 CookieTreeNode::DetailedInfo::TYPE_ORIGIN) |
| 453 continue; | 454 continue; |
| 454 CookieTreeOriginNode* origin_node = static_cast<CookieTreeOriginNode*>( | 455 CookieTreeOriginNode* origin_node = static_cast<CookieTreeOriginNode*>( |
| 455 node); | 456 node); |
| 456 if (origin_node->CanCreateContentException()) { | 457 if (origin_node->CanCreateContentException()) { |
| 457 if (!last_domain_name.empty()) | 458 if (!last_domain_name.empty()) |
| 458 multiple_domains_added = true; | 459 multiple_domains_added = true; |
| 459 last_domain_name = origin_node->GetTitle(); | 460 last_domain_name = origin_node->GetTitle(); |
| 460 Profile* profile = wrapper_->profile(); | 461 Profile* profile = wrapper_->profile(); |
| 461 origin_node->CreateContentException( | 462 origin_node->CreateContentException( |
| 462 profile->GetHostContentSettingsMap(), setting); | 463 CookieSettings::GetForProfile(profile), setting); |
| 463 } | 464 } |
| 464 } | 465 } |
| 465 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); | 466 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); |
| 466 g_list_free(paths); | 467 g_list_free(paths); |
| 467 if (last_domain_name.empty()) { | 468 if (last_domain_name.empty()) { |
| 468 gtk_widget_hide(infobar_); | 469 gtk_widget_hide(infobar_); |
| 469 } else { | 470 } else { |
| 470 gtk_label_set_text( | 471 gtk_label_set_text( |
| 471 GTK_LABEL(infobar_label_), GetInfobarLabel( | 472 GTK_LABEL(infobar_label_), GetInfobarLabel( |
| 472 setting, multiple_domains_added, last_domain_name).c_str()); | 473 setting, multiple_domains_added, last_domain_name).c_str()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); | 506 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); |
| 506 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE); | 507 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE); |
| 507 g_signal_handlers_unblock_by_func( | 508 g_signal_handlers_unblock_by_func( |
| 508 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); | 509 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); |
| 509 } | 510 } |
| 510 | 511 |
| 511 void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) { | 512 void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) { |
| 512 EnableControls(); | 513 EnableControls(); |
| 513 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); | 514 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); |
| 514 } | 515 } |
| OLD | NEW |