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

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

Issue 10540100: TabContentsWrapper -> TabContents, part 48. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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) 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_appcache_helper.h" 7 #include "chrome/browser/browsing_data_appcache_helper.h"
8 #include "chrome/browser/browsing_data_cookie_helper.h" 8 #include "chrome/browser/browsing_data_cookie_helper.h"
9 #include "chrome/browser/browsing_data_database_helper.h" 9 #include "chrome/browser/browsing_data_database_helper.h"
10 #include "chrome/browser/browsing_data_file_system_helper.h" 10 #include "chrome/browser/browsing_data_file_system_helper.h"
11 #include "chrome/browser/browsing_data_indexed_db_helper.h" 11 #include "chrome/browser/browsing_data_indexed_db_helper.h"
12 #include "chrome/browser/browsing_data_local_storage_helper.h" 12 #include "chrome/browser/browsing_data_local_storage_helper.h"
13 #include "chrome/browser/browsing_data_server_bound_cert_helper.h" 13 #include "chrome/browser/browsing_data_server_bound_cert_helper.h"
14 #include "chrome/browser/content_settings/cookie_settings.h" 14 #include "chrome/browser/content_settings/cookie_settings.h"
15 #include "chrome/browser/content_settings/local_shared_objects_container.h" 15 #include "chrome/browser/content_settings/local_shared_objects_container.h"
16 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 16 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
17 #include "chrome/browser/cookies_tree_model.h" 17 #include "chrome/browser/cookies_tree_model.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/tab_contents/tab_contents_wrapper.h" 23 #include "chrome/browser/ui/tab_contents/tab_contents.h"
24 #include "chrome/browser/ui/views/constrained_window_views.h" 24 #include "chrome/browser/ui/views/constrained_window_views.h"
25 #include "chrome/browser/ui/views/cookie_info_view.h" 25 #include "chrome/browser/ui/views/cookie_info_view.h"
26 #include "chrome/common/chrome_notification_types.h" 26 #include "chrome/common/chrome_notification_types.h"
27 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
28 #include "content/public/browser/notification_details.h" 28 #include "content/public/browser/notification_details.h"
29 #include "content/public/browser/notification_source.h" 29 #include "content/public/browser/notification_source.h"
30 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
31 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
32 #include "grit/locale_settings.h" 32 #include "grit/locale_settings.h"
33 #include "grit/theme_resources.h" 33 #include "grit/theme_resources.h"
34 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
35 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
36 #include "ui/gfx/color_utils.h" 36 #include "ui/gfx/color_utils.h"
37 #include "ui/views/controls/button/text_button.h" 37 #include "ui/views/controls/button/text_button.h"
38 #include "ui/views/controls/image_view.h" 38 #include "ui/views/controls/image_view.h"
39 #include "ui/views/controls/label.h" 39 #include "ui/views/controls/label.h"
40 #include "ui/views/controls/tabbed_pane/tabbed_pane.h" 40 #include "ui/views/controls/tabbed_pane/tabbed_pane.h"
41 #include "ui/views/controls/tree/tree_view.h" 41 #include "ui/views/controls/tree/tree_view.h"
42 #include "ui/views/layout/box_layout.h" 42 #include "ui/views/layout/box_layout.h"
43 #include "ui/views/layout/grid_layout.h" 43 #include "ui/views/layout/grid_layout.h"
44 #include "ui/views/layout/layout_constants.h" 44 #include "ui/views/layout/layout_constants.h"
45 #include "ui/views/widget/widget.h" 45 #include "ui/views/widget/widget.h"
46 46
47 namespace browser { 47 namespace browser {
48 48
49 // Declared in browser_dialogs.h so others don't have to depend on our header. 49 // Declared in browser_dialogs.h so others don't have to depend on our header.
50 void ShowCollectedCookiesDialog(gfx::NativeWindow parent_window, 50 void ShowCollectedCookiesDialog(gfx::NativeWindow parent_window,
51 TabContentsWrapper* wrapper) { 51 TabContents* tab_contents) {
52 // Deletes itself on close. 52 // Deletes itself on close.
53 new CollectedCookiesViews(wrapper); 53 new CollectedCookiesViews(tab_contents);
54 } 54 }
55 55
56 } // namespace browser 56 } // namespace browser
57 57
58 namespace { 58 namespace {
59 // Spacing between the infobar frame and its contents. 59 // Spacing between the infobar frame and its contents.
60 const int kInfobarVerticalPadding = 3; 60 const int kInfobarVerticalPadding = 3;
61 const int kInfobarHorizontalPadding = 8; 61 const int kInfobarHorizontalPadding = 8;
62 62
63 // Width of the infobar frame. 63 // Width of the infobar frame.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 views::ImageView* info_image_; 169 views::ImageView* info_image_;
170 // The label responsible for rendering the text. 170 // The label responsible for rendering the text.
171 views::Label* label_; 171 views::Label* label_;
172 172
173 DISALLOW_COPY_AND_ASSIGN(InfobarView); 173 DISALLOW_COPY_AND_ASSIGN(InfobarView);
174 }; 174 };
175 175
176 /////////////////////////////////////////////////////////////////////////////// 176 ///////////////////////////////////////////////////////////////////////////////
177 // CollectedCookiesViews, public: 177 // CollectedCookiesViews, public:
178 178
179 CollectedCookiesViews::CollectedCookiesViews(TabContentsWrapper* wrapper) 179 CollectedCookiesViews::CollectedCookiesViews(TabContents* tab_contents)
180 : wrapper_(wrapper), 180 : tab_contents_(tab_contents),
181 allowed_label_(NULL), 181 allowed_label_(NULL),
182 blocked_label_(NULL), 182 blocked_label_(NULL),
183 allowed_cookies_tree_(NULL), 183 allowed_cookies_tree_(NULL),
184 blocked_cookies_tree_(NULL), 184 blocked_cookies_tree_(NULL),
185 block_allowed_button_(NULL), 185 block_allowed_button_(NULL),
186 allow_blocked_button_(NULL), 186 allow_blocked_button_(NULL),
187 for_session_blocked_button_(NULL), 187 for_session_blocked_button_(NULL),
188 infobar_(NULL), 188 infobar_(NULL),
189 status_changed_(false) { 189 status_changed_(false) {
190 TabSpecificContentSettings* content_settings = wrapper->content_settings(); 190 TabSpecificContentSettings* content_settings =
191 tab_contents->content_settings();
191 registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, 192 registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN,
192 content::Source<TabSpecificContentSettings>(content_settings)); 193 content::Source<TabSpecificContentSettings>(content_settings));
193 window_ = new ConstrainedWindowViews(wrapper, this); 194 window_ = new ConstrainedWindowViews(tab_contents, this);
194 } 195 }
195 196
196 /////////////////////////////////////////////////////////////////////////////// 197 ///////////////////////////////////////////////////////////////////////////////
197 // CollectedCookiesViews, views::DialogDelegate implementation: 198 // CollectedCookiesViews, views::DialogDelegate implementation:
198 199
199 string16 CollectedCookiesViews::GetWindowTitle() const { 200 string16 CollectedCookiesViews::GetWindowTitle() const {
200 return l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_DIALOG_TITLE); 201 return l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_DIALOG_TITLE);
201 } 202 }
202 203
203 int CollectedCookiesViews::GetDialogButtons() const { 204 int CollectedCookiesViews::GetDialogButtons() const {
204 return ui::DIALOG_BUTTON_CANCEL; 205 return ui::DIALOG_BUTTON_CANCEL;
205 } 206 }
206 207
207 string16 CollectedCookiesViews::GetDialogButtonLabel( 208 string16 CollectedCookiesViews::GetDialogButtonLabel(
208 ui::DialogButton button) const { 209 ui::DialogButton button) const {
209 return l10n_util::GetStringUTF16(IDS_CLOSE); 210 return l10n_util::GetStringUTF16(IDS_CLOSE);
210 } 211 }
211 212
212 void CollectedCookiesViews::DeleteDelegate() { 213 void CollectedCookiesViews::DeleteDelegate() {
213 delete this; 214 delete this;
214 } 215 }
215 216
216 bool CollectedCookiesViews::Cancel() { 217 bool CollectedCookiesViews::Cancel() {
217 if (status_changed_) { 218 if (status_changed_) {
218 InfoBarTabHelper* infobar_helper = wrapper_->infobar_tab_helper(); 219 InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper();
219 infobar_helper->AddInfoBar( 220 infobar_helper->AddInfoBar(
220 new CollectedCookiesInfoBarDelegate(infobar_helper)); 221 new CollectedCookiesInfoBarDelegate(infobar_helper));
221 } 222 }
222 223
223 return true; 224 return true;
224 } 225 }
225 226
226 views::View* CollectedCookiesViews::GetContentsView() { 227 views::View* CollectedCookiesViews::GetContentsView() {
227 return this; 228 return this;
228 } 229 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 316
316 layout->StartRow(0, single_column_with_padding_layout_id); 317 layout->StartRow(0, single_column_with_padding_layout_id);
317 infobar_ = new InfobarView(); 318 infobar_ = new InfobarView();
318 layout->AddView(infobar_); 319 layout->AddView(infobar_);
319 320
320 EnableControls(); 321 EnableControls();
321 ShowCookieInfo(); 322 ShowCookieInfo();
322 } 323 }
323 324
324 views::View* CollectedCookiesViews::CreateAllowedPane() { 325 views::View* CollectedCookiesViews::CreateAllowedPane() {
325 TabSpecificContentSettings* content_settings = wrapper_->content_settings(); 326 TabSpecificContentSettings* content_settings =
327 tab_contents_->content_settings();
326 328
327 // Create the controls that go into the pane. 329 // Create the controls that go into the pane.
328 allowed_label_ = new views::Label(l10n_util::GetStringUTF16( 330 allowed_label_ = new views::Label(l10n_util::GetStringUTF16(
329 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_LABEL)); 331 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_LABEL));
330 332
331 const LocalSharedObjectsContainer& allowed_lsos = 333 const LocalSharedObjectsContainer& allowed_lsos =
332 content_settings->allowed_local_shared_objects(); 334 content_settings->allowed_local_shared_objects();
333 allowed_cookies_tree_model_.reset( 335 allowed_cookies_tree_model_.reset(
334 new CookiesTreeModel(allowed_lsos.cookies()->Clone(), 336 new CookiesTreeModel(allowed_lsos.cookies()->Clone(),
335 allowed_lsos.databases()->Clone(), 337 allowed_lsos.databases()->Clone(),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 378 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
377 379
378 layout->StartRow(0, single_column_layout_id); 380 layout->StartRow(0, single_column_layout_id);
379 layout->AddView(block_allowed_button_, 1, 1, GridLayout::LEADING, 381 layout->AddView(block_allowed_button_, 1, 1, GridLayout::LEADING,
380 GridLayout::CENTER); 382 GridLayout::CENTER);
381 383
382 return pane; 384 return pane;
383 } 385 }
384 386
385 views::View* CollectedCookiesViews::CreateBlockedPane() { 387 views::View* CollectedCookiesViews::CreateBlockedPane() {
386 TabSpecificContentSettings* content_settings = wrapper_->content_settings(); 388 TabSpecificContentSettings* content_settings =
389 tab_contents_->content_settings();
387 390
388 PrefService* prefs = wrapper_->profile()->GetPrefs(); 391 PrefService* prefs = tab_contents_->profile()->GetPrefs();
389 392
390 // Create the controls that go into the pane. 393 // Create the controls that go into the pane.
391 blocked_label_ = new views::Label( 394 blocked_label_ = new views::Label(
392 l10n_util::GetStringUTF16( 395 l10n_util::GetStringUTF16(
393 prefs->GetBoolean(prefs::kBlockThirdPartyCookies) ? 396 prefs->GetBoolean(prefs::kBlockThirdPartyCookies) ?
394 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED : 397 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED :
395 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL)); 398 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL));
396 blocked_label_->SetMultiLine(true); 399 blocked_label_->SetMultiLine(true);
397 blocked_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 400 blocked_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
398 const LocalSharedObjectsContainer& blocked_lsos = 401 const LocalSharedObjectsContainer& blocked_lsos =
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 } 507 }
505 } else { 508 } else {
506 cookie_info_view_->ClearCookieDisplay(); 509 cookie_info_view_->ClearCookieDisplay();
507 } 510 }
508 } 511 }
509 512
510 void CollectedCookiesViews::AddContentException(views::TreeView* tree_view, 513 void CollectedCookiesViews::AddContentException(views::TreeView* tree_view,
511 ContentSetting setting) { 514 ContentSetting setting) {
512 CookieTreeOriginNode* origin_node = 515 CookieTreeOriginNode* origin_node =
513 static_cast<CookieTreeOriginNode*>(tree_view->GetSelectedNode()); 516 static_cast<CookieTreeOriginNode*>(tree_view->GetSelectedNode());
514 Profile* profile = wrapper_->profile(); 517 Profile* profile = tab_contents_->profile();
515 origin_node->CreateContentException( 518 origin_node->CreateContentException(
516 CookieSettings::Factory::GetForProfile(profile), setting); 519 CookieSettings::Factory::GetForProfile(profile), setting);
517 infobar_->UpdateVisibility(true, setting, origin_node->GetTitle()); 520 infobar_->UpdateVisibility(true, setting, origin_node->GetTitle());
518 status_changed_ = true; 521 status_changed_ = true;
519 } 522 }
520 523
521 /////////////////////////////////////////////////////////////////////////////// 524 ///////////////////////////////////////////////////////////////////////////////
522 // CollectedCookiesViews, content::NotificationObserver implementation: 525 // CollectedCookiesViews, content::NotificationObserver implementation:
523 526
524 void CollectedCookiesViews::Observe( 527 void CollectedCookiesViews::Observe(
525 int type, 528 int type,
526 const content::NotificationSource& source, 529 const content::NotificationSource& source,
527 const content::NotificationDetails& details) { 530 const content::NotificationDetails& details) {
528 DCHECK(type == chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN); 531 DCHECK(type == chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN);
529 window_->CloseConstrainedWindow(); 532 window_->CloseConstrainedWindow();
530 } 533 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/collected_cookies_views.h ('k') | chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698