OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/wm_overview_snapshot.h" |
| 6 |
| 7 #include <vector> |
| 8 |
| 9 #include "app/x11_util.h" |
| 10 #include "chrome/browser/browser.h" |
| 11 #include "chrome/browser/browser_window.h" |
| 12 #include "chrome/browser/chromeos/wm_ipc.h" |
| 13 #include "views/border.h" |
| 14 #include "views/controls/image_view.h" |
| 15 #include "views/controls/label.h" |
| 16 #include "views/grid_layout.h" |
| 17 |
| 18 using views::ColumnSet; |
| 19 using views::GridLayout; |
| 20 using std::vector; |
| 21 |
| 22 #if !defined(OS_CHROMEOS) |
| 23 #error This file is only meant to be compiled for ChromeOS |
| 24 #endif |
| 25 |
| 26 namespace chromeos { |
| 27 |
| 28 WmOverviewSnapshot::WmOverviewSnapshot() |
| 29 : WidgetGtk(TYPE_WINDOW), |
| 30 snapshot_view_(NULL), |
| 31 index_(-1), |
| 32 configured_snapshot_(false) { |
| 33 } |
| 34 |
| 35 void WmOverviewSnapshot::Init(const gfx::Size& size, |
| 36 Browser* browser, |
| 37 int index) { |
| 38 snapshot_view_ = new views::ImageView(); |
| 39 MakeTransparent(); |
| 40 |
| 41 snapshot_view_->set_background( |
| 42 views::Background::CreateSolidBackground(SK_ColorWHITE)); |
| 43 snapshot_view_->set_border( |
| 44 views::Border::CreateSolidBorder(1, SkColorSetRGB(176, 176, 176))); |
| 45 |
| 46 WidgetGtk::Init(NULL, gfx::Rect(gfx::Point(0,0), size)); |
| 47 |
| 48 SetContentsView(snapshot_view_); |
| 49 |
| 50 UpdateIndex(browser, index); |
| 51 } |
| 52 |
| 53 |
| 54 void WmOverviewSnapshot::UpdateIndex(Browser* browser, int index) { |
| 55 vector<int> params; |
| 56 params.push_back(x11_util::GetX11WindowFromGtkWidget( |
| 57 GTK_WIDGET(browser->window()->GetNativeHandle()))); |
| 58 params.push_back(index); |
| 59 WmIpc::instance()->SetWindowType( |
| 60 GetNativeView(), |
| 61 WmIpc::WINDOW_TYPE_CHROME_TAB_SNAPSHOT, |
| 62 ¶ms); |
| 63 index_ = index; |
| 64 } |
| 65 |
| 66 void WmOverviewSnapshot::SetImage(const SkBitmap& image) { |
| 67 CHECK(snapshot_view_) << "Init not called before setting image."; |
| 68 snapshot_view_->SetImage(image); |
| 69 |
| 70 // Reset the bounds to the size of the image. |
| 71 gfx::Rect bounds; |
| 72 GetBounds(&bounds, false); |
| 73 bounds.set_width(image.width()); |
| 74 bounds.set_height(image.height()); |
| 75 SetBounds(bounds); |
| 76 |
| 77 configured_snapshot_ = true; |
| 78 } |
| 79 |
| 80 } // namespace chromeos |
OLD | NEW |