OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_views.h" | 5 #include "chrome/browser/ui/views/collected_cookies_views.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 8 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
9 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 9 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
10 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 10 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 /////////////////////////////////////////////////////////////////////////////// | 192 /////////////////////////////////////////////////////////////////////////////// |
193 // CollectedCookiesViews, public: | 193 // CollectedCookiesViews, public: |
194 | 194 |
195 CollectedCookiesViews::CollectedCookiesViews(content::WebContents* web_contents) | 195 CollectedCookiesViews::CollectedCookiesViews(content::WebContents* web_contents) |
196 : web_contents_(web_contents), | 196 : web_contents_(web_contents), |
197 allowed_label_(NULL), | 197 allowed_label_(NULL), |
198 blocked_label_(NULL), | 198 blocked_label_(NULL), |
199 allowed_cookies_tree_(NULL), | 199 allowed_cookies_tree_(NULL), |
200 blocked_cookies_tree_(NULL), | 200 blocked_cookies_tree_(NULL), |
201 block_allowed_button_(NULL), | 201 block_allowed_button_(NULL), |
| 202 delete_allowed_button_(NULL), |
202 allow_blocked_button_(NULL), | 203 allow_blocked_button_(NULL), |
203 for_session_blocked_button_(NULL), | 204 for_session_blocked_button_(NULL), |
204 cookie_info_view_(NULL), | 205 cookie_info_view_(NULL), |
205 infobar_(NULL), | 206 infobar_(NULL), |
206 status_changed_(false) { | 207 status_changed_(false) { |
207 TabSpecificContentSettings* content_settings = | 208 TabSpecificContentSettings* content_settings = |
208 TabSpecificContentSettings::FromWebContents(web_contents); | 209 TabSpecificContentSettings::FromWebContents(web_contents); |
209 registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, | 210 registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, |
210 content::Source<TabSpecificContentSettings>(content_settings)); | 211 content::Source<TabSpecificContentSettings>(content_settings)); |
211 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 212 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 #else | 263 #else |
263 return views::WidgetDelegate::GetModalType(); | 264 return views::WidgetDelegate::GetModalType(); |
264 #endif | 265 #endif |
265 } | 266 } |
266 | 267 |
267 /////////////////////////////////////////////////////////////////////////////// | 268 /////////////////////////////////////////////////////////////////////////////// |
268 // CollectedCookiesViews, views::ButtonListener implementation: | 269 // CollectedCookiesViews, views::ButtonListener implementation: |
269 | 270 |
270 void CollectedCookiesViews::ButtonPressed(views::Button* sender, | 271 void CollectedCookiesViews::ButtonPressed(views::Button* sender, |
271 const ui::Event& event) { | 272 const ui::Event& event) { |
272 if (sender == block_allowed_button_) | 273 if (sender == block_allowed_button_) { |
273 AddContentException(allowed_cookies_tree_, CONTENT_SETTING_BLOCK); | 274 AddContentException(allowed_cookies_tree_, CONTENT_SETTING_BLOCK); |
274 else if (sender == allow_blocked_button_) | 275 } else if (sender == delete_allowed_button_) { |
| 276 allowed_cookies_tree_model_->DeleteCookieNode( |
| 277 static_cast<CookieTreeNode*>(allowed_cookies_tree_->GetSelectedNode())); |
| 278 } else if (sender == allow_blocked_button_) { |
275 AddContentException(blocked_cookies_tree_, CONTENT_SETTING_ALLOW); | 279 AddContentException(blocked_cookies_tree_, CONTENT_SETTING_ALLOW); |
276 else if (sender == for_session_blocked_button_) | 280 } else if (sender == for_session_blocked_button_) { |
277 AddContentException(blocked_cookies_tree_, CONTENT_SETTING_SESSION_ONLY); | 281 AddContentException(blocked_cookies_tree_, CONTENT_SETTING_SESSION_ONLY); |
| 282 } |
278 } | 283 } |
279 | 284 |
280 /////////////////////////////////////////////////////////////////////////////// | 285 /////////////////////////////////////////////////////////////////////////////// |
281 // CollectedCookiesViews, views::TabbedPaneListener implementation: | 286 // CollectedCookiesViews, views::TabbedPaneListener implementation: |
282 | 287 |
283 void CollectedCookiesViews::TabSelectedAt(int index) { | 288 void CollectedCookiesViews::TabSelectedAt(int index) { |
284 EnableControls(); | 289 EnableControls(); |
285 ShowCookieInfo(); | 290 ShowCookieInfo(); |
286 } | 291 } |
287 | 292 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 allowed_cookies_tree_->SetModel(allowed_cookies_tree_model_.get()); | 376 allowed_cookies_tree_->SetModel(allowed_cookies_tree_model_.get()); |
372 allowed_cookies_tree_->SetRootShown(false); | 377 allowed_cookies_tree_->SetRootShown(false); |
373 allowed_cookies_tree_->SetEditable(false); | 378 allowed_cookies_tree_->SetEditable(false); |
374 allowed_cookies_tree_->set_auto_expand_children(true); | 379 allowed_cookies_tree_->set_auto_expand_children(true); |
375 allowed_cookies_tree_->SetController(this); | 380 allowed_cookies_tree_->SetController(this); |
376 | 381 |
377 block_allowed_button_ = new views::LabelButton(this, | 382 block_allowed_button_ = new views::LabelButton(this, |
378 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_BLOCK_BUTTON)); | 383 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_BLOCK_BUTTON)); |
379 block_allowed_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 384 block_allowed_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
380 | 385 |
| 386 delete_allowed_button_ = new views::LabelButton(this, |
| 387 l10n_util::GetStringUTF16(IDS_COOKIES_REMOVE_LABEL)); |
| 388 delete_allowed_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| 389 |
381 // Create the view that holds all the controls together. This will be the | 390 // Create the view that holds all the controls together. This will be the |
382 // pane added to the tabbed pane. | 391 // pane added to the tabbed pane. |
383 using views::GridLayout; | 392 using views::GridLayout; |
384 | 393 |
385 views::View* pane = new views::View(); | 394 views::View* pane = new views::View(); |
386 GridLayout* layout = GridLayout::CreatePanel(pane); | 395 GridLayout* layout = GridLayout::CreatePanel(pane); |
387 layout->SetInsets(kVPanelPadding, views::kButtonHEdgeMarginNew, | 396 layout->SetInsets(kVPanelPadding, views::kButtonHEdgeMarginNew, |
388 kVPanelPadding, views::kButtonHEdgeMarginNew); | 397 kVPanelPadding, views::kButtonHEdgeMarginNew); |
389 pane->SetLayoutManager(layout); | 398 pane->SetLayoutManager(layout); |
390 | 399 |
391 const int single_column_layout_id = 0; | 400 const int single_column_layout_id = 0; |
392 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); | 401 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); |
393 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, | 402 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, |
394 GridLayout::USE_PREF, 0, 0); | 403 GridLayout::USE_PREF, 0, 0); |
395 | 404 |
| 405 const int three_columns_layout_id = 1; |
| 406 column_set = layout->AddColumnSet(three_columns_layout_id); |
| 407 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, |
| 408 GridLayout::USE_PREF, 0, 0); |
| 409 column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); |
| 410 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, |
| 411 GridLayout::USE_PREF, 0, 0); |
| 412 |
396 layout->StartRow(0, single_column_layout_id); | 413 layout->StartRow(0, single_column_layout_id); |
397 layout->AddView(allowed_label_); | 414 layout->AddView(allowed_label_); |
398 layout->AddPaddingRow(0, kLabelBottomPadding); | 415 layout->AddPaddingRow(0, kLabelBottomPadding); |
399 | 416 |
400 layout->StartRow(1, single_column_layout_id); | 417 layout->StartRow(1, single_column_layout_id); |
401 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1, | 418 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1, |
402 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, | 419 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, |
403 kTreeViewHeight); | 420 kTreeViewHeight); |
404 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 421 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
405 | 422 |
406 layout->StartRow(0, single_column_layout_id); | 423 layout->StartRow(0, three_columns_layout_id); |
407 layout->AddView(block_allowed_button_, 1, 1, GridLayout::LEADING, | 424 layout->AddView(block_allowed_button_); |
408 GridLayout::CENTER); | 425 layout->AddView(delete_allowed_button_); |
409 | 426 |
410 return pane; | 427 return pane; |
411 } | 428 } |
412 | 429 |
413 views::View* CollectedCookiesViews::CreateBlockedPane() { | 430 views::View* CollectedCookiesViews::CreateBlockedPane() { |
414 TabSpecificContentSettings* content_settings = | 431 TabSpecificContentSettings* content_settings = |
415 TabSpecificContentSettings::FromWebContents(web_contents_); | 432 TabSpecificContentSettings::FromWebContents(web_contents_); |
416 | 433 |
417 Profile* profile = | 434 Profile* profile = |
418 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 435 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 ui::TreeModelNode* node = allowed_cookies_tree_->GetSelectedNode(); | 513 ui::TreeModelNode* node = allowed_cookies_tree_->GetSelectedNode(); |
497 if (node) { | 514 if (node) { |
498 CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node); | 515 CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node); |
499 if (cookie_node->GetDetailedInfo().node_type == | 516 if (cookie_node->GetDetailedInfo().node_type == |
500 CookieTreeNode::DetailedInfo::TYPE_HOST) { | 517 CookieTreeNode::DetailedInfo::TYPE_HOST) { |
501 enable_allowed_buttons = static_cast<CookieTreeHostNode*>( | 518 enable_allowed_buttons = static_cast<CookieTreeHostNode*>( |
502 cookie_node)->CanCreateContentException(); | 519 cookie_node)->CanCreateContentException(); |
503 } | 520 } |
504 } | 521 } |
505 block_allowed_button_->SetEnabled(enable_allowed_buttons); | 522 block_allowed_button_->SetEnabled(enable_allowed_buttons); |
| 523 delete_allowed_button_->SetEnabled(node != NULL); |
506 | 524 |
507 bool enable_blocked_buttons = false; | 525 bool enable_blocked_buttons = false; |
508 node = blocked_cookies_tree_->GetSelectedNode(); | 526 node = blocked_cookies_tree_->GetSelectedNode(); |
509 if (node) { | 527 if (node) { |
510 CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node); | 528 CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node); |
511 if (cookie_node->GetDetailedInfo().node_type == | 529 if (cookie_node->GetDetailedInfo().node_type == |
512 CookieTreeNode::DetailedInfo::TYPE_HOST) { | 530 CookieTreeNode::DetailedInfo::TYPE_HOST) { |
513 enable_blocked_buttons = static_cast<CookieTreeHostNode*>( | 531 enable_blocked_buttons = static_cast<CookieTreeHostNode*>( |
514 cookie_node)->CanCreateContentException(); | 532 cookie_node)->CanCreateContentException(); |
515 } | 533 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 /////////////////////////////////////////////////////////////////////////////// | 572 /////////////////////////////////////////////////////////////////////////////// |
555 // CollectedCookiesViews, content::NotificationObserver implementation: | 573 // CollectedCookiesViews, content::NotificationObserver implementation: |
556 | 574 |
557 void CollectedCookiesViews::Observe( | 575 void CollectedCookiesViews::Observe( |
558 int type, | 576 int type, |
559 const content::NotificationSource& source, | 577 const content::NotificationSource& source, |
560 const content::NotificationDetails& details) { | 578 const content::NotificationDetails& details) { |
561 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); | 579 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); |
562 window_->Close(); | 580 window_->Close(); |
563 } | 581 } |
OLD | NEW |