summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-17 20:46:10 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-17 20:46:10 +0000
commit36fe7e0be80c4fad4272c9c16bb851a83edf02be (patch)
tree199e9f51f248221e4cd9449f881a06a017e7f1fa
parent9aa0f33d659f91cc92a3108fa52ac7e0bad7ade4 (diff)
downloadchromium_src-36fe7e0be80c4fad4272c9c16bb851a83edf02be.zip
chromium_src-36fe7e0be80c4fad4272c9c16bb851a83edf02be.tar.gz
chromium_src-36fe7e0be80c4fad4272c9c16bb851a83edf02be.tar.bz2
Adds a widget that when clicked creates a new browser window. It's not
wired up yet, but will be shortly. BUG=none TEST=none Review URL: http://codereview.chromium.org/126235 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18653 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/views/new_browser_window_widget.cc48
-rw-r--r--chrome/browser/views/new_browser_window_widget.h37
-rw-r--r--views/controls/button/custom_button.h2
3 files changed, 86 insertions, 1 deletions
diff --git a/chrome/browser/views/new_browser_window_widget.cc b/chrome/browser/views/new_browser_window_widget.cc
new file mode 100644
index 0000000..db3f092
--- /dev/null
+++ b/chrome/browser/views/new_browser_window_widget.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/views/new_browser_window_widget.h"
+
+#include "app/resource_bundle.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/profile.h"
+#include "chrome/common/page_transition_types.h"
+#include "googleurl/src/gurl.h"
+#include "grit/theme_resources.h"
+#include "views/controls/button/image_button.h"
+#include "views/fill_layout.h"
+#include "views/widget/root_view.h"
+#include "views/widget/widget_gtk.h"
+
+NewBrowserWindowWidget::NewBrowserWindowWidget(Profile* profile)
+ : profile_(profile),
+ widget_(NULL) {
+ views::ImageButton* button = new views::ImageButton(this);
+ button->SetImage(views::CustomButton::BS_NORMAL,
+ ResourceBundle::GetSharedInstance().GetBitmapNamed(
+ IDR_NEW_BROWSER_WINDOW_ICON));
+ gfx::Size pref = button->GetPreferredSize();
+ views::WidgetGtk* widget =
+ new views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW);
+ widget->MakeTransparent();
+ widget->Init(NULL, gfx::Rect(0, 0, pref.width(), pref.height()), false);
+ widget->GetRootView()->SetLayoutManager(new views::FillLayout());
+ widget->GetRootView()->AddChildView(button);
+ // TODO: set window type.
+ widget_ = widget;
+ widget->Show();
+}
+
+NewBrowserWindowWidget::~NewBrowserWindowWidget() {
+ widget_->Close();
+ widget_ = NULL;
+}
+
+void NewBrowserWindowWidget::ButtonPressed(views::Button* sender) {
+ Browser* browser = Browser::Create(profile_);
+ browser->AddTabWithURL(GURL(), GURL(), PageTransition::START_PAGE,
+ true, -1, false, NULL);
+ browser->window()->Show();
+}
diff --git a/chrome/browser/views/new_browser_window_widget.h b/chrome/browser/views/new_browser_window_widget.h
new file mode 100644
index 0000000..f19ce1c
--- /dev/null
+++ b/chrome/browser/views/new_browser_window_widget.h
@@ -0,0 +1,37 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_VIEWS_NEW_BROWSER_WINDOW_WIDGET_H_
+#define CHROME_BROWSER_VIEWS_NEW_BROWSER_WINDOW_WIDGET_H_
+
+#include "views/controls/button/button.h"
+
+class Profile;
+
+namespace views {
+class Widget;
+}
+
+// NewBrowserWindowWidget creates a window containing a single button that
+// when clicked creates a new Browser. NewBrowserWindowWidget shows the window
+// from its constructor, and closes it from the destructor.
+class NewBrowserWindowWidget : public views::ButtonListener {
+ public:
+ explicit NewBrowserWindowWidget(Profile* profile);
+ ~NewBrowserWindowWidget();
+
+ // ButtonListener implementation.
+ virtual void ButtonPressed(views::Button* sender);
+
+ private:
+ // The profile the browser is created with.
+ Profile* profile_;
+
+ // The widget containing the button.
+ views::Widget* widget_;
+
+ DISALLOW_COPY_AND_ASSIGN(NewBrowserWindowWidget);
+};
+
+#endif // CHROME_BROWSER_VIEWS_NEW_BROWSER_WINDOW_WIDGET_H_
diff --git a/views/controls/button/custom_button.h b/views/controls/button/custom_button.h
index 32ff76b..745c19e 100644
--- a/views/controls/button/custom_button.h
+++ b/views/controls/button/custom_button.h
@@ -12,7 +12,7 @@ class ThrobAnimation;
namespace views {
-// A button with custom rendering. The common base class of IconButton and
+// A button with custom rendering. The common base class of ImageButton and
// TextButton.
class CustomButton : public Button,
public AnimationDelegate {