| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/first_run/try_chrome_dialog_view.h" | 5 #include "chrome/browser/first_run/try_chrome_dialog_view.h" |
| 6 | 6 |
| 7 #include <shellapi.h> | 7 #include <shellapi.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 TryChromeDialogView::Result TryChromeDialogView::ShowModal( | 58 TryChromeDialogView::Result TryChromeDialogView::ShowModal( |
| 59 ProcessSingleton* process_singleton) { | 59 ProcessSingleton* process_singleton) { |
| 60 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 60 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 61 | 61 |
| 62 views::ImageView* icon = new views::ImageView(); | 62 views::ImageView* icon = new views::ImageView(); |
| 63 icon->SetImage(*rb.GetBitmapNamed(IDR_PRODUCT_ICON_32)); | 63 icon->SetImage(*rb.GetBitmapNamed(IDR_PRODUCT_ICON_32)); |
| 64 gfx::Size icon_size = icon->GetPreferredSize(); | 64 gfx::Size icon_size = icon->GetPreferredSize(); |
| 65 | 65 |
| 66 // An approximate window size. After Layout() we'll get better bounds. | 66 // An approximate window size. After Layout() we'll get better bounds. |
| 67 views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); | 67 popup_ = views::Widget::CreateWidget(); |
| 68 params.can_activate = true; | |
| 69 popup_ = views::Widget::CreateWidget(params); | |
| 70 if (!popup_) { | 68 if (!popup_) { |
| 71 NOTREACHED(); | 69 NOTREACHED(); |
| 72 return DIALOG_ERROR; | 70 return DIALOG_ERROR; |
| 73 } | 71 } |
| 74 | 72 |
| 75 gfx::Rect pos(310, 160); | 73 views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); |
| 76 popup_->Init(NULL, pos); | 74 params.can_activate = true; |
| 75 params.bounds = gfx::Rect(310, 160); |
| 76 popup_->Init(params); |
| 77 | 77 |
| 78 views::RootView* root_view = popup_->GetRootView(); | 78 views::RootView* root_view = popup_->GetRootView(); |
| 79 // The window color is a tiny bit off-white. | 79 // The window color is a tiny bit off-white. |
| 80 root_view->set_background( | 80 root_view->set_background( |
| 81 views::Background::CreateSolidBackground(0xfc, 0xfc, 0xfc)); | 81 views::Background::CreateSolidBackground(0xfc, 0xfc, 0xfc)); |
| 82 | 82 |
| 83 views::GridLayout* layout = views::GridLayout::CreatePanel(root_view); | 83 views::GridLayout* layout = views::GridLayout::CreatePanel(root_view); |
| 84 if (!layout) { | 84 if (!layout) { |
| 85 NOTREACHED(); | 85 NOTREACHED(); |
| 86 return DIALOG_ERROR; | 86 return DIALOG_ERROR; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // Fifth row views. | 186 // Fifth row views. |
| 187 layout->StartRowWithPadding(0, 4, 0, 10); | 187 layout->StartRowWithPadding(0, 4, 0, 10); |
| 188 views::Link* link = new views::Link(why_this); | 188 views::Link* link = new views::Link(why_this); |
| 189 link->SetController(this); | 189 link->SetController(this); |
| 190 layout->AddView(link); | 190 layout->AddView(link); |
| 191 | 191 |
| 192 // We resize the window according to the layout manager. This takes into | 192 // We resize the window according to the layout manager. This takes into |
| 193 // account the differences between XP and Vista fonts and buttons. | 193 // account the differences between XP and Vista fonts and buttons. |
| 194 layout->Layout(root_view); | 194 layout->Layout(root_view); |
| 195 gfx::Size preferred = layout->GetPreferredSize(root_view); | 195 gfx::Size preferred = layout->GetPreferredSize(root_view); |
| 196 pos = ComputeWindowPosition(preferred.width(), preferred.height(), | 196 gfx::Rect pos = ComputeWindowPosition(preferred.width(), preferred.height(), |
| 197 base::i18n::IsRTL()); | 197 base::i18n::IsRTL()); |
| 198 popup_->SetBounds(pos); | 198 popup_->SetBounds(pos); |
| 199 | 199 |
| 200 // Carve the toast shape into the window. | 200 // Carve the toast shape into the window. |
| 201 SetToastRegion(popup_->GetNativeView(), | 201 SetToastRegion(popup_->GetNativeView(), |
| 202 preferred.width(), preferred.height()); | 202 preferred.width(), preferred.height()); |
| 203 | 203 |
| 204 // Time to show the window in a modal loop. We don't want this chrome | 204 // Time to show the window in a modal loop. We don't want this chrome |
| 205 // instance trying to serve WM_COPYDATA requests, as we'll surely crash. | 205 // instance trying to serve WM_COPYDATA requests, as we'll surely crash. |
| 206 process_singleton->Lock(popup_->GetNativeView()); | 206 process_singleton->Lock(popup_->GetNativeView()); |
| 207 popup_->Show(); | 207 popup_->Show(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 // The outcome is according to the selected ratio button. | 251 // The outcome is according to the selected ratio button. |
| 252 result_ = try_chrome_->checked() ? TRY_CHROME : UNINSTALL_CHROME; | 252 result_ = try_chrome_->checked() ? TRY_CHROME : UNINSTALL_CHROME; |
| 253 } | 253 } |
| 254 popup_->Close(); | 254 popup_->Close(); |
| 255 MessageLoop::current()->Quit(); | 255 MessageLoop::current()->Quit(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void TryChromeDialogView::LinkActivated(views::Link* source, int event_flags) { | 258 void TryChromeDialogView::LinkActivated(views::Link* source, int event_flags) { |
| 259 ::ShellExecuteW(NULL, L"open", kHelpCenterUrl, NULL, NULL, SW_SHOW); | 259 ::ShellExecuteW(NULL, L"open", kHelpCenterUrl, NULL, NULL, SW_SHOW); |
| 260 } | 260 } |
| OLD | NEW |