summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-17 21:31:16 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-17 21:31:16 +0000
commit28f3c9251dace27b202d71203756fecbbe3cbc15 (patch)
tree7732616ae8527e9603333871d6a4015cd55be4ff /chrome
parent7312f42a14b8d0717cd44bea53690eb27486e32d (diff)
downloadchromium_src-28f3c9251dace27b202d71203756fecbbe3cbc15.zip
chromium_src-28f3c9251dace27b202d71203756fecbbe3cbc15.tar.gz
chromium_src-28f3c9251dace27b202d71203756fecbbe3cbc15.tar.bz2
Revert 105922 - views: Implementation of the new fullscreen bubble.
Due to the base class changing, this also touches the GTK UI, but the GTK changes should be mostly no-ops. Based on a patch by Yuzhu Shen <yzshen@chromium.org> BUG=95136, 100266 TEST=none Review URL: http://codereview.chromium.org/8321016 TBR=thakis@chromium.org Review URL: http://codereview.chromium.org/8318026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105924 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/ui/fullscreen_exit_bubble.cc44
-rw-r--r--chrome/browser/ui/fullscreen_exit_bubble.h30
-rw-r--r--chrome/browser/ui/fullscreen_exit_bubble_type.cc13
-rw-r--r--chrome/browser/ui/fullscreen_exit_bubble_type.h5
-rw-r--r--chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc20
-rw-r--r--chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.h1
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc21
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h10
-rw-r--r--chrome/browser/ui/views/fullscreen_exit_bubble_views.cc169
-rw-r--r--chrome/browser/ui/views/fullscreen_exit_bubble_views.h9
10 files changed, 112 insertions, 210 deletions
diff --git a/chrome/browser/ui/fullscreen_exit_bubble.cc b/chrome/browser/ui/fullscreen_exit_bubble.cc
index 111189e..8bca0a9 100644
--- a/chrome/browser/ui/fullscreen_exit_bubble.cc
+++ b/chrome/browser/ui/fullscreen_exit_bubble.cc
@@ -4,11 +4,8 @@
#include "chrome/browser/ui/fullscreen_exit_bubble.h"
-#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/browser.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/rect.h"
const int FullscreenExitBubble::kPaddingPx = 8;
@@ -20,13 +17,8 @@ const int FullscreenExitBubble::kSlideInDurationMs = 350;
const int FullscreenExitBubble::kSlideOutDurationMs = 700;
const int FullscreenExitBubble::kPopupTopPx = 15;
-FullscreenExitBubble::FullscreenExitBubble(Browser* browser,
- const GURL& url,
- FullscreenExitBubbleType bubble_type)
- : browser_(browser),
- url_(url),
- bubble_type_(bubble_type) {
- DCHECK_NE(FEB_TYPE_NONE, bubble_type_);
+FullscreenExitBubble::FullscreenExitBubble(Browser* browser)
+ : browser_(browser) {
}
FullscreenExitBubble::~FullscreenExitBubble() {
@@ -44,12 +36,6 @@ void FullscreenExitBubble::StartWatchingMouse() {
&FullscreenExitBubble::CheckMousePosition);
}
-void FullscreenExitBubble::StopWatchingMouse() {
- initial_delay_.Stop();
- idle_timeout_.Stop();
- mouse_position_checker_.Stop();
-}
-
void FullscreenExitBubble::CheckMousePosition() {
// Desired behavior:
//
@@ -103,30 +89,10 @@ void FullscreenExitBubble::ToggleFullscreen() {
browser_->ExecuteCommand(IDC_FULLSCREEN);
}
-void FullscreenExitBubble::Accept() {
- // TODO(yzshen): Pass bubble_type_ to OnAcceptFullscreenPermission() once it
- // accepts it.
- browser_->OnAcceptFullscreenPermission(url_);
+void FullscreenExitBubble::AcceptFullscreen(const GURL& url) {
+ browser_->OnAcceptFullscreenPermission(url);
}
-void FullscreenExitBubble::Cancel() {
- // TODO(yzshen): Pass bubble_type_ to OnDenyFullscreenPermission() once it
- // accepts it.
+void FullscreenExitBubble::CancelFullscreen() {
browser_->OnDenyFullscreenPermission();
}
-
-string16 FullscreenExitBubble::GetCurrentMessageText() const {
- return fullscreen_bubble::GetLabelTextForType(bubble_type_, url_);
-}
-
-string16 FullscreenExitBubble::GetCurrentDenyButtonText() const {
- return fullscreen_bubble::GetDenyButtonTextForType(bubble_type_);
-}
-
-string16 FullscreenExitBubble::GetAllowButtonText() const {
- return l10n_util::GetStringUTF16(IDS_FULLSCREEN_ALLOW);
-}
-
-string16 FullscreenExitBubble::GetInstructionText() const {
- return l10n_util::GetStringUTF16(IDS_FULLSCREEN_PRESS_ESC_TO_EXIT);
-}
diff --git a/chrome/browser/ui/fullscreen_exit_bubble.h b/chrome/browser/ui/fullscreen_exit_bubble.h
index 50eb675..ab4ddb8 100644
--- a/chrome/browser/ui/fullscreen_exit_bubble.h
+++ b/chrome/browser/ui/fullscreen_exit_bubble.h
@@ -9,7 +9,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/timer.h"
#include "chrome/browser/command_updater.h"
-#include "chrome/browser/ui/fullscreen_exit_bubble_type.h"
#include "googleurl/src/gurl.h"
#include "ui/base/animation/animation_delegate.h"
#include "ui/gfx/point.h"
@@ -26,9 +25,7 @@ class Rect;
class FullscreenExitBubble : public ui::AnimationDelegate {
public:
- explicit FullscreenExitBubble(Browser* browser,
- const GURL& url,
- FullscreenExitBubbleType bubble_type);
+ explicit FullscreenExitBubble(Browser* browser);
virtual ~FullscreenExitBubble();
protected:
@@ -36,9 +33,8 @@ class FullscreenExitBubble : public ui::AnimationDelegate {
static const int kInitialDelayMs; // Initial time bubble remains onscreen
static const int kIdleTimeMs; // Time before mouse idle triggers hide
static const int kPositionCheckHz; // How fast to check the mouse position
- static const int kSlideInRegionHeightPx;
- // Height of region triggering
- // slide-in
+ static const int kSlideInRegionHeightPx; // Height of region triggering
+ // slide-in
static const int kPopupTopPx; // Space between the popup and the top
// of the screen.
static const int kSlideInDurationMs; // Duration of slide-in animation
@@ -68,19 +64,10 @@ class FullscreenExitBubble : public ui::AnimationDelegate {
void CheckMousePosition();
void StartWatchingMouse();
- void StopWatchingMouse();
void ToggleFullscreen();
- void Accept();
- void Cancel();
-
- // The following strings may change according to the content type and URL.
- string16 GetCurrentMessageText() const;
- string16 GetCurrentDenyButtonText() const;
-
- // The following strings never change.
- string16 GetAllowButtonText() const;
- string16 GetInstructionText() const;
+ void AcceptFullscreen(const GURL& url);
+ void CancelFullscreen();
// The browser this bubble is in.
Browser* browser_;
@@ -102,13 +89,6 @@ class FullscreenExitBubble : public ui::AnimationDelegate {
// The most recently seen mouse position, in screen coordinates. Used to see
// if the mouse has moved since our last check.
gfx::Point last_mouse_pos_;
-
- protected:
- // The host the bubble is for, can be empty.
- GURL url_;
-
- // The type of the bubble; controls e.g. which buttons to show.
- FullscreenExitBubbleType bubble_type_;
};
#endif // CHROME_BROWSER_UI_FULLSCREEN_EXIT_BUBBLE_H_
diff --git a/chrome/browser/ui/fullscreen_exit_bubble_type.cc b/chrome/browser/ui/fullscreen_exit_bubble_type.cc
index 6d0c76f..d346dcb 100644
--- a/chrome/browser/ui/fullscreen_exit_bubble_type.cc
+++ b/chrome/browser/ui/fullscreen_exit_bubble_type.cc
@@ -92,17 +92,4 @@ bool ShowButtonsForType(FullscreenExitBubbleType type) {
type == FEB_TYPE_MOUSELOCK_BUTTONS;
}
-void PermissionRequestedByType(FullscreenExitBubbleType type,
- bool* tab_fullscreen,
- bool* mouse_lock) {
- if (tab_fullscreen) {
- *tab_fullscreen = type == FEB_TYPE_FULLSCREEN_BUTTONS ||
- type == FEB_TYPE_FULLSCREEN_MOUSELOCK_BUTTONS;
- }
- if (mouse_lock) {
- *mouse_lock = type == FEB_TYPE_FULLSCREEN_MOUSELOCK_BUTTONS ||
- type == FEB_TYPE_MOUSELOCK_BUTTONS;
- }
-}
-
} // namespace
diff --git a/chrome/browser/ui/fullscreen_exit_bubble_type.h b/chrome/browser/ui/fullscreen_exit_bubble_type.h
index 4d2507a..bf77bd7 100644
--- a/chrome/browser/ui/fullscreen_exit_bubble_type.h
+++ b/chrome/browser/ui/fullscreen_exit_bubble_type.h
@@ -35,10 +35,7 @@ string16 GetLabelTextForType(
FullscreenExitBubbleType type, const GURL& url);
string16 GetDenyButtonTextForType(FullscreenExitBubbleType type);
bool ShowButtonsForType(FullscreenExitBubbleType type);
-void PermissionRequestedByType(FullscreenExitBubbleType type,
- bool* tab_fullscreen,
- bool* mouse_lock);
-} // namespace fullscreen_bubble
+} // namespace fullscreen
#endif // CHROME_BROWSER_UI_FULLSCREEN_EXIT_BUBBLE_TYPE_H_
diff --git a/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc b/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc
index 43b4eda..c140e73 100644
--- a/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc
+++ b/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.cc
@@ -25,11 +25,9 @@ FullscreenExitBubbleGtk::FullscreenExitBubbleGtk(
Browser* browser,
const GURL& url,
bool ask_permission)
- : FullscreenExitBubble(
- browser, url,
- ask_permission ? FEB_TYPE_FULLSCREEN_BUTTONS :
- FEB_TYPE_FULLSCREEN_EXIT_INSTRUCTION),
+ : FullscreenExitBubble(browser),
container_(container),
+ url_(url),
show_buttons_(ask_permission) {
InitWidgets();
}
@@ -55,9 +53,9 @@ void FullscreenExitBubbleGtk::InitWidgets() {
GtkWidget* button_link_hbox = gtk_hbox_new(false, ui::kControlSpacing);
allow_button_ = gtk_button_new_with_label(
- l10n_util::GetStringUTF8(IDS_FULLSCREEN_ALLOW).c_str());
+ l10n_util::GetStringUTF8(IDS_FULLSCREEN_INFOBAR_ALLOW).c_str());
deny_button_ = gtk_button_new_with_label(
- l10n_util::GetStringUTF8(IDS_FULLSCREEN_DENY).c_str());
+ l10n_util::GetStringUTF8(IDS_FULLSCREEN_INFOBAR_DENY).c_str());
gtk_box_pack_end(GTK_BOX(button_link_hbox), deny_button_, FALSE, FALSE, 0);
gtk_box_pack_end(GTK_BOX(button_link_hbox), allow_button_, FALSE, FALSE, 0);
gtk_box_pack_end(GTK_BOX(button_link_hbox), link_, FALSE, FALSE, 0);
@@ -121,11 +119,11 @@ void FullscreenExitBubbleGtk::InitWidgets() {
std::string FullscreenExitBubbleGtk::GetMessage(const GURL& url) {
if (url.is_empty()) {
return l10n_util::GetStringUTF8(
- IDS_FULLSCREEN_USER_ENTERED_FULLSCREEN);
+ IDS_FULLSCREEN_INFOBAR_USER_ENTERED_FULLSCREEN);
}
if (url.SchemeIsFile())
- return l10n_util::GetStringUTF8(IDS_FULLSCREEN_ENTERED_FULLSCREEN);
- return l10n_util::GetStringFUTF8(IDS_FULLSCREEN_SITE_ENTERED_FULLSCREEN,
+ return l10n_util::GetStringUTF8(IDS_FULLSCREEN_INFOBAR_FILE_PAGE_NAME);
+ return l10n_util::GetStringFUTF8(IDS_FULLSCREEN_INFOBAR_REQUEST_PERMISSION,
UTF8ToUTF16(url.host()));
}
@@ -212,9 +210,9 @@ void FullscreenExitBubbleGtk::HideButtons() {
}
void FullscreenExitBubbleGtk::OnAllowClicked(GtkWidget* button) {
- Accept();
+ AcceptFullscreen(url_);
HideButtons();
}
void FullscreenExitBubbleGtk::OnDenyClicked(GtkWidget* button) {
- Cancel();
+ CancelFullscreen();
}
diff --git a/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.h b/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.h
index c23a129..8528315 100644
--- a/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.h
+++ b/chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.h
@@ -68,6 +68,7 @@ class FullscreenExitBubbleGtk : public FullscreenExitBubble {
ui::GtkSignalRegistrar signals_;
+ const GURL url_;
bool show_buttons_;
};
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 1ecd895..38ac79f 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -767,12 +767,12 @@ bool BrowserView::IsMinimized() const {
}
void BrowserView::EnterFullscreen(
- const GURL& url, FullscreenExitBubbleType bubble_type) {
+ const GURL& url, FullscreenExitBubbleType type) {
if (IsFullscreen())
return; // Nothing to do.
#if defined(OS_WIN)
- ProcessFullscreen(true, url, bubble_type);
+ ProcessFullscreen(true, url, type == FEB_TYPE_FULLSCREEN_BUTTONS);
#else
// On Linux changing fullscreen is async. Ask the window to change it's
// fullscreen state, and when done invoke ProcessFullscreen.
@@ -785,7 +785,7 @@ void BrowserView::ExitFullscreen() {
return; // Nothing to do.
#if defined(OS_WIN)
- ProcessFullscreen(false, GURL(), FEB_TYPE_NONE);
+ ProcessFullscreen(false, GURL(), false);
#else
// On Linux changing fullscreen is async. Ask the window to change it's
// fullscreen state, and when done invoke ProcessFullscreen.
@@ -794,10 +794,9 @@ void BrowserView::ExitFullscreen() {
}
void BrowserView::UpdateFullscreenExitBubbleContent(
- const GURL& url,
- FullscreenExitBubbleType bubble_type) {
- if (fullscreen_bubble_.get())
- fullscreen_bubble_->UpdateContent(url, bubble_type);
+ const GURL& url,
+ FullscreenExitBubbleType bubble_type) {
+ NOTIMPLEMENTED();
}
bool BrowserView::IsFullscreen() const {
@@ -809,9 +808,7 @@ bool BrowserView::IsFullscreenBubbleVisible() const {
}
void BrowserView::FullScreenStateChanged() {
- bool is_fullscreen = IsFullscreen();
- ProcessFullscreen(is_fullscreen, GURL(), is_fullscreen ?
- FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION : FEB_TYPE_NONE);
+ ProcessFullscreen(IsFullscreen(), GURL(), false);
}
void BrowserView::RestoreFocus() {
@@ -2203,7 +2200,7 @@ bool BrowserView::UpdateChildViewAndLayout(views::View* new_view,
void BrowserView::ProcessFullscreen(bool fullscreen,
const GURL& url,
- FullscreenExitBubbleType bubble_type) {
+ bool ask_permission) {
// Reduce jankiness during the following position changes by:
// * Hiding the window until it's in the final position
// * Ignoring all intervening Layout() calls, which resize the webpage and
@@ -2253,7 +2250,7 @@ void BrowserView::ProcessFullscreen(bool fullscreen,
CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode);
if (!is_kiosk) {
fullscreen_bubble_.reset(new FullscreenExitBubbleViews(
- GetWidget(), browser_.get(), url, bubble_type));
+ GetWidget(), browser_.get(), url, ask_permission));
}
} else {
#if defined(OS_WIN) && !defined(USE_AURA)
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index f0e844f..c099543c 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -259,7 +259,7 @@ class BrowserView : public BrowserBubbleHost,
virtual bool IsMaximized() const OVERRIDE;
virtual bool IsMinimized() const OVERRIDE;
virtual void EnterFullscreen(
- const GURL& url, FullscreenExitBubbleType bubble_type) OVERRIDE;
+ const GURL& url, FullscreenExitBubbleType type) OVERRIDE;
virtual void ExitFullscreen() OVERRIDE;
virtual void UpdateFullscreenExitBubbleContent(
const GURL& url,
@@ -509,11 +509,9 @@ class BrowserView : public BrowserBubbleHost,
// notification that it succeeded this method is invoked.
// If |url| is not empty, it is the URL of the page that requested fullscreen
// (via the fullscreen JS API).
- // |bubble_type| determines what should be shown in the fullscreen exit
- // bubble.
- void ProcessFullscreen(bool fullscreen,
- const GURL& url,
- FullscreenExitBubbleType bubble_type);
+ // |ask_permission| determines whether the user should be asked to allow the
+ // site to remain fullscreen.
+ void ProcessFullscreen(bool fullscreen, const GURL& url, bool ask_permission);
// Copy the accelerator table from the app resources into something we can
// use.
diff --git a/chrome/browser/ui/views/fullscreen_exit_bubble_views.cc b/chrome/browser/ui/views/fullscreen_exit_bubble_views.cc
index 0c27d24..ceebc768 100644
--- a/chrome/browser/ui/views/fullscreen_exit_bubble_views.cc
+++ b/chrome/browser/ui/views/fullscreen_exit_bubble_views.cc
@@ -38,7 +38,7 @@ class FullscreenExitBubbleViews::FullscreenExitView
FullscreenExitView(FullscreenExitBubbleViews* bubble,
const string16& accelerator,
const GURL& url,
- FullscreenExitBubbleType bubble_type);
+ bool ask_permission);
virtual ~FullscreenExitView();
// views::View
@@ -47,31 +47,35 @@ class FullscreenExitBubbleViews::FullscreenExitView
// views::ButtonListener
virtual void ButtonPressed(views::Button* sender, const views::Event& event);
- void UpdateContent(const GURL& url, FullscreenExitBubbleType bubble_type);
+ // Hide the accept and deny buttons, exposing the exit link.
+ void HideButtons();
private:
+ string16 GetMessage(const GURL& url);
+
// views::View
virtual void Layout();
FullscreenExitBubbleViews* bubble_;
- // Clickable hint text for exiting browser fullscreen mode.
+ // Clickable hint text to show in the bubble.
views::Link link_;
- // Instruction for exiting tab fullscreen mode.
- views::Label instruction_label_;
views::Label message_label_;
views::NativeTextButton* accept_button_;
views::NativeTextButton* deny_button_;
+
+ bool show_buttons_;
};
FullscreenExitBubbleViews::FullscreenExitView::FullscreenExitView(
FullscreenExitBubbleViews* bubble,
const string16& accelerator,
const GURL& url,
- FullscreenExitBubbleType bubble_type)
+ bool ask_permission)
: bubble_(bubble),
accept_button_(NULL),
- deny_button_(NULL) {
+ deny_button_(NULL),
+ show_buttons_(ask_permission) {
views::BubbleBorder* bubble_border =
new views::BubbleBorder(views::BubbleBorder::NONE);
bubble_border->set_background_color(Bubble::kBackgroundColor);
@@ -80,14 +84,10 @@ FullscreenExitBubbleViews::FullscreenExitView::FullscreenExitView(
set_focusable(false);
message_label_.set_parent_owned(false);
+ message_label_.SetText(GetMessage(url));
message_label_.SetFont(ResourceBundle::GetSharedInstance().GetFont(
ResourceBundle::MediumFont));
- instruction_label_.set_parent_owned(false);
- instruction_label_.SetText(bubble_->GetInstructionText());
- instruction_label_.SetFont(ResourceBundle::GetSharedInstance().GetFont(
- ResourceBundle::MediumFont));
-
link_.set_parent_owned(false);
link_.set_collapse_when_hidden(false);
link_.set_focusable(false);
@@ -107,21 +107,33 @@ FullscreenExitBubbleViews::FullscreenExitView::FullscreenExitView(
link_.SetBackgroundColor(background()->get_color());
message_label_.SetBackgroundColor(background()->get_color());
- instruction_label_.SetBackgroundColor(background()->get_color());
AddChildView(&message_label_);
- AddChildView(&instruction_label_);
AddChildView(&link_);
accept_button_ = new views::NativeTextButton(this,
- UTF16ToWideHack(bubble->GetAllowButtonText()));
+ UTF16ToWide(l10n_util::GetStringUTF16(IDS_FULLSCREEN_INFOBAR_ALLOW)));
accept_button_->set_focusable(false);
AddChildView(accept_button_);
- deny_button_ = new views::NativeTextButton(this);
+ deny_button_ = new views::NativeTextButton(this,
+ UTF16ToWide(l10n_util::GetStringUTF16(IDS_FULLSCREEN_INFOBAR_DENY)));
deny_button_->set_focusable(false);
AddChildView(deny_button_);
- UpdateContent(url, bubble_type);
+ if (!show_buttons_)
+ HideButtons();
+}
+
+string16 FullscreenExitBubbleViews::FullscreenExitView::GetMessage(
+ const GURL& url) {
+ if (url.is_empty()) {
+ return l10n_util::GetStringUTF16(
+ IDS_FULLSCREEN_INFOBAR_USER_ENTERED_FULLSCREEN);
+ }
+ if (url.SchemeIsFile())
+ return l10n_util::GetStringUTF16(IDS_FULLSCREEN_INFOBAR_FILE_PAGE_NAME);
+ return l10n_util::GetStringFUTF16(IDS_FULLSCREEN_INFOBAR_REQUEST_PERMISSION,
+ UTF8ToUTF16(url.host()));
}
FullscreenExitBubbleViews::FullscreenExitView::~FullscreenExitView() {
@@ -130,64 +142,43 @@ FullscreenExitBubbleViews::FullscreenExitView::~FullscreenExitView() {
void FullscreenExitBubbleViews::FullscreenExitView::ButtonPressed(
views::Button* sender, const views::Event& event) {
if (sender == accept_button_)
- bubble_->Accept();
+ bubble_->OnAcceptFullscreen();
else
- bubble_->Cancel();
+ bubble_->OnCancelFullscreen();
+}
+
+void FullscreenExitBubbleViews::FullscreenExitView::HideButtons() {
+ show_buttons_ = false;
+ accept_button_->SetVisible(false);
+ deny_button_->SetVisible(false);
+ link_.SetVisible(true);
}
gfx::Size FullscreenExitBubbleViews::FullscreenExitView::GetPreferredSize() {
- gfx::Size message_size(message_label_.GetPreferredSize());
+ gfx::Size link_size(link_.GetPreferredSize());
+ gfx::Size message_label_size(message_label_.GetPreferredSize());
+ gfx::Size accept_size(accept_button_->GetPreferredSize());
+ gfx::Size deny_size(deny_button_->GetPreferredSize());
+ gfx::Insets insets(GetInsets());
- gfx::Size button_instruction_area;
- if (instruction_label_.IsVisible()) {
- button_instruction_area = instruction_label_.GetPreferredSize();
- } else if (link_.IsVisible()) {
- button_instruction_area = link_.GetPreferredSize();
- } else {
- gfx::Size accept_size(accept_button_->GetPreferredSize());
- gfx::Size deny_size(deny_button_->GetPreferredSize());
- button_instruction_area.set_height(accept_size.height());
- button_instruction_area.set_width(
- accept_size.width() + kPaddingPx + deny_size.width());
- }
+ int buttons_width = accept_size.width() + kPaddingPx +
+ deny_size.width();
+ int button_box_width = std::max(buttons_width, link_size.width());
+ int width = kPaddingPx + message_label_size.width() + kMiddlePaddingPx +
+ button_box_width + kPaddingPx;
- gfx::Insets insets(GetInsets());
- gfx::Size result(
- message_size.width() + kMiddlePaddingPx + button_instruction_area.width(),
- std::max(message_size.height(), button_instruction_area.height()));
- result.Enlarge(insets.width() + 2 * kPaddingPx,
- insets.height() + 2 * kPaddingPx);
+ gfx::Size result(width + insets.width(),
+ kPaddingPx * 2 + accept_size.height() + insets.height());
return result;
}
-void FullscreenExitBubbleViews::FullscreenExitView::UpdateContent(
- const GURL& url,
- FullscreenExitBubbleType bubble_type) {
- DCHECK_NE(FEB_TYPE_NONE, bubble_type);
-
- message_label_.SetText(bubble_->GetCurrentMessageText());
- if (fullscreen_bubble::ShowButtonsForType(bubble_type)) {
- link_.SetVisible(false);
- instruction_label_.SetVisible(false);
- accept_button_->SetVisible(true);
- deny_button_->SetText(UTF16ToWideHack(bubble_->GetCurrentDenyButtonText()));
- deny_button_->SetVisible(true);
- deny_button_->ClearMaxTextSize();
- } else {
- bool link_visible =
- bubble_type == FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION;
- link_.SetVisible(link_visible);
- instruction_label_.SetVisible(!link_visible);
- accept_button_->SetVisible(false);
- deny_button_->SetVisible(false);
- }
-}
-
void FullscreenExitBubbleViews::FullscreenExitView::Layout() {
- // TODO(thakis): Use a LayoutManager instead of doing manual layout.
- gfx::Size message_size(message_label_.GetPreferredSize());
+ gfx::Size link_size(link_.GetPreferredSize());
+ gfx::Size message_label_size(message_label_.GetPreferredSize());
+ gfx::Size accept_size(accept_button_->GetPreferredSize());
+ gfx::Size deny_size(deny_button_->GetPreferredSize());
gfx::Insets insets(GetInsets());
- int x = insets.left() + kPaddingPx;
+
int inner_height = height() - insets.height();
int button_box_x = insets.left() + kPaddingPx +
message_label_size.width() + kMiddlePaddingPx;
@@ -219,23 +210,23 @@ void FullscreenExitBubbleViews::FullscreenExitView::Layout() {
// FullscreenExitBubbleViews ---------------------------------------------------
-FullscreenExitBubbleViews::FullscreenExitBubbleViews(
- views::Widget* frame,
- Browser* browser,
- const GURL& url,
- FullscreenExitBubbleType bubble_type)
- : FullscreenExitBubble(browser, url, bubble_type),
+FullscreenExitBubbleViews::FullscreenExitBubbleViews(views::Widget* frame,
+ Browser* browser,
+ const GURL& url,
+ bool ask_permission)
+ : FullscreenExitBubble(browser),
root_view_(frame->GetRootView()),
popup_(NULL),
- size_animation_(new ui::SlideAnimation(this)) {
+ size_animation_(new ui::SlideAnimation(this)),
+ url_(url) {
size_animation_->Reset(1);
// Create the contents view.
views::Accelerator accelerator(ui::VKEY_UNKNOWN, false, false, false);
bool got_accelerator = frame->GetAccelerator(IDC_FULLSCREEN, &accelerator);
DCHECK(got_accelerator);
- view_ = new FullscreenExitView(
- this, accelerator.GetShortcutText(), url, bubble_type_);
+ view_ = new FullscreenExitView(this,
+ accelerator.GetShortcutText(), url, ask_permission);
// Initialize the popup.
popup_ = new views::Widget;
@@ -256,7 +247,8 @@ FullscreenExitBubbleViews::FullscreenExitBubbleViews(
view_->SetBounds(0, 0, size.width(), size.height());
popup_->Show(); // This does not activate the popup.
- StartWatchingMouseIfNecessary();
+ if (!ask_permission)
+ StartWatchingMouse();
}
FullscreenExitBubbleViews::~FullscreenExitBubbleViews() {
@@ -278,24 +270,14 @@ void FullscreenExitBubbleViews::LinkClicked(
ToggleFullscreen();
}
-void FullscreenExitBubbleViews::UpdateContent(
- const GURL& url,
- FullscreenExitBubbleType bubble_type) {
- DCHECK_NE(FEB_TYPE_NONE, bubble_type);
- if (bubble_type_ == bubble_type && url_ == url)
- return;
-
- url_ = url;
- bubble_type_ = bubble_type;
- view_->UpdateContent(url_, bubble_type_);
-
- gfx::Size size = GetPopupRect(true).size();
- view_->SetSize(size);
- popup_->SetBounds(GetPopupRect(false));
- Show();
+void FullscreenExitBubbleViews::OnAcceptFullscreen() {
+ AcceptFullscreen(url_);
+ view_->HideButtons();
+ StartWatchingMouse();
+}
- StopWatchingMouse();
- StartWatchingMouseIfNecessary();
+void FullscreenExitBubbleViews::OnCancelFullscreen() {
+ CancelFullscreen();
}
void FullscreenExitBubbleViews::AnimationProgressed(
@@ -364,8 +346,3 @@ gfx::Rect FullscreenExitBubbleViews::GetPopupRect(
}
return gfx::Rect(origin, size);
}
-
-void FullscreenExitBubbleViews::StartWatchingMouseIfNecessary() {
- if (!fullscreen_bubble::ShowButtonsForType(bubble_type_))
- StartWatchingMouse();
-}
diff --git a/chrome/browser/ui/views/fullscreen_exit_bubble_views.h b/chrome/browser/ui/views/fullscreen_exit_bubble_views.h
index d5df1c5..161f2ca 100644
--- a/chrome/browser/ui/views/fullscreen_exit_bubble_views.h
+++ b/chrome/browser/ui/views/fullscreen_exit_bubble_views.h
@@ -26,10 +26,11 @@ class FullscreenExitBubbleViews : public views::LinkListener,
FullscreenExitBubbleViews(views::Widget* frame,
Browser* browser,
const GURL& url,
- FullscreenExitBubbleType bubble_type);
+ bool ask_permission);
virtual ~FullscreenExitBubbleViews();
- void UpdateContent(const GURL& url, FullscreenExitBubbleType bubble_type);
+ void OnAcceptFullscreen();
+ void OnCancelFullscreen();
protected:
// FullScreenExitBubble
@@ -44,8 +45,6 @@ class FullscreenExitBubbleViews : public views::LinkListener,
private:
class FullscreenExitView;
- void StartWatchingMouseIfNecessary();
-
// views::LinkListener:
virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
@@ -64,6 +63,8 @@ class FullscreenExitBubbleViews : public views::LinkListener,
// The contents of the popup.
FullscreenExitView* view_;
+ const GURL url_;
+
DISALLOW_COPY_AND_ASSIGN(FullscreenExitBubbleViews);
};