summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/new_browser_window_widget.cc
blob: db3f0928ad5f4fb4210cd96e401eddabdb31ef96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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();
}