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

Side by Side Diff: chrome/browser/ui/views/options/cookies_view.cc

Issue 6452011: Rework tree APIs to reflect Google style and more const-correctness.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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/options/cookies_view.h" 5 #include "chrome/browser/ui/views/options/cookies_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // CookiesView::InfoPanelView 66 // CookiesView::InfoPanelView
67 // Overridden to handle layout of the various info views. 67 // Overridden to handle layout of the various info views.
68 // 68 //
69 // This view is a child of the CookiesView and participates 69 // This view is a child of the CookiesView and participates
70 // in its GridLayout. The various info views are all children 70 // in its GridLayout. The various info views are all children
71 // of this view. Only one child is expected to be visible at a time. 71 // of this view. Only one child is expected to be visible at a time.
72 72
73 class CookiesView::InfoPanelView : public views::View { 73 class CookiesView::InfoPanelView : public views::View {
74 public: 74 public:
75 virtual void Layout() { 75 virtual void Layout() {
76 int child_count = GetChildViewCount(); 76 for (int i = 0; i < child_count(); ++i)
77 for (int i = 0; i < child_count; ++i)
78 GetChildViewAt(i)->SetBounds(0, 0, width(), height()); 77 GetChildViewAt(i)->SetBounds(0, 0, width(), height());
79 } 78 }
80 79
81 virtual gfx::Size GetPreferredSize() { 80 virtual gfx::Size GetPreferredSize() {
82 DCHECK(GetChildViewCount() > 0); 81 DCHECK(has_children());
83 return GetChildViewAt(0)->GetPreferredSize(); 82 return GetChildViewAt(0)->GetPreferredSize();
84 } 83 }
85 }; 84 };
86 85
87 /////////////////////////////////////////////////////////////////////////////// 86 ///////////////////////////////////////////////////////////////////////////////
88 // CookiesView, public: 87 // CookiesView, public:
89 88
90 // static 89 // static
91 void CookiesView::ShowCookiesWindow(Profile* profile) { 90 void CookiesView::ShowCookiesWindow(Profile* profile) {
92 if (!instance_) { 91 if (!instance_) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 views::View* CookiesView::GetContentsView() { 169 views::View* CookiesView::GetContentsView() {
171 return this; 170 return this;
172 } 171 }
173 172
174 /////////////////////////////////////////////////////////////////////////////// 173 ///////////////////////////////////////////////////////////////////////////////
175 // CookiesView, views::View overrides: 174 // CookiesView, views::View overrides:
176 175
177 void CookiesView::Layout() { 176 void CookiesView::Layout() {
178 // Lay out the Remove/Remove All buttons in the parent view. 177 // Lay out the Remove/Remove All buttons in the parent view.
179 gfx::Size ps = remove_button_->GetPreferredSize(); 178 gfx::Size ps = remove_button_->GetPreferredSize();
180 gfx::Rect parent_bounds = GetParent()->GetContentsBounds(); 179 gfx::Rect parent_bounds = parent()->GetContentsBounds();
181 int y_buttons = 180 int y_buttons =
182 parent_bounds.bottom() - ps.height() - views::kButtonVEdgeMargin; 181 parent_bounds.bottom() - ps.height() - views::kButtonVEdgeMargin;
183 182
184 remove_button_->SetBounds(kPanelHorizMargin, y_buttons, ps.width(), 183 remove_button_->SetBounds(kPanelHorizMargin, y_buttons, ps.width(),
185 ps.height()); 184 ps.height());
186 185
187 ps = remove_all_button_->GetPreferredSize(); 186 ps = remove_all_button_->GetPreferredSize();
188 int remove_all_x = remove_button_->x() + remove_button_->width() + 187 int remove_all_x = remove_button_->x() + remove_button_->width() +
189 kRelatedControlHorizontalSpacing; 188 kRelatedControlHorizontalSpacing;
190 remove_all_button_->SetBounds(remove_all_x, y_buttons, ps.width(), 189 remove_all_button_->SetBounds(remove_all_x, y_buttons, ps.width(),
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 cookies_tree_->set_auto_expand_children(true); 354 cookies_tree_->set_auto_expand_children(true);
356 layout->AddView(cookies_tree_); 355 layout->AddView(cookies_tree_);
357 356
358 cookies_tree_->SetController(this); 357 cookies_tree_->SetController(this);
359 358
360 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); 359 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
361 layout->StartRow(0, single_column_layout_id); 360 layout->StartRow(0, single_column_layout_id);
362 layout->AddView(info_panel_); 361 layout->AddView(info_panel_);
363 362
364 // Add the Remove/Remove All buttons to the ClientView 363 // Add the Remove/Remove All buttons to the ClientView
365 View* parent = GetParent(); 364 parent()->AddChildView(remove_button_);
366 parent->AddChildView(remove_button_); 365 parent()->AddChildView(remove_all_button_);
367 parent->AddChildView(remove_all_button_);
368 if (!cookies_tree_model_.get()->GetRoot()->GetChildCount()) { 366 if (!cookies_tree_model_.get()->GetRoot()->GetChildCount()) {
369 UpdateForEmptyState(); 367 UpdateForEmptyState();
370 } else { 368 } else {
371 UpdateVisibleDetailedInfo(cookie_info_view_); 369 UpdateVisibleDetailedInfo(cookie_info_view_);
372 UpdateRemoveButtonsState(); 370 UpdateRemoveButtonsState();
373 } 371 }
374 } 372 }
375 373
376 void CookiesView::ResetSearchQuery() { 374 void CookiesView::ResetSearchQuery() {
377 search_field_->SetText(std::wstring()); 375 search_field_->SetText(std::wstring());
(...skipping 15 matching lines...) Expand all
393 GetTotalNodeCount() > 1); 391 GetTotalNodeCount() > 1);
394 } 392 }
395 393
396 void CookiesView::UpdateVisibleDetailedInfo(views::View* view) { 394 void CookiesView::UpdateVisibleDetailedInfo(views::View* view) {
397 cookie_info_view_->SetVisible(view == cookie_info_view_); 395 cookie_info_view_->SetVisible(view == cookie_info_view_);
398 database_info_view_->SetVisible(view == database_info_view_); 396 database_info_view_->SetVisible(view == database_info_view_);
399 local_storage_info_view_->SetVisible(view == local_storage_info_view_); 397 local_storage_info_view_->SetVisible(view == local_storage_info_view_);
400 appcache_info_view_->SetVisible(view == appcache_info_view_); 398 appcache_info_view_->SetVisible(view == appcache_info_view_);
401 indexed_db_info_view_->SetVisible(view == indexed_db_info_view_); 399 indexed_db_info_view_->SetVisible(view == indexed_db_info_view_);
402 } 400 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/options/content_settings_window_view.cc ('k') | chrome/browser/ui/views/options/exceptions_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698