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/cookie_settings.h" |
| 10 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 11 #include "chrome/browser/content_settings/host_content_settings_map.h" |
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 12 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
11 #include "chrome/browser/cookies_tree_model.h" | 13 #include "chrome/browser/cookies_tree_model.h" |
12 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" | 15 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
14 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" | 16 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" |
15 #include "chrome/browser/ui/gtk/gtk_chrome_cookie_view.h" | 17 #include "chrome/browser/ui/gtk/gtk_chrome_cookie_view.h" |
16 #include "chrome/browser/ui/gtk/gtk_util.h" | 18 #include "chrome/browser/ui/gtk/gtk_util.h" |
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
18 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // horizontal axis. | 237 // horizontal axis. |
236 GtkWidget* box = gtk_hbox_new(FALSE, 0); | 238 GtkWidget* box = gtk_hbox_new(FALSE, 0); |
237 gtk_box_pack_start(GTK_BOX(box), cookie_list_vbox, TRUE, TRUE, | 239 gtk_box_pack_start(GTK_BOX(box), cookie_list_vbox, TRUE, TRUE, |
238 ui::kControlSpacing); | 240 ui::kControlSpacing); |
239 return box; | 241 return box; |
240 } | 242 } |
241 | 243 |
242 GtkWidget* CollectedCookiesGtk::CreateBlockedPane() { | 244 GtkWidget* CollectedCookiesGtk::CreateBlockedPane() { |
243 TabContentsWrapper* wrapper = | 245 TabContentsWrapper* wrapper = |
244 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_); | 246 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_); |
245 HostContentSettingsMap* host_content_settings_map = | 247 CookieSettings* cookie_settings = |
246 wrapper->profile()->GetHostContentSettingsMap(); | 248 CookieSettingsFactory::GetForProfile(wrapper->profile()); |
247 | 249 |
248 GtkWidget* cookie_list_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing); | 250 GtkWidget* cookie_list_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing); |
249 | 251 |
250 GtkWidget* label = gtk_label_new( | 252 GtkWidget* label = gtk_label_new( |
251 l10n_util::GetStringUTF8( | 253 l10n_util::GetStringUTF8( |
252 host_content_settings_map->BlockThirdPartyCookies() ? | 254 cookie_settings->BlockThirdPartyCookies() ? |
253 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED : | 255 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED : |
254 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL).c_str()); | 256 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL).c_str()); |
255 gtk_widget_set_size_request(label, kTreeViewWidth, -1); | 257 gtk_widget_set_size_request(label, kTreeViewWidth, -1); |
256 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | 258 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
257 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | 259 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
258 gtk_box_pack_start(GTK_BOX(cookie_list_vbox), label, TRUE, TRUE, | 260 gtk_box_pack_start(GTK_BOX(cookie_list_vbox), label, TRUE, TRUE, |
259 ui::kControlSpacing); | 261 ui::kControlSpacing); |
260 | 262 |
261 GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL); | 263 GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL); |
262 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), | 264 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 continue; | 459 continue; |
458 CookieTreeOriginNode* origin_node = static_cast<CookieTreeOriginNode*>( | 460 CookieTreeOriginNode* origin_node = static_cast<CookieTreeOriginNode*>( |
459 node); | 461 node); |
460 if (origin_node->CanCreateContentException()) { | 462 if (origin_node->CanCreateContentException()) { |
461 if (!last_domain_name.empty()) | 463 if (!last_domain_name.empty()) |
462 multiple_domains_added = true; | 464 multiple_domains_added = true; |
463 last_domain_name = origin_node->GetTitle(); | 465 last_domain_name = origin_node->GetTitle(); |
464 Profile* profile = | 466 Profile* profile = |
465 Profile::FromBrowserContext(tab_contents_->browser_context()); | 467 Profile::FromBrowserContext(tab_contents_->browser_context()); |
466 origin_node->CreateContentException( | 468 origin_node->CreateContentException( |
467 profile->GetHostContentSettingsMap(), setting); | 469 CookieSettingsFactory::GetForProfile(profile), setting); |
468 } | 470 } |
469 } | 471 } |
470 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); | 472 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); |
471 g_list_free(paths); | 473 g_list_free(paths); |
472 if (last_domain_name.empty()) { | 474 if (last_domain_name.empty()) { |
473 gtk_widget_hide(infobar_); | 475 gtk_widget_hide(infobar_); |
474 } else { | 476 } else { |
475 gtk_label_set_text( | 477 gtk_label_set_text( |
476 GTK_LABEL(infobar_label_), GetInfobarLabel( | 478 GTK_LABEL(infobar_label_), GetInfobarLabel( |
477 setting, multiple_domains_added, last_domain_name).c_str()); | 479 setting, multiple_domains_added, last_domain_name).c_str()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); | 512 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); |
511 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE); | 513 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE); |
512 g_signal_handlers_unblock_by_func( | 514 g_signal_handlers_unblock_by_func( |
513 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); | 515 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); |
514 } | 516 } |
515 | 517 |
516 void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) { | 518 void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) { |
517 EnableControls(); | 519 EnableControls(); |
518 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); | 520 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); |
519 } | 521 } |
OLD | NEW |