| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/views/new_browser_window_widget.h" | 5 #include "chrome/browser/views/new_browser_window_widget.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
| 9 #include "chrome/browser/browser_window.h" | 9 #include "chrome/browser/browser_window.h" |
| 10 #include "chrome/browser/metrics/user_metrics.h" | 10 #include "chrome/browser/metrics/user_metrics.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 : profile_(profile), | 22 : profile_(profile), |
| 23 widget_(NULL) { | 23 widget_(NULL) { |
| 24 views::ImageButton* button = new views::ImageButton(this); | 24 views::ImageButton* button = new views::ImageButton(this); |
| 25 button->SetImage(views::CustomButton::BS_NORMAL, | 25 button->SetImage(views::CustomButton::BS_NORMAL, |
| 26 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 26 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 27 IDR_NEW_BROWSER_WINDOW_ICON)); | 27 IDR_NEW_BROWSER_WINDOW_ICON)); |
| 28 gfx::Size pref = button->GetPreferredSize(); | 28 gfx::Size pref = button->GetPreferredSize(); |
| 29 views::WidgetGtk* widget = | 29 views::WidgetGtk* widget = |
| 30 new views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW); | 30 new views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW); |
| 31 widget->MakeTransparent(); | 31 widget->MakeTransparent(); |
| 32 widget->Init(NULL, gfx::Rect(0, 0, pref.width(), pref.height()), false); | 32 widget->Init(NULL, gfx::Rect(0, 0, pref.width(), pref.height())); |
| 33 TabOverviewTypes::instance()->SetWindowType( | 33 TabOverviewTypes::instance()->SetWindowType( |
| 34 widget->GetNativeView(), | 34 widget->GetNativeView(), |
| 35 TabOverviewTypes::WINDOW_TYPE_CREATE_BROWSER_WINDOW, | 35 TabOverviewTypes::WINDOW_TYPE_CREATE_BROWSER_WINDOW, |
| 36 NULL); | 36 NULL); |
| 37 widget->GetRootView()->SetLayoutManager(new views::FillLayout()); | 37 widget->GetRootView()->SetLayoutManager(new views::FillLayout()); |
| 38 widget->GetRootView()->AddChildView(button); | 38 widget->GetRootView()->AddChildView(button); |
| 39 widget_ = widget; | 39 widget_ = widget; |
| 40 widget->Show(); | 40 widget->Show(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 NewBrowserWindowWidget::~NewBrowserWindowWidget() { | 43 NewBrowserWindowWidget::~NewBrowserWindowWidget() { |
| 44 widget_->Close(); | 44 widget_->Close(); |
| 45 widget_ = NULL; | 45 widget_ = NULL; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void NewBrowserWindowWidget::ButtonPressed(views::Button* sender) { | 48 void NewBrowserWindowWidget::ButtonPressed(views::Button* sender) { |
| 49 UserMetrics::RecordAction(L"TabOverview_PressedCreateNewBrowserButton", | 49 UserMetrics::RecordAction(L"TabOverview_PressedCreateNewBrowserButton", |
| 50 profile_); | 50 profile_); |
| 51 | 51 |
| 52 Browser* browser = Browser::Create(profile_); | 52 Browser* browser = Browser::Create(profile_); |
| 53 browser->AddTabWithURL(GURL(), GURL(), PageTransition::START_PAGE, | 53 browser->AddTabWithURL(GURL(), GURL(), PageTransition::START_PAGE, |
| 54 true, -1, false, NULL); | 54 true, -1, false, NULL); |
| 55 browser->window()->Show(); | 55 browser->window()->Show(); |
| 56 } | 56 } |
| OLD | NEW |