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

Side by Side Diff: chrome/browser/ui/gtk/collected_cookies_gtk.cc

Issue 8383004: Adding CookieSettings for storing cookie content settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing the rebase. Created 9 years, 1 month 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
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/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/public/browser/notification_source.h" 22 #include "content/public/browser/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
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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 CookieTreeNode::DetailedInfo::TYPE_ORIGIN) 454 CookieTreeNode::DetailedInfo::TYPE_ORIGIN)
454 continue; 455 continue;
455 CookieTreeOriginNode* origin_node = static_cast<CookieTreeOriginNode*>( 456 CookieTreeOriginNode* origin_node = static_cast<CookieTreeOriginNode*>(
456 node); 457 node);
457 if (origin_node->CanCreateContentException()) { 458 if (origin_node->CanCreateContentException()) {
458 if (!last_domain_name.empty()) 459 if (!last_domain_name.empty())
459 multiple_domains_added = true; 460 multiple_domains_added = true;
460 last_domain_name = origin_node->GetTitle(); 461 last_domain_name = origin_node->GetTitle();
461 Profile* profile = wrapper_->profile(); 462 Profile* profile = wrapper_->profile();
462 origin_node->CreateContentException( 463 origin_node->CreateContentException(
463 profile->GetHostContentSettingsMap(), setting); 464 CookieSettings::GetForProfile(profile), setting);
464 } 465 }
465 } 466 }
466 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); 467 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL);
467 g_list_free(paths); 468 g_list_free(paths);
468 if (last_domain_name.empty()) { 469 if (last_domain_name.empty()) {
469 gtk_widget_hide(infobar_); 470 gtk_widget_hide(infobar_);
470 } else { 471 } else {
471 gtk_label_set_text( 472 gtk_label_set_text(
472 GTK_LABEL(infobar_label_), GetInfobarLabel( 473 GTK_LABEL(infobar_label_), GetInfobarLabel(
473 setting, multiple_domains_added, last_domain_name).c_str()); 474 setting, multiple_domains_added, last_domain_name).c_str());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); 507 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this);
507 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE); 508 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE);
508 g_signal_handlers_unblock_by_func( 509 g_signal_handlers_unblock_by_func(
509 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); 510 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this);
510 } 511 }
511 512
512 void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) { 513 void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) {
513 EnableControls(); 514 EnableControls();
514 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); 515 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_)));
515 } 516 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/content_settings/content_setting_bubble_model.cc ('k') | chrome/browser/ui/views/collected_cookies_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698