summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-07 00:04:57 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-07 00:04:57 +0000
commita3627e688f2f9453719e5ac1ceb0f97b8850a5b2 (patch)
tree3129aa03244ddf479393c78c01c59b8bd515c45b /chrome
parentbd0f08969a6fe21366e7d1fc7ae962c282325ae8 (diff)
downloadchromium_src-a3627e688f2f9453719e5ac1ceb0f97b8850a5b2.zip
chromium_src-a3627e688f2f9453719e5ac1ceb0f97b8850a5b2.tar.gz
chromium_src-a3627e688f2f9453719e5ac1ceb0f97b8850a5b2.tar.bz2
content: Move collected cookies constrained window to TabContentsWrapper.
To split the ConstrainedWindow feature off of TabContents entirely (moving it to a helper object on TabContentsWrapper), I'll need to first make each constrained window TabContentsWrapper aware first. I started just hacking BUG=95257 TEST=compiles Review URL: http://codereview.chromium.org/7831051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99872 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc3
-rw-r--r--chrome/browser/ui/browser.cc4
-rw-r--r--chrome/browser/ui/browser.h4
-rw-r--r--chrome/browser/ui/browser_window.h2
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.h2
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.mm5
-rw-r--r--chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h12
-rw-r--r--chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm38
-rw-r--r--chrome/browser/ui/cocoa/content_settings/collected_cookies_mac_unittest.mm2
-rw-r--r--chrome/browser/ui/content_settings/content_setting_bubble_model.cc2
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc4
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.h2
-rw-r--r--chrome/browser/ui/gtk/collected_cookies_gtk.cc31
-rw-r--r--chrome/browser/ui/gtk/collected_cookies_gtk.h11
-rw-r--r--chrome/browser/ui/panels/panel.cc2
-rw-r--r--chrome/browser/ui/panels/panel.h2
-rw-r--r--chrome/browser/ui/views/browser_dialogs.h2
-rw-r--r--chrome/browser/ui/views/collected_cookies_win.cc35
-rw-r--r--chrome/browser/ui/views/collected_cookies_win.h5
-rw-r--r--chrome/browser/ui/views/dialog_stubs_gtk.cc6
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc4
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h2
-rw-r--r--chrome/browser/ui/webui/collected_cookies_ui_delegate.cc18
-rw-r--r--chrome/browser/ui/webui/collected_cookies_ui_delegate.h7
-rw-r--r--chrome/test/base/test_browser_window.h3
25 files changed, 93 insertions, 115 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index addfa68..509f368 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -568,7 +568,8 @@ void TestingAutomationProvider::ShowCollectedCookiesDialog(
NavigationController* controller = tab_tracker_->GetResource(handle);
TabContents* tab_contents = controller->tab_contents();
Browser* browser = Browser::GetBrowserForController(controller, NULL);
- browser->ShowCollectedCookiesDialog(tab_contents);
+ browser->ShowCollectedCookiesDialog(
+ TabContentsWrapper::GetCurrentWrapperForContents(tab_contents));
*success = true;
}
}
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 31950f11..d96ca0c 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -3764,8 +3764,8 @@ void Browser::ShowContentSettingsPage(ContentSettingsType content_type) {
ContentSettingsHandler::ContentSettingsTypeToGroupName(content_type));
}
-void Browser::ShowCollectedCookiesDialog(TabContents *tab_contents) {
- window()->ShowCollectedCookiesDialog(tab_contents);
+void Browser::ShowCollectedCookiesDialog(TabContentsWrapper* wrapper) {
+ window()->ShowCollectedCookiesDialog(wrapper);
}
bool Browser::ShouldAddNavigationToHistory(
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index 616c5a5..fdd1083 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -740,8 +740,8 @@ class Browser : public TabHandlerDelegate,
// specified.
GURL GetHomePage() const;
- // Shows the cookies collected in the tab contents.
- void ShowCollectedCookiesDialog(TabContents* tab_contents);
+ // Shows the cookies collected in the tab contents wrapper.
+ void ShowCollectedCookiesDialog(TabContentsWrapper* wrapper);
// Interface implementations ////////////////////////////////////////////////
diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h
index b74f9fa..51e96f9 100644
--- a/chrome/browser/ui/browser_window.h
+++ b/chrome/browser/ui/browser_window.h
@@ -234,7 +234,7 @@ class BrowserWindow {
virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) = 0;
// Shows the collected cookies dialog box.
- virtual void ShowCollectedCookiesDialog(TabContents* tab_contents) = 0;
+ virtual void ShowCollectedCookiesDialog(TabContentsWrapper* tab_contents) = 0;
// Show the bubble that indicates to the user that a theme is being installed.
virtual void ShowThemeInstallBubble() = 0;
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.h b/chrome/browser/ui/cocoa/browser_window_cocoa.h
index 255b1cf..94846ad 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.h
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.h
@@ -81,7 +81,7 @@ class BrowserWindowCocoa : public BrowserWindow,
virtual bool IsDownloadShelfVisible() const;
virtual DownloadShelf* GetDownloadShelf();
virtual void ShowRepostFormWarningDialog(TabContents* tab_contents);
- virtual void ShowCollectedCookiesDialog(TabContents* tab_contents);
+ virtual void ShowCollectedCookiesDialog(TabContentsWrapper* wrapper);
virtual void ShowThemeInstallBubble();
virtual void ConfirmBrowserCloseWithPendingDownloads();
virtual gfx::NativeWindow ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index 19f1d3a..cd928a7 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -380,9 +380,10 @@ void BrowserWindowCocoa::ShowRepostFormWarningDialog(
RepostFormWarningMac::Create(GetNativeHandle(), tab_contents);
}
-void BrowserWindowCocoa::ShowCollectedCookiesDialog(TabContents* tab_contents) {
+void BrowserWindowCocoa::ShowCollectedCookiesDialog(
+ TabContentsWrapper* wrapper) {
// Deletes itself on close.
- new CollectedCookiesMac(GetNativeHandle(), tab_contents);
+ new CollectedCookiesMac(GetNativeHandle(), wrapper);
}
void BrowserWindowCocoa::ShowThemeInstallBubble() {
diff --git a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h
index 3151800..acb636e 100644
--- a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h
+++ b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h
@@ -15,14 +15,14 @@
@class CollectedCookiesWindowController;
@class CookieDetailsViewController;
@class VerticalGradientView;
-class TabContents;
+class TabContentsWrapper;
// The constrained window delegate reponsible for managing the collected
// cookies dialog.
class CollectedCookiesMac : public ConstrainedWindowMacDelegateCustomSheet,
public NotificationObserver {
public:
- CollectedCookiesMac(NSWindow* parent, TabContents* tab_contents);
+ CollectedCookiesMac(NSWindow* parent, TabContentsWrapper* wrapper);
void OnSheetDidEnd(NSWindow* sheet);
@@ -41,8 +41,6 @@ class CollectedCookiesMac : public ConstrainedWindowMacDelegateCustomSheet,
ConstrainedWindow* window_;
- TabContents* tab_contents_;
-
CollectedCookiesWindowController* sheet_controller_;
DISALLOW_COPY_AND_ASSIGN(CollectedCookiesMac);
@@ -88,7 +86,7 @@ class CollectedCookiesMac : public ConstrainedWindowMacDelegateCustomSheet,
scoped_nsobject<CookieDetailsViewController> detailsViewController_;
- TabContents* tabContents_; // weak
+ TabContentsWrapper* wrapper_; // weak
BOOL infoBarVisible_;
@@ -101,7 +99,7 @@ class CollectedCookiesMac : public ConstrainedWindowMacDelegateCustomSheet,
@property(assign, nonatomic) BOOL blockedCookiesButtonsEnabled;
// Designated initializer. TabContents cannot be NULL.
-- (id)initWithTabContents:(TabContents*)tabContents;
+- (id)initWithTabContentsWrapper:(TabContentsWrapper*)wrapper;
// Closes the sheet and ends the modal loop. This will also cleanup the memory.
- (IBAction)closeSheet:(id)sender;
@@ -120,5 +118,5 @@ class CollectedCookiesMac : public ConstrainedWindowMacDelegateCustomSheet,
- (CookiesTreeModel*)allowedTreeModel;
- (CookiesTreeModel*)blockedTreeModel;
-- (void)loadTreeModelFromTabContents;
+- (void)loadTreeModelFromTabContentsWrapper;
@end
diff --git a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm
index 35b43f1..75e1606 100644
--- a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm
+++ b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm
@@ -78,24 +78,21 @@ enum TabViewItemIndices {
#pragma mark Constrained window delegate
CollectedCookiesMac::CollectedCookiesMac(NSWindow* parent,
- TabContents* tab_contents)
+ TabContentsWrapper* wrapper)
: ConstrainedWindowMacDelegateCustomSheet(
[[[CollectedCookiesSheetBridge alloc]
initWithCollectedCookiesMac:this] autorelease],
- @selector(sheetDidEnd:returnCode:contextInfo:)),
- tab_contents_(tab_contents) {
- TabSpecificContentSettings* content_settings =
- TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)->
- content_settings();
+ @selector(sheetDidEnd:returnCode:contextInfo:)) {
+ TabSpecificContentSettings* content_settings = wrapper->content_settings();
registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN,
Source<TabSpecificContentSettings>(content_settings));
sheet_controller_ = [[CollectedCookiesWindowController alloc]
- initWithTabContents:tab_contents];
+ initWithTabContentsWrapper:wrapper];
set_sheet([sheet_controller_ window]);
- window_ = new ConstrainedWindowMac(tab_contents, this);
+ window_ = new ConstrainedWindowMac(wrapper->tab_contents(), this);
}
CollectedCookiesMac::~CollectedCookiesMac() {
@@ -142,15 +139,15 @@ void CollectedCookiesMac::OnSheetDidEnd(NSWindow* sheet) {
@synthesize allowedTreeController = allowedTreeController_;
@synthesize blockedTreeController = blockedTreeController_;
-- (id)initWithTabContents:(TabContents*)tabContents {
- DCHECK(tabContents);
+- (id)initWithTabContentsWrapper:(TabContentsWrapper*)wrapper {
+ DCHECK(wrapper);
NSString* nibpath =
[base::mac::MainAppBundle() pathForResource:@"CollectedCookies"
ofType:@"nib"];
if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
- tabContents_ = tabContents;
- [self loadTreeModelFromTabContents];
+ wrapper_ = wrapper;
+ [self loadTreeModelFromTabContentsWrapper];
animation_.reset([[NSViewAnimation alloc] init]);
[animation_ setAnimationBlockingMode:NSAnimationNonblocking];
@@ -186,8 +183,7 @@ void CollectedCookiesMac::OnSheetDidEnd(NSWindow* sheet) {
[infoBar_ setStrokeColor:bannerStrokeColor];
// Change the label of the blocked cookies part if necessary.
- Profile* profile =
- Profile::FromBrowserContext(tabContents_->browser_context());
+ Profile* profile = wrapper_->profile();
if (profile->GetHostContentSettingsMap()->BlockThirdPartyCookies()) {
[blockedCookiesText_ setStringValue:l10n_util::GetNSString(
IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED)];
@@ -219,9 +215,8 @@ void CollectedCookiesMac::OnSheetDidEnd(NSWindow* sheet) {
- (void)windowWillClose:(NSNotification*)notif {
if (contentSettingsChanged_) {
- TabContentsWrapper::GetCurrentWrapperForContents(tabContents_)->
- infobar_tab_helper()->AddInfoBar(
- new CollectedCookiesInfoBarDelegate(tabContents_));
+ wrapper_->infobar_tab_helper()->AddInfoBar(
+ new CollectedCookiesInfoBarDelegate(wrapper_->tab_contents()));
}
[allowedOutlineView_ setDelegate:nil];
[blockedOutlineView_ setDelegate:nil];
@@ -245,8 +240,7 @@ void CollectedCookiesMac::OnSheetDidEnd(NSWindow* sheet) {
CookieTreeNode::DetailedInfo::TYPE_ORIGIN) {
continue;
}
- Profile* profile =
- Profile::FromBrowserContext(tabContents_->browser_context());
+ Profile* profile = wrapper_->profile();
CookieTreeOriginNode* origin_node =
static_cast<CookieTreeOriginNode*>(cookie);
origin_node->CreateContentException(profile->GetHostContentSettingsMap(),
@@ -359,10 +353,8 @@ void CollectedCookiesMac::OnSheetDidEnd(NSWindow* sheet) {
// Initializes the |allowedTreeModel_| and |blockedTreeModel_|, and builds
// the |cocoaAllowedTreeModel_| and |cocoaBlockedTreeModel_|.
-- (void)loadTreeModelFromTabContents {
- TabSpecificContentSettings* content_settings =
- TabContentsWrapper::GetCurrentWrapperForContents(tabContents_)->
- content_settings();
+- (void)loadTreeModelFromTabContentsWrapper {
+ TabSpecificContentSettings* content_settings = wrapper_->content_settings();
allowedTreeModel_.reset(content_settings->GetAllowedCookiesTreeModel());
blockedTreeModel_.reset(content_settings->GetBlockedCookiesTreeModel());
diff --git a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac_unittest.mm b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac_unittest.mm
index 770cca4..a9e4136 100644
--- a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac_unittest.mm
+++ b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac_unittest.mm
@@ -28,7 +28,7 @@ class CollectedCookiesWindowControllerTest
TEST_F(CollectedCookiesWindowControllerTest, Construction) {
CollectedCookiesWindowController* controller =
[[CollectedCookiesWindowController alloc]
- initWithTabContents:contents()];
+ initWithTabContentsWrapper:contents_wrapper()];
[controller release];
}
diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
index bda976a..a5eb196 100644
--- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
+++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
@@ -331,7 +331,7 @@ class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup {
chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN,
Source<TabSpecificContentSettings>(tab_contents()->content_settings()),
NotificationService::NoDetails());
- browser()->ShowCollectedCookiesDialog(tab_contents()->tab_contents());
+ browser()->ShowCollectedCookiesDialog(tab_contents());
}
};
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index 94f6066..6eb2328 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -984,9 +984,9 @@ void BrowserWindowGtk::ShowRepostFormWarningDialog(TabContents* tab_contents) {
new RepostFormWarningGtk(GetNativeHandle(), tab_contents);
}
-void BrowserWindowGtk::ShowCollectedCookiesDialog(TabContents* tab_contents) {
+void BrowserWindowGtk::ShowCollectedCookiesDialog(TabContentsWrapper* wrapper) {
// Deletes itself on close.
- new CollectedCookiesGtk(GetNativeHandle(), tab_contents);
+ new CollectedCookiesGtk(GetNativeHandle(), wrapper);
}
void BrowserWindowGtk::ShowThemeInstallBubble() {
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.h b/chrome/browser/ui/gtk/browser_window_gtk.h
index d23c439..d5cf0e3 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.h
+++ b/chrome/browser/ui/gtk/browser_window_gtk.h
@@ -106,7 +106,7 @@ class BrowserWindowGtk : public BrowserWindow,
virtual bool IsDownloadShelfVisible() const;
virtual DownloadShelf* GetDownloadShelf();
virtual void ShowRepostFormWarningDialog(TabContents* tab_contents);
- virtual void ShowCollectedCookiesDialog(TabContents* tab_contents);
+ virtual void ShowCollectedCookiesDialog(TabContentsWrapper* tab_contents);
virtual void ShowThemeInstallBubble();
virtual void ConfirmBrowserCloseWithPendingDownloads();
virtual gfx::NativeWindow ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
diff --git a/chrome/browser/ui/gtk/collected_cookies_gtk.cc b/chrome/browser/ui/gtk/collected_cookies_gtk.cc
index cb9e5e1..963dcc3 100644
--- a/chrome/browser/ui/gtk/collected_cookies_gtk.cc
+++ b/chrome/browser/ui/gtk/collected_cookies_gtk.cc
@@ -77,17 +77,16 @@ const std::string GetInfobarLabel(ContentSetting setting,
return std::string();
}
}
+
} // namespace
CollectedCookiesGtk::CollectedCookiesGtk(GtkWindow* parent,
- TabContents* tab_contents)
- : tab_contents_(tab_contents),
+ TabContentsWrapper* wrapper)
+ : wrapper_(wrapper),
status_changed_(false) {
- TabSpecificContentSettings* content_settings =
- TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)->
- content_settings();
registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN,
- Source<TabSpecificContentSettings>(content_settings));
+ Source<TabSpecificContentSettings>(
+ wrapper->content_settings()));
Init();
}
@@ -164,7 +163,7 @@ void CollectedCookiesGtk::Init() {
blocked_cookies_tree_adapter_->Init();
EnableControls();
ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_)));
- window_ = new ConstrainedWindowGtk(tab_contents_, this);
+ window_ = new ConstrainedWindowGtk(wrapper_->tab_contents(), this);
}
GtkWidget* CollectedCookiesGtk::CreateAllowedPane() {
@@ -185,9 +184,7 @@ GtkWidget* CollectedCookiesGtk::CreateAllowedPane() {
GTK_SHADOW_ETCHED_IN);
gtk_box_pack_start(GTK_BOX(cookie_list_vbox), scroll_window, TRUE, TRUE, 0);
- TabSpecificContentSettings* content_settings =
- TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)->
- content_settings();
+ TabSpecificContentSettings* content_settings = wrapper_->content_settings();
allowed_cookies_tree_model_.reset(
content_settings->GetAllowedCookiesTreeModel());
@@ -241,10 +238,8 @@ GtkWidget* CollectedCookiesGtk::CreateAllowedPane() {
}
GtkWidget* CollectedCookiesGtk::CreateBlockedPane() {
- TabContentsWrapper* wrapper =
- TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_);
HostContentSettingsMap* host_content_settings_map =
- wrapper->profile()->GetHostContentSettingsMap();
+ wrapper_->profile()->GetHostContentSettingsMap();
GtkWidget* cookie_list_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing);
@@ -267,7 +262,7 @@ GtkWidget* CollectedCookiesGtk::CreateBlockedPane() {
GTK_SHADOW_ETCHED_IN);
gtk_box_pack_start(GTK_BOX(cookie_list_vbox), scroll_window, TRUE, TRUE, 0);
- TabSpecificContentSettings* content_settings = wrapper->content_settings();
+ TabSpecificContentSettings* content_settings = wrapper_->content_settings();
blocked_cookies_tree_model_.reset(
content_settings->GetBlockedCookiesTreeModel());
@@ -433,9 +428,8 @@ void CollectedCookiesGtk::Observe(int type,
void CollectedCookiesGtk::OnClose(GtkWidget* close_button) {
if (status_changed_) {
- TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)->
- infobar_tab_helper()->AddInfoBar(
- new CollectedCookiesInfoBarDelegate(tab_contents_));
+ wrapper_->infobar_tab_helper()->AddInfoBar(
+ new CollectedCookiesInfoBarDelegate(wrapper_->tab_contents()));
}
window_->CloseConstrainedWindow();
}
@@ -463,8 +457,7 @@ void CollectedCookiesGtk::AddExceptions(GtkTreeSelection* selection,
if (!last_domain_name.empty())
multiple_domains_added = true;
last_domain_name = origin_node->GetTitle();
- Profile* profile =
- Profile::FromBrowserContext(tab_contents_->browser_context());
+ Profile* profile = wrapper_->profile();
origin_node->CreateContentException(
profile->GetHostContentSettingsMap(), setting);
}
diff --git a/chrome/browser/ui/gtk/collected_cookies_gtk.h b/chrome/browser/ui/gtk/collected_cookies_gtk.h
index 0b5563b..18d739e 100644
--- a/chrome/browser/ui/gtk/collected_cookies_gtk.h
+++ b/chrome/browser/ui/gtk/collected_cookies_gtk.h
@@ -19,6 +19,7 @@
#include "ui/base/gtk/gtk_signal.h"
class CookiesTreeModel;
+class TabContentsWrapper;
// CollectedCookiesGtk is a dialog that displays the allowed and blocked
// cookies of the current tab contents. To display the dialog, invoke
@@ -26,10 +27,10 @@ class CookiesTreeModel;
// content settings tab helper.
class CollectedCookiesGtk : public ConstrainedWindowGtkDelegate,
- gtk_tree::TreeAdapter::Delegate,
- NotificationObserver {
+ public gtk_tree::TreeAdapter::Delegate,
+ public NotificationObserver {
public:
- CollectedCookiesGtk(GtkWindow* parent, TabContents* tab_contents);
+ CollectedCookiesGtk(GtkWindow* parent, TabContentsWrapper* wrapper);
// ConstrainedWindowGtkDelegate methods.
virtual GtkWidget* GetWidgetRoot();
@@ -112,8 +113,8 @@ class CollectedCookiesGtk : public ConstrainedWindowGtkDelegate,
// Displays information about selected cookie.
GtkWidget* cookie_info_view_;
- // The tab contents.
- TabContents* tab_contents_;
+ // The tab contents wrapper.
+ TabContentsWrapper* wrapper_;
bool status_changed_;
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc
index 118d741..b598ab9 100644
--- a/chrome/browser/ui/panels/panel.cc
+++ b/chrome/browser/ui/panels/panel.cc
@@ -316,7 +316,7 @@ void Panel::ShowRepostFormWarningDialog(TabContents* tab_contents) {
NOTIMPLEMENTED();
}
-void Panel::ShowCollectedCookiesDialog(TabContents* tab_contents) {
+void Panel::ShowCollectedCookiesDialog(TabContentsWrapper* wrapper) {
NOTIMPLEMENTED();
}
diff --git a/chrome/browser/ui/panels/panel.h b/chrome/browser/ui/panels/panel.h
index af9b6214..81b5548f2 100644
--- a/chrome/browser/ui/panels/panel.h
+++ b/chrome/browser/ui/panels/panel.h
@@ -103,7 +103,7 @@ class Panel : public BrowserWindow {
virtual bool IsDownloadShelfVisible() const OVERRIDE;
virtual DownloadShelf* GetDownloadShelf() OVERRIDE;
virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) OVERRIDE;
- virtual void ShowCollectedCookiesDialog(TabContents* tab_contents) OVERRIDE;
+ virtual void ShowCollectedCookiesDialog(TabContentsWrapper* wrapper) OVERRIDE;
virtual void ShowThemeInstallBubble() OVERRIDE;
virtual void ConfirmBrowserCloseWithPendingDownloads() OVERRIDE;
virtual gfx::NativeWindow ShowHTMLDialog(
diff --git a/chrome/browser/ui/views/browser_dialogs.h b/chrome/browser/ui/views/browser_dialogs.h
index a9575e53..f0f0026 100644
--- a/chrome/browser/ui/views/browser_dialogs.h
+++ b/chrome/browser/ui/views/browser_dialogs.h
@@ -83,7 +83,7 @@ void ShowRepostFormWarningDialog(gfx::NativeWindow parent_window,
// Shows the collected cookies dialog box.
void ShowCollectedCookiesDialog(gfx::NativeWindow parent_window,
- TabContents* tab_contents);
+ TabContentsWrapper* tab_contents);
// Shows the create web app shortcut dialog box.
diff --git a/chrome/browser/ui/views/collected_cookies_win.cc b/chrome/browser/ui/views/collected_cookies_win.cc
index 6780fa6..7aee53b 100644
--- a/chrome/browser/ui/views/collected_cookies_win.cc
+++ b/chrome/browser/ui/views/collected_cookies_win.cc
@@ -36,9 +36,9 @@ namespace browser {
// Declared in browser_dialogs.h so others don't have to depend on our header.
void ShowCollectedCookiesDialog(gfx::NativeWindow parent_window,
- TabContents* tab_contents) {
+ TabContentsWrapper* wrapper) {
// Deletes itself on close.
- new CollectedCookiesWin(parent_window, tab_contents);
+ new CollectedCookiesWin(parent_window, wrapper);
}
} // namespace browser
@@ -164,8 +164,8 @@ class InfobarView : public views::View {
// CollectedCookiesWin, constructor and destructor:
CollectedCookiesWin::CollectedCookiesWin(gfx::NativeWindow parent_window,
- TabContents* tab_contents)
- : tab_contents_(tab_contents),
+ TabContentsWrapper* wrapper)
+ : wrapper_(wrapper),
allowed_label_(NULL),
blocked_label_(NULL),
allowed_cookies_tree_(NULL),
@@ -175,15 +175,13 @@ CollectedCookiesWin::CollectedCookiesWin(gfx::NativeWindow parent_window,
for_session_blocked_button_(NULL),
infobar_(NULL),
status_changed_(false) {
- TabSpecificContentSettings* content_settings =
- TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)->
- content_settings();
+ TabSpecificContentSettings* content_settings = wrapper->content_settings();
registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN,
Source<TabSpecificContentSettings>(content_settings));
Init();
- window_ = new ConstrainedWindowViews(tab_contents_, this);
+ window_ = new ConstrainedWindowViews(wrapper->tab_contents(), this);
}
CollectedCookiesWin::~CollectedCookiesWin() {
@@ -238,9 +236,7 @@ void CollectedCookiesWin::Init() {
}
views::View* CollectedCookiesWin::CreateAllowedPane() {
- TabSpecificContentSettings* content_settings =
- TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)->
- content_settings();
+ TabSpecificContentSettings* content_settings = wrapper_->content_settings();
// Create the controls that go into the pane.
allowed_label_ = new views::Label(UTF16ToWide(l10n_util::GetStringUTF16(
@@ -288,12 +284,10 @@ views::View* CollectedCookiesWin::CreateAllowedPane() {
}
views::View* CollectedCookiesWin::CreateBlockedPane() {
- TabContentsWrapper* wrapper =
- TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_);
- TabSpecificContentSettings* content_settings = wrapper->content_settings();
+ TabSpecificContentSettings* content_settings = wrapper_->content_settings();
HostContentSettingsMap* host_content_settings_map =
- wrapper->profile()->GetHostContentSettingsMap();
+ wrapper_->profile()->GetHostContentSettingsMap();
// Create the controls that go into the pane.
blocked_label_ = new views::Label(
@@ -379,9 +373,8 @@ void CollectedCookiesWin::DeleteDelegate() {
bool CollectedCookiesWin::Cancel() {
if (status_changed_) {
- TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)->
- infobar_tab_helper()->AddInfoBar(
- new CollectedCookiesInfoBarDelegate(tab_contents_));
+ wrapper_->infobar_tab_helper()->AddInfoBar(
+ new CollectedCookiesInfoBarDelegate(wrapper_->tab_contents()));
}
return true;
@@ -486,8 +479,7 @@ void CollectedCookiesWin::AddContentException(views::TreeView* tree_view,
ContentSetting setting) {
CookieTreeOriginNode* origin_node =
static_cast<CookieTreeOriginNode*>(tree_view->GetSelectedNode());
- Profile* profile =
- Profile::FromBrowserContext(tab_contents_->browser_context());
+ Profile* profile = wrapper_->profile();
origin_node->CreateContentException(profile->GetHostContentSettingsMap(),
setting);
infobar_->UpdateVisibility(true, setting, origin_node->GetTitle());
@@ -500,7 +492,8 @@ void CollectedCookiesWin::AddContentException(views::TreeView* tree_view,
// window, while NativeWidgetWin::SetBounds wants screen coordinates. Do the
// translation here until http://crbug.com/52851 is fixed.
POINT topleft = {bounds.x(), bounds.y()};
- MapWindowPoints(HWND_DESKTOP, tab_contents_->GetNativeView(), &topleft, 1);
+ MapWindowPoints(HWND_DESKTOP, wrapper_->tab_contents()->GetNativeView(),
+ &topleft, 1);
gfx::Size size = GetWidget()->GetRootView()->GetPreferredSize();
bounds.SetRect(topleft.x, topleft.y, size.width(), size.height());
GetWidget()->SetBounds(bounds);
diff --git a/chrome/browser/ui/views/collected_cookies_win.h b/chrome/browser/ui/views/collected_cookies_win.h
index ad74996..713222e 100644
--- a/chrome/browser/ui/views/collected_cookies_win.h
+++ b/chrome/browser/ui/views/collected_cookies_win.h
@@ -20,6 +20,7 @@ class CookieInfoView;
class CookiesTreeModel;
class InfobarView;
class TabContents;
+class TabContentsWrapper;
namespace views {
class Label;
@@ -41,7 +42,7 @@ class CollectedCookiesWin : public views::DialogDelegate,
public:
// Use BrowserWindow::ShowCollectedCookiesDialog to show.
CollectedCookiesWin(gfx::NativeWindow parent_window,
- TabContents* tab_contents);
+ TabContentsWrapper* wrapper);
// views::DialogDelegate:
virtual std::wstring GetWindowTitle() const OVERRIDE;
@@ -89,7 +90,7 @@ class CollectedCookiesWin : public views::DialogDelegate,
ConstrainedWindow* window_;
// The tab contents.
- TabContents* tab_contents_;
+ TabContentsWrapper* wrapper_;
// Assorted views.
views::Label* allowed_label_;
diff --git a/chrome/browser/ui/views/dialog_stubs_gtk.cc b/chrome/browser/ui/views/dialog_stubs_gtk.cc
index e0b70fc..bf0b5cb 100644
--- a/chrome/browser/ui/views/dialog_stubs_gtk.cc
+++ b/chrome/browser/ui/views/dialog_stubs_gtk.cc
@@ -41,11 +41,11 @@ void ShowRepostFormWarningDialog(gfx::NativeWindow parent_window,
}
void ShowCollectedCookiesDialog(gfx::NativeWindow parent_window,
- TabContents* tab_contents) {
+ TabContentsWrapper* wrapper) {
#if defined(OS_CHROMEOS)
- CollectedCookiesUIDelegate::Show(tab_contents);
+ CollectedCookiesUIDelegate::Show(wrapper);
#else
- new CollectedCookiesGtk(GTK_WINDOW(parent_window), tab_contents);
+ new CollectedCookiesGtk(GTK_WINDOW(parent_window), wrapper);
#endif
}
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index d77882c..83646e1 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1142,8 +1142,8 @@ void BrowserView::ShowRepostFormWarningDialog(TabContents* tab_contents) {
browser::ShowRepostFormWarningDialog(GetNativeHandle(), tab_contents);
}
-void BrowserView::ShowCollectedCookiesDialog(TabContents* tab_contents) {
- browser::ShowCollectedCookiesDialog(GetNativeHandle(), tab_contents);
+void BrowserView::ShowCollectedCookiesDialog(TabContentsWrapper* wrapper) {
+ browser::ShowCollectedCookiesDialog(GetNativeHandle(), wrapper);
}
void BrowserView::ShowThemeInstallBubble() {
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index ca1c525..8015321 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -307,7 +307,7 @@ class BrowserView : public BrowserBubbleHost,
virtual bool IsDownloadShelfVisible() const OVERRIDE;
virtual DownloadShelf* GetDownloadShelf() OVERRIDE;
virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) OVERRIDE;
- virtual void ShowCollectedCookiesDialog(TabContents* tab_contents) OVERRIDE;
+ virtual void ShowCollectedCookiesDialog(TabContentsWrapper* wrapper) OVERRIDE;
virtual void ShowThemeInstallBubble() OVERRIDE;
virtual void ConfirmBrowserCloseWithPendingDownloads() OVERRIDE;
virtual gfx::NativeWindow ShowHTMLDialog(
diff --git a/chrome/browser/ui/webui/collected_cookies_ui_delegate.cc b/chrome/browser/ui/webui/collected_cookies_ui_delegate.cc
index 0ad2f38..9ab9743 100644
--- a/chrome/browser/ui/webui/collected_cookies_ui_delegate.cc
+++ b/chrome/browser/ui/webui/collected_cookies_ui_delegate.cc
@@ -130,22 +130,19 @@ void CollectedCookiesSource::StartDataRequest(const std::string& path,
} // namespace
// static
-void CollectedCookiesUIDelegate::Show(TabContents* tab_contents) {
+void CollectedCookiesUIDelegate::Show(TabContentsWrapper* wrapper) {
CollectedCookiesUIDelegate* delegate =
- new CollectedCookiesUIDelegate(tab_contents);
- Profile* profile =
- Profile::FromBrowserContext(tab_contents->browser_context());
+ new CollectedCookiesUIDelegate(wrapper);
+ Profile* profile = wrapper->profile();
ConstrainedHtmlUI::CreateConstrainedHtmlDialog(profile,
delegate,
- tab_contents);
+ wrapper->tab_contents());
}
CollectedCookiesUIDelegate::CollectedCookiesUIDelegate(
- TabContents* tab_contents)
- : tab_contents_(tab_contents),
+ TabContentsWrapper* wrapper)
+ : wrapper_(wrapper),
closed_(false) {
- TabContentsWrapper* wrapper =
- TabContentsWrapper::GetCurrentWrapperForContents(tab_contents);
TabSpecificContentSettings* content_settings = wrapper->content_settings();
HostContentSettingsMap* host_content_settings_map =
wrapper->profile()->GetHostContentSettingsMap();
@@ -229,8 +226,7 @@ void CollectedCookiesUIDelegate::SetInfobarLabel(const std::string& text) {
void CollectedCookiesUIDelegate::AddContentException(
CookieTreeOriginNode* origin_node, ContentSetting setting) {
if (origin_node->CanCreateContentException()) {
- Profile* profile =
- Profile::FromBrowserContext(tab_contents_->browser_context());
+ Profile* profile = wrapper_->profile();
origin_node->CreateContentException(profile->GetHostContentSettingsMap(),
setting);
diff --git a/chrome/browser/ui/webui/collected_cookies_ui_delegate.h b/chrome/browser/ui/webui/collected_cookies_ui_delegate.h
index e9d52e5..3f1a86c 100644
--- a/chrome/browser/ui/webui/collected_cookies_ui_delegate.h
+++ b/chrome/browser/ui/webui/collected_cookies_ui_delegate.h
@@ -18,6 +18,7 @@
class GURL;
class TabContents;
+class TabContentsWrapper;
namespace gfx {
class Size;
@@ -30,7 +31,7 @@ class CollectedCookiesUIDelegate : public HtmlDialogUIDelegate,
virtual ~CollectedCookiesUIDelegate();
// static factory method that shows CollectedCookiesUI for |tab_contents|.
- static void Show(TabContents* tab_contents);
+ static void Show(TabContentsWrapper* wrapper);
// HtmlDialogUIDelegate implementation:
virtual bool IsDialogModal() const OVERRIDE;
@@ -49,7 +50,7 @@ class CollectedCookiesUIDelegate : public HtmlDialogUIDelegate,
virtual void RegisterMessages();
private:
- explicit CollectedCookiesUIDelegate(TabContents* tab_contents);
+ explicit CollectedCookiesUIDelegate(TabContentsWrapper* wrapper);
// Closes the dialog from javascript.
void CloseDialog();
@@ -75,7 +76,7 @@ class CollectedCookiesUIDelegate : public HtmlDialogUIDelegate,
void AllowThisSession(const base::ListValue* args);
NotificationRegistrar registrar_;
- TabContents* tab_contents_;
+ TabContentsWrapper* wrapper_;
bool closed_;
scoped_ptr<CookiesTreeModel> allowed_cookies_tree_model_;
diff --git a/chrome/test/base/test_browser_window.h b/chrome/test/base/test_browser_window.h
index 4878800..d3bbb6c 100644
--- a/chrome/test/base/test_browser_window.h
+++ b/chrome/test/base/test_browser_window.h
@@ -85,7 +85,8 @@ class TestBrowserWindow : public BrowserWindow {
virtual DownloadShelf* GetDownloadShelf() OVERRIDE;
virtual void ShowRepostFormWarningDialog(
TabContents* tab_contents) OVERRIDE {}
- virtual void ShowCollectedCookiesDialog(TabContents* tab_contents) OVERRIDE {}
+ virtual void ShowCollectedCookiesDialog(
+ TabContentsWrapper* wrapper) OVERRIDE {}
virtual void ShowThemeInstallBubble() OVERRIDE {}
virtual void ConfirmBrowserCloseWithPendingDownloads() OVERRIDE {}
virtual gfx::NativeWindow ShowHTMLDialog(