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 "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 7 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
8 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 8 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
9 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 9 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
10 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 10 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
11 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" | 11 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
12 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 12 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
13 #include "chrome/browser/browsing_data/browsing_data_server_bound_cert_helper.h" | 13 #include "chrome/browser/browsing_data/browsing_data_server_bound_cert_helper.h" |
14 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 14 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
15 #include "chrome/browser/content_settings/cookie_settings.h" | 15 #include "chrome/browser/content_settings/cookie_settings.h" |
16 #include "chrome/browser/content_settings/local_shared_objects_container.h" | 16 #include "chrome/browser/content_settings/local_shared_objects_container.h" |
17 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 17 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
18 #include "chrome/browser/infobars/infobar_tab_helper.h" | 18 #include "chrome/browser/infobars/infobar_tab_helper.h" |
19 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" | 21 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
22 #include "chrome/browser/ui/constrained_window.h" | 22 #include "chrome/browser/ui/constrained_window.h" |
| 23 #include "chrome/browser/ui/constrained_window_constants.h" |
23 #include "chrome/browser/ui/views/constrained_window_views.h" | 24 #include "chrome/browser/ui/views/constrained_window_views.h" |
24 #include "chrome/browser/ui/views/cookie_info_view.h" | 25 #include "chrome/browser/ui/views/cookie_info_view.h" |
25 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
| 27 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
27 #include "content/public/browser/notification_details.h" | 29 #include "content/public/browser/notification_details.h" |
28 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
29 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
30 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
31 #include "grit/locale_settings.h" | 33 #include "grit/locale_settings.h" |
32 #include "grit/theme_resources.h" | 34 #include "grit/theme_resources.h" |
33 #include "net/cookies/canonical_cookie.h" | 35 #include "net/cookies/canonical_cookie.h" |
34 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
35 #include "ui/base/resource/resource_bundle.h" | 37 #include "ui/base/resource/resource_bundle.h" |
36 #include "ui/gfx/color_utils.h" | 38 #include "ui/gfx/color_utils.h" |
| 39 #include "ui/views/controls/button/chrome_style.h" |
37 #include "ui/views/controls/button/text_button.h" | 40 #include "ui/views/controls/button/text_button.h" |
38 #include "ui/views/controls/image_view.h" | 41 #include "ui/views/controls/image_view.h" |
39 #include "ui/views/controls/label.h" | 42 #include "ui/views/controls/label.h" |
40 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" | 43 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" |
41 #include "ui/views/controls/tree/tree_view.h" | 44 #include "ui/views/controls/tree/tree_view.h" |
42 #include "ui/views/layout/box_layout.h" | 45 #include "ui/views/layout/box_layout.h" |
43 #include "ui/views/layout/grid_layout.h" | 46 #include "ui/views/layout/grid_layout.h" |
44 #include "ui/views/layout/layout_constants.h" | 47 #include "ui/views/layout/layout_constants.h" |
45 #include "ui/views/widget/widget.h" | 48 #include "ui/views/widget/widget.h" |
46 | 49 |
(...skipping 21 matching lines...) Expand all Loading... |
68 | 71 |
69 // Width of the infobar frame. | 72 // Width of the infobar frame. |
70 const int kInfobarBorderSize = 1; | 73 const int kInfobarBorderSize = 1; |
71 | 74 |
72 // Dimensions of the tree views. | 75 // Dimensions of the tree views. |
73 const int kTreeViewWidth = 400; | 76 const int kTreeViewWidth = 400; |
74 const int kTreeViewHeight = 125; | 77 const int kTreeViewHeight = 125; |
75 | 78 |
76 } // namespace | 79 } // namespace |
77 | 80 |
| 81 struct CollectedCookiesViews::LayoutParams { |
| 82 // Padding above the Block/Unblock button. |
| 83 int button_top_padding; |
| 84 // Padding between the button and the cookie info view. |
| 85 int cookie_info_view_top_padding; |
| 86 // Padding below the cookie info view. |
| 87 int cookie_info_view_bottom_padding; |
| 88 int label_top_padding; |
| 89 int label_bottom_padding; |
| 90 }; |
| 91 |
| 92 const CollectedCookiesViews::LayoutParams |
| 93 CollectedCookiesViews::standard_layout_params = { |
| 94 views::kRelatedControlVerticalSpacing, |
| 95 views::kRelatedControlVerticalSpacing, |
| 96 views::kRelatedControlVerticalSpacing, |
| 97 0, |
| 98 views::kRelatedControlVerticalSpacing |
| 99 }; |
| 100 |
| 101 const CollectedCookiesViews::LayoutParams |
| 102 CollectedCookiesViews::chrome_style_layout_params = { |
| 103 10, |
| 104 19, |
| 105 ConstrainedWindowConstants::kRowPadding, |
| 106 ConstrainedWindowConstants::kRowPadding, |
| 107 ConstrainedWindowConstants::kRowPadding |
| 108 }; |
| 109 |
78 // A custom view that conditionally displays an infobar. | 110 // A custom view that conditionally displays an infobar. |
79 class InfobarView : public views::View { | 111 class InfobarView : public views::View { |
80 public: | 112 public: |
81 InfobarView() { | 113 InfobarView() { |
82 content_ = new views::View; | 114 content_ = new views::View; |
83 #if defined(USE_AURA) || !defined(OS_WIN) | 115 #if defined(USE_AURA) || !defined(OS_WIN) |
84 SkColor border_color = SK_ColorGRAY; | 116 SkColor border_color = SK_ColorGRAY; |
85 #else | 117 #else |
86 SkColor border_color = color_utils::GetSysSkColor(COLOR_3DSHADOW); | 118 SkColor border_color = chrome::UseChromeStyleDialogs() ? |
| 119 SK_ColorGRAY : |
| 120 color_utils::GetSysSkColor(COLOR_3DSHADOW); |
87 #endif | 121 #endif |
88 views::Border* border = views::Border::CreateSolidBorder( | 122 views::Border* border = views::Border::CreateSolidBorder( |
89 kInfobarBorderSize, border_color); | 123 kInfobarBorderSize, border_color); |
90 content_->set_border(border); | 124 content_->set_border(border); |
91 | 125 |
92 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 126 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
93 info_image_ = new views::ImageView(); | 127 info_image_ = new views::ImageView(); |
94 info_image_->SetImage(rb.GetImageSkiaNamed(IDR_INFO)); | 128 info_image_->SetImage(rb.GetImageSkiaNamed(IDR_INFO)); |
95 label_ = new views::Label(); | 129 label_ = new views::Label(); |
96 } | 130 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 : web_contents_(web_contents), | 220 : web_contents_(web_contents), |
187 allowed_label_(NULL), | 221 allowed_label_(NULL), |
188 blocked_label_(NULL), | 222 blocked_label_(NULL), |
189 allowed_cookies_tree_(NULL), | 223 allowed_cookies_tree_(NULL), |
190 blocked_cookies_tree_(NULL), | 224 blocked_cookies_tree_(NULL), |
191 block_allowed_button_(NULL), | 225 block_allowed_button_(NULL), |
192 allow_blocked_button_(NULL), | 226 allow_blocked_button_(NULL), |
193 for_session_blocked_button_(NULL), | 227 for_session_blocked_button_(NULL), |
194 cookie_info_view_(NULL), | 228 cookie_info_view_(NULL), |
195 infobar_(NULL), | 229 infobar_(NULL), |
196 status_changed_(false) { | 230 status_changed_(false), |
| 231 layout_params_(chrome::UseChromeStyleDialogs() ? |
| 232 chrome_style_layout_params : standard_layout_params) { |
197 TabSpecificContentSettings* content_settings = | 233 TabSpecificContentSettings* content_settings = |
198 TabSpecificContentSettings::FromWebContents(web_contents); | 234 TabSpecificContentSettings::FromWebContents(web_contents); |
199 registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, | 235 registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, |
200 content::Source<TabSpecificContentSettings>(content_settings)); | 236 content::Source<TabSpecificContentSettings>(content_settings)); |
201 window_ = new ConstrainedWindowViews( | 237 window_ = new ConstrainedWindowViews( |
202 web_contents, this, false, ConstrainedWindowViews::DEFAULT_INSETS); | 238 web_contents, |
| 239 this, |
| 240 chrome::UseChromeStyleDialogs(), |
| 241 ConstrainedWindowViews::FRAME_LAYOUT_HEADER_ONLY); |
203 } | 242 } |
204 | 243 |
205 /////////////////////////////////////////////////////////////////////////////// | 244 /////////////////////////////////////////////////////////////////////////////// |
206 // CollectedCookiesViews, views::DialogDelegate implementation: | 245 // CollectedCookiesViews, views::DialogDelegate implementation: |
207 | 246 |
208 string16 CollectedCookiesViews::GetWindowTitle() const { | 247 string16 CollectedCookiesViews::GetWindowTitle() const { |
209 return l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_DIALOG_TITLE); | 248 return l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_DIALOG_TITLE); |
210 } | 249 } |
211 | 250 |
212 int CollectedCookiesViews::GetDialogButtons() const { | 251 int CollectedCookiesViews::GetDialogButtons() const { |
213 return ui::DIALOG_BUTTON_CANCEL; | 252 return ui::DIALOG_BUTTON_CANCEL; |
214 } | 253 } |
215 | 254 |
216 string16 CollectedCookiesViews::GetDialogButtonLabel( | 255 string16 CollectedCookiesViews::GetDialogButtonLabel( |
217 ui::DialogButton button) const { | 256 ui::DialogButton button) const { |
218 return l10n_util::GetStringUTF16(IDS_CLOSE); | 257 return l10n_util::GetStringUTF16(IDS_CLOSE); |
219 } | 258 } |
220 | 259 |
221 void CollectedCookiesViews::DeleteDelegate() { | 260 void CollectedCookiesViews::DeleteDelegate() { |
222 delete this; | 261 delete this; |
223 } | 262 } |
224 | 263 |
| 264 bool CollectedCookiesViews::UseChromeStyle() const { |
| 265 return chrome::UseChromeStyleDialogs(); |
| 266 } |
| 267 |
| 268 void CollectedCookiesViews::GetChromeStyleMargins(int* vertical_edge, |
| 269 int* horizontal_edge) const { |
| 270 DCHECK(vertical_edge); |
| 271 DCHECK(horizontal_edge); |
| 272 *vertical_edge = ConstrainedWindowConstants::kClientBottomPadding - |
| 273 views::GetChromeStyleButtonShadowMargin(); |
| 274 *horizontal_edge = ConstrainedWindowConstants::kHorizontalPadding; |
| 275 } |
| 276 |
225 bool CollectedCookiesViews::Cancel() { | 277 bool CollectedCookiesViews::Cancel() { |
226 if (status_changed_) { | 278 if (status_changed_) { |
227 InfoBarTabHelper* infobar_helper = | 279 InfoBarTabHelper* infobar_helper = |
228 InfoBarTabHelper::FromWebContents(web_contents_); | 280 InfoBarTabHelper::FromWebContents(web_contents_); |
229 infobar_helper->AddInfoBar( | 281 infobar_helper->AddInfoBar( |
230 new CollectedCookiesInfoBarDelegate(infobar_helper)); | 282 new CollectedCookiesInfoBarDelegate(infobar_helper)); |
231 } | 283 } |
232 | 284 |
233 return true; | 285 return true; |
234 } | 286 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 // CollectedCookiesViews, private: | 333 // CollectedCookiesViews, private: |
282 | 334 |
283 CollectedCookiesViews::~CollectedCookiesViews() { | 335 CollectedCookiesViews::~CollectedCookiesViews() { |
284 allowed_cookies_tree_->SetModel(NULL); | 336 allowed_cookies_tree_->SetModel(NULL); |
285 blocked_cookies_tree_->SetModel(NULL); | 337 blocked_cookies_tree_->SetModel(NULL); |
286 } | 338 } |
287 | 339 |
288 void CollectedCookiesViews::Init() { | 340 void CollectedCookiesViews::Init() { |
289 using views::GridLayout; | 341 using views::GridLayout; |
290 | 342 |
291 GridLayout* layout = GridLayout::CreatePanel(this); | 343 GridLayout* layout = chrome::UseChromeStyleDialogs() ? |
| 344 new GridLayout(this) : |
| 345 GridLayout::CreatePanel(this); |
292 SetLayoutManager(layout); | 346 SetLayoutManager(layout); |
293 | 347 |
294 const int single_column_layout_id = 0; | 348 const int single_column_layout_id = 0; |
295 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); | 349 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); |
296 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 350 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
297 GridLayout::USE_PREF, 0, 0); | 351 GridLayout::USE_PREF, 0, 0); |
298 | 352 |
299 const int single_column_with_padding_layout_id = 1; | 353 const int single_column_with_padding_layout_id = 1; |
300 views::ColumnSet* column_set_with_padding = layout->AddColumnSet( | 354 views::ColumnSet* column_set_with_padding = layout->AddColumnSet( |
301 single_column_with_padding_layout_id); | 355 single_column_with_padding_layout_id); |
302 column_set_with_padding->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 356 column_set_with_padding->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
303 GridLayout::USE_PREF, 0, 0); | 357 GridLayout::USE_PREF, 0, 0); |
304 column_set_with_padding->AddPaddingColumn(0, 2); | 358 column_set_with_padding->AddPaddingColumn(0, 2); |
305 | 359 |
306 layout->StartRow(0, single_column_layout_id); | 360 layout->StartRow(0, single_column_layout_id); |
307 views::TabbedPane* tabbed_pane = new views::TabbedPane(); | 361 views::TabbedPane* tabbed_pane = |
| 362 new views::TabbedPane(chrome::UseChromeStyleDialogs()); |
308 #if defined(OS_WIN) && !defined(USE_AURA) | 363 #if defined(OS_WIN) && !defined(USE_AURA) |
309 // "set_use_native_win_control" must be called before the first tab is added. | 364 // "set_use_native_win_control" must be called before the first tab is added. |
310 tabbed_pane->set_use_native_win_control(true); | 365 tabbed_pane->set_use_native_win_control(!chrome::UseChromeStyleDialogs()); |
311 #endif | 366 #endif |
312 layout->AddView(tabbed_pane); | 367 layout->AddView(tabbed_pane); |
313 // NOTE: the panes need to be added after the tabbed_pane has been added to | 368 // NOTE: the panes need to be added after the tabbed_pane has been added to |
314 // its parent. | 369 // its parent. |
315 string16 label_allowed = l10n_util::GetStringUTF16( | 370 string16 label_allowed = l10n_util::GetStringUTF16( |
316 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_TAB_LABEL); | 371 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_TAB_LABEL); |
317 string16 label_blocked = l10n_util::GetStringUTF16( | 372 string16 label_blocked = l10n_util::GetStringUTF16( |
318 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_TAB_LABEL); | 373 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_TAB_LABEL); |
319 tabbed_pane->AddTab(label_allowed, CreateAllowedPane()); | 374 tabbed_pane->AddTab(label_allowed, CreateAllowedPane()); |
320 tabbed_pane->AddTab(label_blocked, CreateBlockedPane()); | 375 tabbed_pane->AddTab(label_blocked, CreateBlockedPane()); |
321 tabbed_pane->SelectTabAt(0); | 376 tabbed_pane->SelectTabAt(0); |
322 tabbed_pane->set_listener(this); | 377 tabbed_pane->set_listener(this); |
323 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 378 layout->AddPaddingRow(0, layout_params_.cookie_info_view_top_padding); |
324 | 379 |
325 layout->StartRow(0, single_column_with_padding_layout_id); | 380 layout->StartRow(0, single_column_with_padding_layout_id); |
326 cookie_info_view_ = new CookieInfoView(false); | 381 cookie_info_view_ = new CookieInfoView(false); |
327 layout->AddView(cookie_info_view_); | 382 layout->AddView(cookie_info_view_); |
328 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 383 layout->AddPaddingRow(0, layout_params_.cookie_info_view_bottom_padding); |
329 | 384 |
330 layout->StartRow(0, single_column_with_padding_layout_id); | 385 layout->StartRow(0, single_column_with_padding_layout_id); |
331 infobar_ = new InfobarView(); | 386 infobar_ = new InfobarView(); |
332 layout->AddView(infobar_); | 387 layout->AddView(infobar_); |
333 | 388 |
334 EnableControls(); | 389 EnableControls(); |
335 ShowCookieInfo(); | 390 ShowCookieInfo(); |
336 } | 391 } |
337 | 392 |
338 views::View* CollectedCookiesViews::CreateAllowedPane() { | 393 views::View* CollectedCookiesViews::CreateAllowedPane() { |
339 TabSpecificContentSettings* content_settings = | 394 TabSpecificContentSettings* content_settings = |
340 TabSpecificContentSettings::FromWebContents(web_contents_); | 395 TabSpecificContentSettings::FromWebContents(web_contents_); |
341 | 396 |
342 // Create the controls that go into the pane. | 397 // Create the controls that go into the pane. |
343 allowed_label_ = new views::Label(l10n_util::GetStringUTF16( | 398 allowed_label_ = new views::Label(l10n_util::GetStringUTF16( |
344 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_LABEL)); | 399 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_LABEL)); |
345 | 400 |
346 const LocalSharedObjectsContainer& allowed_data = | 401 const LocalSharedObjectsContainer& allowed_data = |
347 content_settings->allowed_local_shared_objects(); | 402 content_settings->allowed_local_shared_objects(); |
348 allowed_cookies_tree_model_ = allowed_data.CreateCookiesTreeModel(); | 403 allowed_cookies_tree_model_ = allowed_data.CreateCookiesTreeModel(); |
349 allowed_cookies_tree_ = new views::TreeView(); | 404 allowed_cookies_tree_ = new views::TreeView(); |
350 allowed_cookies_tree_->SetModel(allowed_cookies_tree_model_.get()); | 405 allowed_cookies_tree_->SetModel(allowed_cookies_tree_model_.get()); |
351 allowed_cookies_tree_->SetRootShown(false); | 406 allowed_cookies_tree_->SetRootShown(false); |
352 allowed_cookies_tree_->SetEditable(false); | 407 allowed_cookies_tree_->SetEditable(false); |
353 allowed_cookies_tree_->set_lines_at_root(true); | 408 allowed_cookies_tree_->set_lines_at_root(true); |
354 allowed_cookies_tree_->set_auto_expand_children(true); | 409 allowed_cookies_tree_->set_auto_expand_children(true); |
355 allowed_cookies_tree_->SetController(this); | 410 allowed_cookies_tree_->SetController(this); |
356 | 411 |
357 block_allowed_button_ = new views::NativeTextButton(this, | 412 block_allowed_button_ = CreateTextButton( |
358 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_BLOCK_BUTTON)); | 413 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_BLOCK_BUTTON)); |
359 | 414 |
360 // Create the view that holds all the controls together. This will be the | 415 // Create the view that holds all the controls together. This will be the |
361 // pane added to the tabbed pane. | 416 // pane added to the tabbed pane. |
362 using views::GridLayout; | 417 using views::GridLayout; |
363 | 418 |
364 views::View* pane = new views::View(); | 419 views::View* pane = new views::View(); |
365 GridLayout* layout = GridLayout::CreatePanel(pane); | 420 GridLayout* layout; |
| 421 if (chrome::UseChromeStyleDialogs()) { |
| 422 layout = new GridLayout(pane); |
| 423 layout->SetInsets(0, |
| 424 ConstrainedWindowConstants::kHorizontalPadding, |
| 425 0, |
| 426 ConstrainedWindowConstants::kHorizontalPadding); |
| 427 } else { |
| 428 layout = GridLayout::CreatePanel(pane); |
| 429 } |
366 pane->SetLayoutManager(layout); | 430 pane->SetLayoutManager(layout); |
367 | 431 |
368 const int single_column_layout_id = 0; | 432 const int single_column_layout_id = 0; |
369 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); | 433 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); |
370 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, | 434 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, |
371 GridLayout::USE_PREF, 0, 0); | 435 GridLayout::USE_PREF, 0, 0); |
372 | 436 |
| 437 layout->AddPaddingRow(0, layout_params_.label_top_padding); |
373 layout->StartRow(0, single_column_layout_id); | 438 layout->StartRow(0, single_column_layout_id); |
374 layout->AddView(allowed_label_); | 439 layout->AddView(allowed_label_); |
375 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 440 layout->AddPaddingRow(0, layout_params_.label_bottom_padding); |
376 | 441 |
377 layout->StartRow(1, single_column_layout_id); | 442 layout->StartRow(1, single_column_layout_id); |
378 layout->AddView(allowed_cookies_tree_->CreateParentIfNecessary(), 1, 1, | 443 layout->AddView(allowed_cookies_tree_->CreateParentIfNecessary(), 1, 1, |
379 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, | 444 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, |
380 kTreeViewHeight); | 445 kTreeViewHeight); |
381 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 446 layout->AddPaddingRow(0, layout_params_.button_top_padding); |
382 | 447 |
383 layout->StartRow(0, single_column_layout_id); | 448 layout->StartRow(0, single_column_layout_id); |
384 layout->AddView(block_allowed_button_, 1, 1, GridLayout::LEADING, | 449 layout->AddView(block_allowed_button_, 1, 1, GridLayout::LEADING, |
385 GridLayout::CENTER); | 450 GridLayout::CENTER); |
386 | 451 |
387 return pane; | 452 return pane; |
388 } | 453 } |
389 | 454 |
390 views::View* CollectedCookiesViews::CreateBlockedPane() { | 455 views::View* CollectedCookiesViews::CreateBlockedPane() { |
391 TabSpecificContentSettings* content_settings = | 456 TabSpecificContentSettings* content_settings = |
(...skipping 15 matching lines...) Expand all Loading... |
407 content_settings->blocked_local_shared_objects(); | 472 content_settings->blocked_local_shared_objects(); |
408 blocked_cookies_tree_model_ = blocked_data.CreateCookiesTreeModel(); | 473 blocked_cookies_tree_model_ = blocked_data.CreateCookiesTreeModel(); |
409 blocked_cookies_tree_ = new views::TreeView(); | 474 blocked_cookies_tree_ = new views::TreeView(); |
410 blocked_cookies_tree_->SetModel(blocked_cookies_tree_model_.get()); | 475 blocked_cookies_tree_->SetModel(blocked_cookies_tree_model_.get()); |
411 blocked_cookies_tree_->SetRootShown(false); | 476 blocked_cookies_tree_->SetRootShown(false); |
412 blocked_cookies_tree_->SetEditable(false); | 477 blocked_cookies_tree_->SetEditable(false); |
413 blocked_cookies_tree_->set_lines_at_root(true); | 478 blocked_cookies_tree_->set_lines_at_root(true); |
414 blocked_cookies_tree_->set_auto_expand_children(true); | 479 blocked_cookies_tree_->set_auto_expand_children(true); |
415 blocked_cookies_tree_->SetController(this); | 480 blocked_cookies_tree_->SetController(this); |
416 | 481 |
417 allow_blocked_button_ = new views::NativeTextButton(this, | 482 allow_blocked_button_ = CreateTextButton( |
418 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_ALLOW_BUTTON)); | 483 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_ALLOW_BUTTON)); |
419 for_session_blocked_button_ = new views::NativeTextButton(this, | 484 for_session_blocked_button_ = CreateTextButton( |
420 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_SESSION_ONLY_BUTTON)); | 485 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_SESSION_ONLY_BUTTON)); |
421 | 486 |
422 // Create the view that holds all the controls together. This will be the | 487 // Create the view that holds all the controls together. This will be the |
423 // pane added to the tabbed pane. | 488 // pane added to the tabbed pane. |
424 using views::GridLayout; | 489 using views::GridLayout; |
425 | 490 |
426 views::View* pane = new views::View(); | 491 views::View* pane = new views::View(); |
427 GridLayout* layout = GridLayout::CreatePanel(pane); | 492 GridLayout* layout; |
| 493 if (chrome::UseChromeStyleDialogs()) { |
| 494 layout = new GridLayout(pane); |
| 495 layout->SetInsets(0, |
| 496 ConstrainedWindowConstants::kHorizontalPadding, |
| 497 0, |
| 498 ConstrainedWindowConstants::kHorizontalPadding); |
| 499 } else { |
| 500 layout = GridLayout::CreatePanel(pane); |
| 501 } |
428 pane->SetLayoutManager(layout); | 502 pane->SetLayoutManager(layout); |
429 | 503 |
430 const int single_column_layout_id = 0; | 504 const int single_column_layout_id = 0; |
431 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); | 505 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); |
432 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, | 506 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, |
433 GridLayout::USE_PREF, 0, 0); | 507 GridLayout::USE_PREF, 0, 0); |
434 | 508 |
435 const int three_columns_layout_id = 1; | 509 const int three_columns_layout_id = 1; |
436 column_set = layout->AddColumnSet(three_columns_layout_id); | 510 column_set = layout->AddColumnSet(three_columns_layout_id); |
437 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, | 511 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, |
438 GridLayout::USE_PREF, 0, 0); | 512 GridLayout::USE_PREF, 0, 0); |
439 column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); | 513 column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); |
440 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, | 514 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, |
441 GridLayout::USE_PREF, 0, 0); | 515 GridLayout::USE_PREF, 0, 0); |
442 | 516 |
| 517 layout->AddPaddingRow(0, layout_params_.label_top_padding); |
443 layout->StartRow(0, single_column_layout_id); | 518 layout->StartRow(0, single_column_layout_id); |
444 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL); | 519 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL); |
445 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 520 layout->AddPaddingRow(0, layout_params_.label_bottom_padding); |
446 | 521 |
447 layout->StartRow(1, single_column_layout_id); | 522 layout->StartRow(1, single_column_layout_id); |
448 layout->AddView( | 523 layout->AddView( |
449 blocked_cookies_tree_->CreateParentIfNecessary(), 1, 1, | 524 blocked_cookies_tree_->CreateParentIfNecessary(), 1, 1, |
450 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight); | 525 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight); |
451 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 526 layout->AddPaddingRow(0, layout_params_.button_top_padding); |
452 | 527 |
453 layout->StartRow(0, three_columns_layout_id); | 528 layout->StartRow(0, three_columns_layout_id); |
454 layout->AddView(allow_blocked_button_); | 529 layout->AddView(allow_blocked_button_); |
455 layout->AddView(for_session_blocked_button_); | 530 layout->AddView(for_session_blocked_button_); |
456 | 531 |
457 return pane; | 532 return pane; |
458 } | 533 } |
459 | 534 |
| 535 views::TextButton* CollectedCookiesViews::CreateTextButton( |
| 536 const string16& text) { |
| 537 if (UseChromeStyle()) { |
| 538 views::TextButton* button = new views::TextButton(this, text); |
| 539 ApplyChromeStyle(button); |
| 540 return button; |
| 541 } else { |
| 542 return new views::NativeTextButton(this, text); |
| 543 } |
| 544 } |
| 545 |
460 void CollectedCookiesViews::EnableControls() { | 546 void CollectedCookiesViews::EnableControls() { |
461 bool enable_allowed_buttons = false; | 547 bool enable_allowed_buttons = false; |
462 ui::TreeModelNode* node = allowed_cookies_tree_->GetSelectedNode(); | 548 ui::TreeModelNode* node = allowed_cookies_tree_->GetSelectedNode(); |
463 if (node) { | 549 if (node) { |
464 CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node); | 550 CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node); |
465 if (cookie_node->GetDetailedInfo().node_type == | 551 if (cookie_node->GetDetailedInfo().node_type == |
466 CookieTreeNode::DetailedInfo::TYPE_HOST) { | 552 CookieTreeNode::DetailedInfo::TYPE_HOST) { |
467 enable_allowed_buttons = static_cast<CookieTreeHostNode*>( | 553 enable_allowed_buttons = static_cast<CookieTreeHostNode*>( |
468 cookie_node)->CanCreateContentException(); | 554 cookie_node)->CanCreateContentException(); |
469 } | 555 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 /////////////////////////////////////////////////////////////////////////////// | 606 /////////////////////////////////////////////////////////////////////////////// |
521 // CollectedCookiesViews, content::NotificationObserver implementation: | 607 // CollectedCookiesViews, content::NotificationObserver implementation: |
522 | 608 |
523 void CollectedCookiesViews::Observe( | 609 void CollectedCookiesViews::Observe( |
524 int type, | 610 int type, |
525 const content::NotificationSource& source, | 611 const content::NotificationSource& source, |
526 const content::NotificationDetails& details) { | 612 const content::NotificationDetails& details) { |
527 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); | 613 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); |
528 window_->CloseConstrainedWindow(); | 614 window_->CloseConstrainedWindow(); |
529 } | 615 } |
OLD | NEW |