| 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/infobars/infobar_tab_helper.h" | 10 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 11 #include "chrome/browser/prefs/pref_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" | 13 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
| 13 #include "chrome/browser/ui/constrained_window.h" | 14 #include "chrome/browser/ui/constrained_window.h" |
| 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 15 #include "chrome/browser/ui/views/constrained_window_views.h" | 16 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 16 #include "chrome/browser/ui/views/cookie_info_view.h" | 17 #include "chrome/browser/ui/views/cookie_info_view.h" |
| 17 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/pref_names.h" |
| 18 #include "content/public/browser/notification_details.h" | 20 #include "content/public/browser/notification_details.h" |
| 19 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
| 20 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 21 #include "grit/locale_settings.h" | 23 #include "grit/locale_settings.h" |
| 22 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
| 25 #include "ui/gfx/color_utils.h" | 27 #include "ui/gfx/color_utils.h" |
| 26 #include "views/controls/button/text_button.h" | 28 #include "views/controls/button/text_button.h" |
| 27 #include "views/controls/image_view.h" | 29 #include "views/controls/image_view.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 layout->StartRow(0, single_column_layout_id); | 282 layout->StartRow(0, single_column_layout_id); |
| 281 layout->AddView(block_allowed_button_, 1, 1, GridLayout::LEADING, | 283 layout->AddView(block_allowed_button_, 1, 1, GridLayout::LEADING, |
| 282 GridLayout::CENTER); | 284 GridLayout::CENTER); |
| 283 | 285 |
| 284 return pane; | 286 return pane; |
| 285 } | 287 } |
| 286 | 288 |
| 287 views::View* CollectedCookiesWin::CreateBlockedPane() { | 289 views::View* CollectedCookiesWin::CreateBlockedPane() { |
| 288 TabSpecificContentSettings* content_settings = wrapper_->content_settings(); | 290 TabSpecificContentSettings* content_settings = wrapper_->content_settings(); |
| 289 | 291 |
| 290 HostContentSettingsMap* host_content_settings_map = | 292 PrefService* prefs = wrapper_->profile()->GetPrefs(); |
| 291 wrapper_->profile()->GetHostContentSettingsMap(); | |
| 292 | 293 |
| 293 // Create the controls that go into the pane. | 294 // Create the controls that go into the pane. |
| 294 blocked_label_ = new views::Label( | 295 blocked_label_ = new views::Label( |
| 295 l10n_util::GetStringUTF16( | 296 l10n_util::GetStringUTF16( |
| 296 host_content_settings_map->BlockThirdPartyCookies() ? | 297 prefs->GetBoolean(prefs::kBlockThirdPartyCookies) ? |
| 297 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED : | 298 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED : |
| 298 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL)); | 299 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL)); |
| 299 blocked_label_->SetMultiLine(true); | 300 blocked_label_->SetMultiLine(true); |
| 300 blocked_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 301 blocked_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 301 blocked_cookies_tree_model_.reset( | 302 blocked_cookies_tree_model_.reset( |
| 302 content_settings->GetBlockedCookiesTreeModel()); | 303 content_settings->GetBlockedCookiesTreeModel()); |
| 303 blocked_cookies_tree_ = new views::TreeView(); | 304 blocked_cookies_tree_ = new views::TreeView(); |
| 304 blocked_cookies_tree_->SetModel(blocked_cookies_tree_model_.get()); | 305 blocked_cookies_tree_->SetModel(blocked_cookies_tree_model_.get()); |
| 305 blocked_cookies_tree_->SetController(this); | 306 blocked_cookies_tree_->SetController(this); |
| 306 blocked_cookies_tree_->SetRootShown(false); | 307 blocked_cookies_tree_->SetRootShown(false); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 } else { | 475 } else { |
| 475 cookie_info_view_->ClearCookieDisplay(); | 476 cookie_info_view_->ClearCookieDisplay(); |
| 476 } | 477 } |
| 477 } | 478 } |
| 478 | 479 |
| 479 void CollectedCookiesWin::AddContentException(views::TreeView* tree_view, | 480 void CollectedCookiesWin::AddContentException(views::TreeView* tree_view, |
| 480 ContentSetting setting) { | 481 ContentSetting setting) { |
| 481 CookieTreeOriginNode* origin_node = | 482 CookieTreeOriginNode* origin_node = |
| 482 static_cast<CookieTreeOriginNode*>(tree_view->GetSelectedNode()); | 483 static_cast<CookieTreeOriginNode*>(tree_view->GetSelectedNode()); |
| 483 Profile* profile = wrapper_->profile(); | 484 Profile* profile = wrapper_->profile(); |
| 484 origin_node->CreateContentException(profile->GetHostContentSettingsMap(), | 485 origin_node->CreateContentException(CookieSettings::GetForProfile(profile), |
| 485 setting); | 486 setting); |
| 486 infobar_->UpdateVisibility(true, setting, origin_node->GetTitle()); | 487 infobar_->UpdateVisibility(true, setting, origin_node->GetTitle()); |
| 487 gfx::Rect bounds = GetWidget()->GetClientAreaScreenBounds(); | 488 gfx::Rect bounds = GetWidget()->GetClientAreaScreenBounds(); |
| 488 #if defined(USE_AURA) | 489 #if defined(USE_AURA) |
| 489 // TODO(beng): convert the conversion to use views conversion methods. | 490 // TODO(beng): convert the conversion to use views conversion methods. |
| 490 NOTIMPLEMENTED(); | 491 NOTIMPLEMENTED(); |
| 491 #else | 492 #else |
| 492 // NativeWidgetWin::GetBounds returns the bounds relative to the parent | 493 // NativeWidgetWin::GetBounds returns the bounds relative to the parent |
| 493 // window, while NativeWidgetWin::SetBounds wants screen coordinates. Do the | 494 // window, while NativeWidgetWin::SetBounds wants screen coordinates. Do the |
| 494 // translation here until http://crbug.com/52851 is fixed. | 495 // translation here until http://crbug.com/52851 is fixed. |
| 495 POINT topleft = {bounds.x(), bounds.y()}; | 496 POINT topleft = {bounds.x(), bounds.y()}; |
| 496 MapWindowPoints(HWND_DESKTOP, wrapper_->tab_contents()->GetNativeView(), | 497 MapWindowPoints(HWND_DESKTOP, wrapper_->tab_contents()->GetNativeView(), |
| 497 &topleft, 1); | 498 &topleft, 1); |
| 498 gfx::Size size = GetWidget()->GetRootView()->GetPreferredSize(); | 499 gfx::Size size = GetWidget()->GetRootView()->GetPreferredSize(); |
| 499 bounds.SetRect(topleft.x, topleft.y, size.width(), size.height()); | 500 bounds.SetRect(topleft.x, topleft.y, size.width(), size.height()); |
| 500 GetWidget()->SetBounds(bounds); | 501 GetWidget()->SetBounds(bounds); |
| 501 #endif | 502 #endif |
| 502 status_changed_ = true; | 503 status_changed_ = true; |
| 503 } | 504 } |
| 504 | 505 |
| 505 /////////////////////////////////////////////////////////////////////////////// | 506 /////////////////////////////////////////////////////////////////////////////// |
| 506 // content::NotificationObserver implementation. | 507 // content::NotificationObserver implementation. |
| 507 | 508 |
| 508 void CollectedCookiesWin::Observe(int type, | 509 void CollectedCookiesWin::Observe(int type, |
| 509 const content::NotificationSource& source, | 510 const content::NotificationSource& source, |
| 510 const content::NotificationDetails& details) { | 511 const content::NotificationDetails& details) { |
| 511 DCHECK(type == chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN); | 512 DCHECK(type == chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN); |
| 512 window_->CloseConstrainedWindow(); | 513 window_->CloseConstrainedWindow(); |
| 513 } | 514 } |
| OLD | NEW |