summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/views/blocked_popup_container.cc38
-rw-r--r--chrome/browser/views/blocked_popup_container.h8
2 files changed, 26 insertions, 20 deletions
diff --git a/chrome/browser/views/blocked_popup_container.cc b/chrome/browser/views/blocked_popup_container.cc
index fb324b0..b315976 100644
--- a/chrome/browser/views/blocked_popup_container.cc
+++ b/chrome/browser/views/blocked_popup_container.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/views/blocked_popup_container.h"
+#include <math.h>
+
#include "chrome/app/theme/theme_resources.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents.h"
@@ -19,8 +21,9 @@
#include "generated_resources.h"
-#include <math.h>
-
+// Menu item ID for the "Notify me when a popup is blocked" checkbox. (All
+// other menu IDs are positive and should be base 1 indexies into the vector of
+// blocked popups.)
const int kNotifyMenuItem = -1;
// A number larger than the internal popup count on the Renderer; meant for
@@ -28,11 +31,10 @@ const int kNotifyMenuItem = -1;
// infinite windows.
const int kImpossibleNumberOfPopups = 30;
-// A small border around all widgets
+// The minimal border around the edge of the notification.
const int kSmallPadding = 2;
-// The background color of the blocked popup notification
-//static const SkColor kBackgroundColor = SkColorSetRGB(222, 234, 248);
+// The background color of the blocked popup notification.
static const SkColor kBackgroundColorTop = SkColorSetRGB(255, 242, 183);
static const SkColor kBackgroundColorBottom = SkColorSetRGB(250, 230, 145);
@@ -47,10 +49,11 @@ static const int kShowAnimationDurationMS = 200;
static const int kHideAnimationDurationMS = 120;
static const int kFramerate = 25;
-// Rounded corner radius (in pixels)
+// Rounded corner radius (in pixels).
static const int kBackgroundCornerRadius = 4;
-// Rounded corner definition for the
+// Rounded corner definition so the top corners are rounded, and the bottom are
+// normal 90 degree angles.
static const SkScalar kRoundedCornerRad[8] = {
// Top left corner
SkIntToScalar(kBackgroundCornerRadius),
@@ -104,7 +107,7 @@ class BlockedPopupContainerView : public views::View,
// Our "X" button.
views::Button* close_button_;
- /// Popup menu shown to user.
+ // Popup menu shown to user.
scoped_ptr<Menu> launch_menu_;
};
@@ -147,8 +150,8 @@ void BlockedPopupContainerView::UpdatePopupCountLabel() {
}
void BlockedPopupContainerView::Paint(ChromeCanvas* canvas) {
+ // Draw the standard background.
View::Paint(canvas);
- // Draw the standard background
SkRect rect;
rect.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
@@ -200,7 +203,6 @@ gfx::Size BlockedPopupContainerView::GetPreferredSize() {
void BlockedPopupContainerView::ButtonPressed(views::BaseButton* sender) {
if (sender == popup_count_label_) {
- // Menu goes here.
launch_menu_.reset(new Menu(this, Menu::TOPLEFT, container_->GetHWND()));
int item_count = container_->GetTabContentsCount();
@@ -275,7 +277,7 @@ void BlockedPopupContainer::ToggleBlockedPopupNotification() {
}
bool BlockedPopupContainer::GetShowBlockedPopupNotification() {
- return ! block_popup_pref_.GetValue();
+ return !block_popup_pref_.GetValue();
}
void BlockedPopupContainer::AddTabContents(TabContents* blocked_contents,
@@ -339,7 +341,7 @@ void BlockedPopupContainer::CloseAllPopups() {
HideSelf();
}
-/////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Override from ConstrainedWindow:
void BlockedPopupContainer::CloseConstrainedWindow() {
@@ -370,10 +372,11 @@ const gfx::Rect& BlockedPopupContainer::GetCurrentBounds() const {
return bounds_;
}
-/////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Override from TabContentsDelegate:
void BlockedPopupContainer::OpenURLFromTab(TabContents* source,
- const GURL& url, const GURL& referrer,
+ const GURL& url,
+ const GURL& referrer,
WindowOpenDisposition disposition,
PageTransition::Type transition) {
owner_->OpenURL(url, referrer, disposition, transition);
@@ -442,7 +445,7 @@ TabContents* BlockedPopupContainer::GetConstrainingContents(
return owner_;
}
-/////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Override from Animation:
void BlockedPopupContainer::AnimateToState(double state) {
if (in_show_animation_)
@@ -453,7 +456,7 @@ void BlockedPopupContainer::AnimateToState(double state) {
SetPosition();
}
-/////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// Override from views::ContainerWin:
void BlockedPopupContainer::OnFinalMessage(HWND window) {
owner_->WillClose(this);
@@ -520,7 +523,8 @@ void BlockedPopupContainer::SetPosition() {
SetWindowPos(HWND_TOP, base_x, real_y, size.width(), real_height, 0);
container_view_->SchedulePaint();
} else {
- SetWindowPos(HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_HIDEWINDOW);
+ SetWindowPos(HWND_TOP, 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_HIDEWINDOW);
}
}
diff --git a/chrome/browser/views/blocked_popup_container.h b/chrome/browser/views/blocked_popup_container.h
index de59a1e..0ae552e 100644
--- a/chrome/browser/views/blocked_popup_container.h
+++ b/chrome/browser/views/blocked_popup_container.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_VIEWS_BLOCKED_POPUP_CONTAINER_H_
#define CHROME_BROWSER_VIEWS_BLOCKED_POPUP_CONTAINER_H_
+#include <utility>
#include <vector>
#include "base/gfx/rect.h"
@@ -129,14 +130,15 @@ class BlockedPopupContainer : public ConstrainedWindow,
// The TabContents that owns and constrains this BlockedPopupContainer.
TabContents* owner_;
- // TabContents.
+ // The TabContents and initial positions of all blocked popups.
std::vector<std::pair<TabContents*, gfx::Rect> > blocked_popups_;
// Our associated view object.
BlockedPopupContainerView* container_view_;
- // Link to the show blocked popup preference. Used to both determine whether
- // we should show ourself to the user...
+ // Link to the block popups preference. Used to both determine whether we
+ // should show ourself to the user and to toggle whether we should show this
+ // notification to the user.
BooleanPrefMember block_popup_pref_;
// Once the container is hidden, this is set to prevent it from reappearing.