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

Side by Side Diff: chrome/browser/ui/views/collected_cookies_win.cc

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

Powered by Google App Engine
This is Rietveld 408576698