| 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/views/collected_cookies_win.h" | 5 #include "chrome/browser/ui/views/collected_cookies_win.h" |
| 6 | 6 |
| 7 #include "chrome/browser/content_settings/host_content_settings_map.h" | 7 #include "chrome/browser/content_settings/cookie_settings.h" |
| 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 9 #include "chrome/browser/cookies_tree_model.h" | 9 #include "chrome/browser/cookies_tree_model.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" | 11 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
| 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 13 #include "chrome/browser/ui/views/constrained_window_views.h" | 13 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 14 #include "chrome/browser/ui/views/cookie_info_view.h" | 14 #include "chrome/browser/ui/views/cookie_info_view.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "content/common/notification_details.h" | 16 #include "content/common/notification_details.h" |
| 17 #include "content/common/notification_source.h" | 17 #include "content/common/notification_source.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 GridLayout::CENTER); | 284 GridLayout::CENTER); |
| 285 | 285 |
| 286 return pane; | 286 return pane; |
| 287 } | 287 } |
| 288 | 288 |
| 289 views::View* CollectedCookiesWin::CreateBlockedPane() { | 289 views::View* CollectedCookiesWin::CreateBlockedPane() { |
| 290 TabContentsWrapper* wrapper = | 290 TabContentsWrapper* wrapper = |
| 291 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_); | 291 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_); |
| 292 TabSpecificContentSettings* content_settings = wrapper->content_settings(); | 292 TabSpecificContentSettings* content_settings = wrapper->content_settings(); |
| 293 | 293 |
| 294 HostContentSettingsMap* host_content_settings_map = | 294 CookieSettings* cookie_settings = |
| 295 wrapper->profile()->GetHostContentSettingsMap(); | 295 CookieSettings::GetForProfile(wrapper->profile()); |
| 296 | 296 |
| 297 // Create the controls that go into the pane. | 297 // Create the controls that go into the pane. |
| 298 blocked_label_ = new views::Label( | 298 blocked_label_ = new views::Label( |
| 299 UTF16ToWide(l10n_util::GetStringUTF16( | 299 UTF16ToWide(l10n_util::GetStringUTF16( |
| 300 host_content_settings_map->BlockThirdPartyCookies() ? | 300 cookie_settings->ShouldBlockThirdPartyCookies() ? |
| 301 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED : | 301 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED : |
| 302 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL))); | 302 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL))); |
| 303 blocked_label_->SetMultiLine(true); | 303 blocked_label_->SetMultiLine(true); |
| 304 blocked_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 304 blocked_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 305 blocked_cookies_tree_model_.reset( | 305 blocked_cookies_tree_model_.reset( |
| 306 content_settings->GetBlockedCookiesTreeModel()); | 306 content_settings->GetBlockedCookiesTreeModel()); |
| 307 blocked_cookies_tree_ = new views::TreeView(); | 307 blocked_cookies_tree_ = new views::TreeView(); |
| 308 blocked_cookies_tree_->SetModel(blocked_cookies_tree_model_.get()); | 308 blocked_cookies_tree_->SetModel(blocked_cookies_tree_model_.get()); |
| 309 blocked_cookies_tree_->SetController(this); | 309 blocked_cookies_tree_->SetController(this); |
| 310 blocked_cookies_tree_->SetRootShown(false); | 310 blocked_cookies_tree_->SetRootShown(false); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 cookie_info_view_->ClearCookieDisplay(); | 479 cookie_info_view_->ClearCookieDisplay(); |
| 480 } | 480 } |
| 481 } | 481 } |
| 482 | 482 |
| 483 void CollectedCookiesWin::AddContentException(views::TreeView* tree_view, | 483 void CollectedCookiesWin::AddContentException(views::TreeView* tree_view, |
| 484 ContentSetting setting) { | 484 ContentSetting setting) { |
| 485 CookieTreeOriginNode* origin_node = | 485 CookieTreeOriginNode* origin_node = |
| 486 static_cast<CookieTreeOriginNode*>(tree_view->GetSelectedNode()); | 486 static_cast<CookieTreeOriginNode*>(tree_view->GetSelectedNode()); |
| 487 Profile* profile = | 487 Profile* profile = |
| 488 Profile::FromBrowserContext(tab_contents_->browser_context()); | 488 Profile::FromBrowserContext(tab_contents_->browser_context()); |
| 489 origin_node->CreateContentException(profile->GetHostContentSettingsMap(), | 489 origin_node->CreateContentException(CookieSettings::GetForProfile(profile), |
| 490 setting); | 490 setting); |
| 491 infobar_->UpdateVisibility(true, setting, origin_node->GetTitle()); | 491 infobar_->UpdateVisibility(true, setting, origin_node->GetTitle()); |
| 492 gfx::Rect bounds = GetWidget()->GetClientAreaScreenBounds(); | 492 gfx::Rect bounds = GetWidget()->GetClientAreaScreenBounds(); |
| 493 // NativeWidgetWin::GetBounds returns the bounds relative to the parent | 493 // NativeWidgetWin::GetBounds returns the bounds relative to the parent |
| 494 // window, while NativeWidgetWin::SetBounds wants screen coordinates. Do the | 494 // window, while NativeWidgetWin::SetBounds wants screen coordinates. Do the |
| 495 // translation here until http://crbug.com/52851 is fixed. | 495 // translation here until http://crbug.com/52851 is fixed. |
| 496 POINT topleft = {bounds.x(), bounds.y()}; | 496 POINT topleft = {bounds.x(), bounds.y()}; |
| 497 MapWindowPoints(HWND_DESKTOP, tab_contents_->GetNativeView(), &topleft, 1); | 497 MapWindowPoints(HWND_DESKTOP, tab_contents_->GetNativeView(), &topleft, 1); |
| 498 gfx::Size size = GetWidget()->GetRootView()->GetPreferredSize(); | 498 gfx::Size size = GetWidget()->GetRootView()->GetPreferredSize(); |
| 499 bounds.SetRect(topleft.x, topleft.y, size.width(), size.height()); | 499 bounds.SetRect(topleft.x, topleft.y, size.width(), size.height()); |
| 500 GetWidget()->SetBounds(bounds); | 500 GetWidget()->SetBounds(bounds); |
| 501 status_changed_ = true; | 501 status_changed_ = true; |
| 502 } | 502 } |
| 503 | 503 |
| 504 /////////////////////////////////////////////////////////////////////////////// | 504 /////////////////////////////////////////////////////////////////////////////// |
| 505 // NotificationObserver implementation. | 505 // NotificationObserver implementation. |
| 506 | 506 |
| 507 void CollectedCookiesWin::Observe(int type, | 507 void CollectedCookiesWin::Observe(int type, |
| 508 const NotificationSource& source, | 508 const NotificationSource& source, |
| 509 const NotificationDetails& details) { | 509 const NotificationDetails& details) { |
| 510 DCHECK(type == chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN); | 510 DCHECK(type == chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN); |
| 511 window_->CloseConstrainedWindow(); | 511 window_->CloseConstrainedWindow(); |
| 512 } | 512 } |
| OLD | NEW |