summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-08 19:38:31 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-08 19:38:31 +0000
commitb6c874589ef2f9212314ef9d2a5f1cfc19046fe7 (patch)
tree1e42e52695c5ce65654180e296afb56294b9e99d /chrome/browser/tab_contents
parent24df63781910c204fa57ac06406c0883dacc366d (diff)
downloadchromium_src-b6c874589ef2f9212314ef9d2a5f1cfc19046fe7.zip
chromium_src-b6c874589ef2f9212314ef9d2a5f1cfc19046fe7.tar.gz
chromium_src-b6c874589ef2f9212314ef9d2a5f1cfc19046fe7.tar.bz2
Various popup UI fixes:
* Remove "show popup notification" option, pref, and all associated machinery. * Toggling whitelisting on for a site no longer hides the "manage" button. * Toggling whitelisting off for a site re-blocks (not closes) its popups, and does not hide the "manage" button. Also rips the whitelist hooks out of TabContents in preparation for getting the whitelist values directly from the BlockedPopupContainer, since there was no reason to plumb everything through TabContents. BUG=11440 Review URL: http://codereview.chromium.org/115112 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15670 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc53
-rw-r--r--chrome/browser/tab_contents/tab_contents.h13
-rw-r--r--chrome/browser/tab_contents/tab_contents_delegate.h11
3 files changed, 22 insertions, 55 deletions
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index e932939..9cea219 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -389,8 +389,6 @@ void TabContents::RegisterUserPrefs(PrefService* prefs) {
IDS_USES_UNIVERSAL_DETECTOR);
prefs->RegisterLocalizedStringPref(prefs::kStaticEncodings,
IDS_STATIC_ENCODING_LIST);
-
- prefs->RegisterBooleanPref(prefs::kBlockPopups, false);
}
bool TabContents::SupportsURL(GURL* url) {
@@ -799,27 +797,16 @@ void TabContents::AddNewContents(TabContents* new_contents,
!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisablePopupBlocking)) {
// Unrequested popups from normal pages are constrained unless they're in
- // the whitelist.
- std::string host;
- if (creator_url.is_valid())
- host = creator_url.host();
- constrain_popup = true; // TODO(pkasting): Add whitelist
-
- TabContents* our_owner = delegate_->GetConstrainingContents(this);
- TabContents* popup_owner = our_owner ? our_owner : this;
- if (constrain_popup)
- popup_owner->AddConstrainedPopup(new_contents, initial_pos, host);
- else
- popup_owner->OnPopupOpenedFromWhitelistedHost(host);
- }
- if (!constrain_popup) {
+ // the whitelist. The popup owner will handle checking this.
+ delegate_->GetConstrainingContents(this)->AddPopup(new_contents,
+ initial_pos,
+ creator_url.is_valid() ? creator_url.host() : std::string());
+ } else {
new_contents->DisassociateFromPopupCount();
-
delegate_->AddNewContents(this, new_contents, disposition, initial_pos,
user_gesture);
-
- PopupNotificationVisibilityChanged(ShowingBlockedPopupNotification());
}
+ PopupNotificationVisibilityChanged(ShowingBlockedPopupNotification());
#else
// TODO(port): implement the popup blocker stuff
delegate_->AddNewContents(this, new_contents, disposition, initial_pos,
@@ -959,15 +946,9 @@ void TabContents::ToolbarSizeChanged(bool is_animating) {
void TabContents::OnStartDownload(DownloadItem* download) {
DCHECK(download);
- TabContents* tab_contents = this;
-// TODO(port): port contraining contents.
-#if defined(OS_WIN)
// Download in a constrained popup is shown in the tab that opened it.
- TabContents* constraining_tab = delegate()->GetConstrainingContents(this);
- if (constraining_tab)
- tab_contents = constraining_tab;
-#endif
+ TabContents* tab_contents = delegate()->GetConstrainingContents(this);
// GetDownloadShelf creates the download shelf if it was not yet created.
tab_contents->GetDownloadShelf()->AddDownload(
@@ -1135,12 +1116,6 @@ bool TabContents::IsActiveEntry(int32 page_id) {
active_entry->page_id() == page_id);
}
-#if defined(OS_WIN)
-void TabContents::SetWhitelistForHost(const std::string& host, bool whitelist) {
- // TODO(pkasting): Add whitelist
-}
-#endif
-
// Notifies the RenderWidgetHost instance about the fact that the page is
// loading, or done loading and calls the base implementation.
void TabContents::SetIsLoading(bool is_loading,
@@ -1187,17 +1162,11 @@ void TabContents::CreateBlockedPopupContainerIfNecessary() {
child_windows_.push_back(blocked_popups_);
}
-void TabContents::AddConstrainedPopup(TabContents* new_contents,
- const gfx::Rect& initial_pos,
- const std::string& host) {
+void TabContents::AddPopup(TabContents* new_contents,
+ const gfx::Rect& initial_pos,
+ const std::string& host) {
CreateBlockedPopupContainerIfNecessary();
blocked_popups_->AddTabContents(new_contents, initial_pos, host);
- PopupNotificationVisibilityChanged(ShowingBlockedPopupNotification());
-}
-
-void TabContents::OnPopupOpenedFromWhitelistedHost(const std::string& host) {
- CreateBlockedPopupContainerIfNecessary();
- blocked_popups_->OnPopupOpenedFromWhitelistedHost(host);
}
// TODO(brettw) This should be on the TabContentsView.
@@ -2032,7 +2001,7 @@ void TabContents::RunJavaScriptMessage(
bool suppress_this_message = suppress_javascript_messages_;
if (delegate())
suppress_this_message |=
- (delegate()->GetConstrainingContents(this) != NULL);
+ (delegate()->GetConstrainingContents(this) != this);
*did_suppress_message = suppress_this_message;
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index a546df5..4f938a2 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -565,9 +565,6 @@ class TabContents : public PageNavigator,
render_view_host()->WindowMoveOrResizeStarted();
}
- // Sets popup whitelisting state for |host| to |whitelist|.
- void SetWhitelistForHost(const std::string& host, bool whitelist);
-
private:
friend class NavigationController;
// Used to access the child_windows_ (ConstrainedWindowList) for testing
@@ -621,13 +618,9 @@ class TabContents : public PageNavigator,
void CreateBlockedPopupContainerIfNecessary();
// Adds the incoming |new_contents| to the |blocked_popups_| container.
- void AddConstrainedPopup(TabContents* new_contents,
- const gfx::Rect& initial_pos,
- const std::string& host);
-
- // Notifies the |blocked_popups_| container that a popup has been opened from
- // a particular whitelisted host.
- void OnPopupOpenedFromWhitelistedHost(const std::string& host);
+ void AddPopup(TabContents* new_contents,
+ const gfx::Rect& initial_pos,
+ const std::string& host);
// Called by a derived class when the TabContents is resized, causing
// suppressed constrained web popups to be repositioned to the new bounds
diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h
index ad7ac1e..3485fb8 100644
--- a/chrome/browser/tab_contents/tab_contents_delegate.h
+++ b/chrome/browser/tab_contents/tab_contents_delegate.h
@@ -64,13 +64,18 @@ class TabContentsDelegate {
// in screen coordinates.
virtual void MoveContents(TabContents* source, const gfx::Rect& pos) = 0;
+ // Causes the delegate to detach |source| and clean up any internal data
+ // pointing to it. After this call ownership of |source| passes to the
+ // caller, and it is safe to call "source->set_delegate(someone_else);".
+ virtual void DetachContents(TabContents* source) { }
+
// Called to determine if the TabContents is contained in a popup window.
virtual bool IsPopup(TabContents* source) = 0;
- // Returns the tab which contains the specified tab content if it is
- // constrained, NULL otherwise.
+ // If |source| is constrained, returns the tab containing it. Otherwise
+ // returns |source|.
virtual TabContents* GetConstrainingContents(TabContents* source) {
- return NULL;
+ return source;
}
// Notification that some of our content has changed size as