summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/wm_overview_snapshot.cc
diff options
context:
space:
mode:
authorgspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-28 17:26:49 +0000
committergspencer@chromium.org <gspencer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-28 17:26:49 +0000
commitd65adb173f09a837c96f96fc24a258f439e46e58 (patch)
tree43605ab367e97389930c518c4e94bd3da5f20080 /chrome/browser/chromeos/wm_overview_snapshot.cc
parent7cea56d943924d0c2196bdf4049f592b6182992c (diff)
downloadchromium_src-d65adb173f09a837c96f96fc24a258f439e46e58.zip
chromium_src-d65adb173f09a837c96f96fc24a258f439e46e58.tar.gz
chromium_src-d65adb173f09a837c96f96fc24a258f439e46e58.tar.bz2
This adds in the ability for Chrome to generate windows with snapshots
of all currently open tabs in all browsers. This is needed for overview mode on ChromeOS. BUG=http://code.google.com/p/chromium-os/issues/detail?id=1170 TEST=Ran Chrome under ChromeOS with updated window manager. Review URL: http://codereview.chromium.org/661237 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45824 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/wm_overview_snapshot.cc')
-rw-r--r--chrome/browser/chromeos/wm_overview_snapshot.cc80
1 files changed, 80 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/wm_overview_snapshot.cc b/chrome/browser/chromeos/wm_overview_snapshot.cc
new file mode 100644
index 0000000..97c2a8e
--- /dev/null
+++ b/chrome/browser/chromeos/wm_overview_snapshot.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2010 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/chromeos/wm_overview_snapshot.h"
+
+#include <vector>
+
+#include "app/x11_util.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/chromeos/wm_ipc.h"
+#include "views/border.h"
+#include "views/controls/image_view.h"
+#include "views/controls/label.h"
+#include "views/grid_layout.h"
+
+using views::ColumnSet;
+using views::GridLayout;
+using std::vector;
+
+#if !defined(OS_CHROMEOS)
+#error This file is only meant to be compiled for ChromeOS
+#endif
+
+namespace chromeos {
+
+WmOverviewSnapshot::WmOverviewSnapshot()
+ : WidgetGtk(TYPE_WINDOW),
+ snapshot_view_(NULL),
+ index_(-1),
+ configured_snapshot_(false) {
+}
+
+void WmOverviewSnapshot::Init(const gfx::Size& size,
+ Browser* browser,
+ int index) {
+ snapshot_view_ = new views::ImageView();
+ MakeTransparent();
+
+ snapshot_view_->set_background(
+ views::Background::CreateSolidBackground(SK_ColorWHITE));
+ snapshot_view_->set_border(
+ views::Border::CreateSolidBorder(1, SkColorSetRGB(176, 176, 176)));
+
+ WidgetGtk::Init(NULL, gfx::Rect(gfx::Point(0,0), size));
+
+ SetContentsView(snapshot_view_);
+
+ UpdateIndex(browser, index);
+}
+
+
+void WmOverviewSnapshot::UpdateIndex(Browser* browser, int index) {
+ vector<int> params;
+ params.push_back(x11_util::GetX11WindowFromGtkWidget(
+ GTK_WIDGET(browser->window()->GetNativeHandle())));
+ params.push_back(index);
+ WmIpc::instance()->SetWindowType(
+ GetNativeView(),
+ WmIpc::WINDOW_TYPE_CHROME_TAB_SNAPSHOT,
+ &params);
+ index_ = index;
+}
+
+void WmOverviewSnapshot::SetImage(const SkBitmap& image) {
+ CHECK(snapshot_view_) << "Init not called before setting image.";
+ snapshot_view_->SetImage(image);
+
+ // Reset the bounds to the size of the image.
+ gfx::Rect bounds;
+ GetBounds(&bounds, false);
+ bounds.set_width(image.width());
+ bounds.set_height(image.height());
+ SetBounds(bounds);
+
+ configured_snapshot_ = true;
+}
+
+} // namespace chromeos