Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7004)

Unified Diff: chrome/browser/ui/views/extensions/shell_window_views.cc

Issue 9254046: Custom frame UI for platform apps on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/extensions/shell_window_views.cc
diff --git a/chrome/browser/ui/views/extensions/shell_window_views.cc b/chrome/browser/ui/views/extensions/shell_window_views.cc
index 91fe7c62cd9d87a77dff3dc1f61e56fae7bdcbaf..eb6d5ae53dcf8c224da67956d89a2112e8766581 100644
--- a/chrome/browser/ui/views/extensions/shell_window_views.cc
+++ b/chrome/browser/ui/views/extensions/shell_window_views.cc
@@ -8,6 +8,13 @@
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/common/extensions/extension.h"
#include "ui/views/widget/widget.h"
+#include "ui/gfx/path.h"
+#include "ui/gfx/scoped_sk_region.h"
+#include "chrome/browser/ui/extensions/native_shell_frame.h"
+#if defined(OS_WIN)
+#include "content/browser/renderer_host/render_widget_host_view_win.h"
+#include "content/browser/renderer_host/render_view_host.h"
+#endif
#if defined(OS_WIN) && !defined(USE_AURA)
#include "chrome/browser/shell_integration.h"
@@ -21,8 +28,12 @@ ShellWindowViews::ShellWindowViews(ExtensionHost* host)
window_ = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
params.delegate = this;
- gfx::Rect bounds(0, 0, 512, 384);
+ gfx::Rect bounds(10, 10, 512, 384);
params.bounds = bounds;
+#if defined(OS_WIN)
+ params.native_widget = NativeShellFrame::CreateNativeShellFrame(window_)
+ ->AsNativeWidget();
+#endif
window_->Init(params);
#if defined(OS_WIN) && !defined(USE_AURA)
std::string app_name = web_app::GenerateApplicationNameFromExtensionId(
@@ -66,6 +77,35 @@ const views::Widget* ShellWindowViews::GetWidget() const {
return window_;
}
+void ShellWindowViews::OnViewWasResized() {
+ // TODO(jeremya): this doesn't seem like a terribly elegant way to keep the
+ // window shape in sync.
+#if defined(OS_WIN)
+ gfx::Size sz = host_->view()->size();
+ int height = sz.height(), width = sz.width();
+ int radius = 1;
+ gfx::Path path;
+ path.moveTo(0, radius);
+ path.lineTo(radius, 0);
+ path.lineTo(width - radius, 0);
+ path.lineTo(width, radius);
+ path.lineTo(width, height - radius - 1);
+ path.lineTo(width - radius - 1, height);
+ path.lineTo(radius + 1, height);
+ path.lineTo(0, height - radius - 1);
+ path.close();
+ SetWindowRgn(host_->view()->native_view(), path.CreateNativeRegion(), 1);
+
+ SkRegion* rgn = new SkRegion;
+ rgn->op(0, 0, width, 20, SkRegion::kUnion_Op);
+ rgn->op(0, 0, 5, height, SkRegion::kUnion_Op);
+ rgn->op(width - 5, 0, width, height, SkRegion::kUnion_Op);
+ rgn->op(0, height - 5, width, height, SkRegion::kUnion_Op);
+ static_cast<RenderWidgetHostViewWin*>(host_->render_view_host()->view())
+ ->SetTransparentRegion(rgn);
+#endif
+}
+
// static
ShellWindow* ShellWindow::CreateShellWindow(ExtensionHost* host) {
return new ShellWindowViews(host);

Powered by Google App Engine
This is Rietveld 408576698