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

Unified Diff: chrome/browser/ui/ash/shell_utility_window_ash.cc

Issue 11363250: Allow Chrome apps to create Ash Panels (apps v2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Multi-icon support Created 8 years, 1 month 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/ash/shell_utility_window_ash.cc
diff --git a/chrome/browser/ui/ash/shell_utility_window_ash.cc b/chrome/browser/ui/ash/shell_utility_window_ash.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a92bb2434ff9b82825d1a66c4ef2e9bdf3c0ed05
--- /dev/null
+++ b/chrome/browser/ui/ash/shell_utility_window_ash.cc
@@ -0,0 +1,239 @@
+// Copyright (c) 2012 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/ui/ash/shell_utility_window_ash.h"
+
+#include "ash/wm/panel_frame_view.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/profiles/profile.h"
+#include "googleurl/src/gurl.h"
+#include "ui/aura/window.h"
+#include "ui/views/controls/webview/webview.h"
+#include "ui/views/widget/widget.h"
+
+namespace {
+const int kMinWidth = 100;
+const int kMinHeight = 100;
+const int kDefaultWidth = 200;
+const int kDefaultHeight = 300;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// ShellUtilityWindowAsh
+
+ShellUtilityWindowAsh::ShellUtilityWindowAsh(
+ ShellWindow* shell_window,
+ const ShellWindow::CreateParams& win_params)
+ : shell_window_(shell_window),
+ web_view_(NULL),
+ window_(NULL),
+ panel_frame_view_(NULL),
+ frameless_(win_params.frame == ShellWindow::FRAME_NONE) {
+ window_ = new views::Widget;
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_PANEL);
+ params.delegate = this;
+
+ preferred_size_ = gfx::Size(win_params.bounds.width(),
+ win_params.bounds.height());
+ if (preferred_size_.width() == 0)
+ preferred_size_.set_width(kDefaultWidth);
+ else if (preferred_size_.width() < kMinWidth)
+ preferred_size_.set_width(kMinWidth);
+
+ if (preferred_size_.height() == 0)
+ preferred_size_.set_height(kDefaultHeight);
+ else if (preferred_size_.height() < kMinHeight)
+ preferred_size_.set_height(kMinHeight);
+
+ params.bounds = gfx::Rect(preferred_size_.width(), preferred_size_.height());
+ window_->Init(params);
+
+ // Resize the window to include the frame insets.
+ gfx::Rect bounds = GetBounds();
+ bounds.Inset(-GetFrameInsets());
+ SetBounds(bounds);
+}
+
+ShellUtilityWindowAsh::~ShellUtilityWindowAsh() {
+ web_view_->SetWebContents(NULL);
+}
+
+// BaseWindow implementation
+
+bool ShellUtilityWindowAsh::IsActive() const {
+ return window_->IsActive();
+}
+
+bool ShellUtilityWindowAsh::IsMaximized() const {
+ return window_->IsMaximized();
+}
+
+bool ShellUtilityWindowAsh::IsMinimized() const {
+ return window_->IsMinimized();
+}
+
+bool ShellUtilityWindowAsh::IsFullscreen() const {
+ return window_->IsFullscreen();
+}
+
+gfx::NativeWindow ShellUtilityWindowAsh::GetNativeWindow() {
+ return window_->GetNativeWindow();
+}
+
+gfx::Rect ShellUtilityWindowAsh::GetRestoredBounds() const {
+ return window_->GetRestoredBounds();
+}
+
+gfx::Rect ShellUtilityWindowAsh::GetBounds() const {
+ return window_->GetWindowBoundsInScreen();
+}
+
+void ShellUtilityWindowAsh::Show() {
+ window_->Show();
+}
+
+void ShellUtilityWindowAsh::ShowInactive() {
+ window_->ShowInactive();
+}
+
+void ShellUtilityWindowAsh::Hide() {
+ window_->Hide();
+}
+
+void ShellUtilityWindowAsh::Close() {
+ window_->Close();
+}
+
+void ShellUtilityWindowAsh::Activate() {
+ window_->Activate();
+}
+
+void ShellUtilityWindowAsh::Deactivate() {
+ window_->Deactivate();
+}
+
+void ShellUtilityWindowAsh::Maximize() {
+ // Maximize is not implemented for panels.
+}
+
+void ShellUtilityWindowAsh::Minimize() {
+ window_->Minimize();
+}
+
+void ShellUtilityWindowAsh::Restore() {
+ window_->Restore();
+}
+
+void ShellUtilityWindowAsh::SetBounds(const gfx::Rect& bounds) {
+ window_->SetBounds(bounds);
+}
+
+void ShellUtilityWindowAsh::FlashFrame(bool flash) {
+ // TODO(stevenjb): Implement
+ NOTIMPLEMENTED();
+}
+
+bool ShellUtilityWindowAsh::IsAlwaysOnTop() const {
+ return true;
+}
+
+gfx::Insets ShellUtilityWindowAsh::GetFrameInsets() const {
+ if (!panel_frame_view_)
+ return gfx::Insets();
+ return panel_frame_view_->GetFrameInsets();
+}
+
+// views::WidgetDelegate implementation
+
+void ShellUtilityWindowAsh::DeleteDelegate() {
+ shell_window_->OnNativeClose();
+}
+
+bool ShellUtilityWindowAsh::CanResize() const {
+ return true;
+}
+
+views::View* ShellUtilityWindowAsh::GetContentsView() {
+ return this;
+}
+
+views::NonClientFrameView* ShellUtilityWindowAsh::CreateNonClientFrameView(
+ views::Widget* widget) {
+ ash::PanelFrameView::FrameType frame_type = frameless_ ?
+ ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH;
+ panel_frame_view_ = new ash::PanelFrameView(widget, frame_type);
+ return panel_frame_view_;
+}
+
+string16 ShellUtilityWindowAsh::GetWindowTitle() const {
+ return shell_window_->GetTitle();
+}
+
+bool ShellUtilityWindowAsh::ShouldShowWindowTitle() const {
+ return true;
+}
+
+views::Widget* ShellUtilityWindowAsh::GetWidget() {
+ return window_;
+}
+
+const views::Widget* ShellUtilityWindowAsh::GetWidget() const {
+ return window_;
+}
+
+views::View* ShellUtilityWindowAsh::GetInitiallyFocusedView() {
+ return web_view_;
+}
+
+// views::View implementation
+
+void ShellUtilityWindowAsh::Layout() {
+ DCHECK(web_view_);
+ web_view_->SetBounds(0, 0, width(), height());
+}
+
+void ShellUtilityWindowAsh::ViewHierarchyChanged(
+ bool is_add, views::View *parent, views::View *child) {
+ if (is_add && child == this) {
+ web_view_ = new views::WebView(NULL);
+ AddChildView(web_view_);
+ web_view_->SetWebContents(shell_window_->web_contents());
+ }
+}
+
+gfx::Size ShellUtilityWindowAsh::GetPreferredSize() {
+ return preferred_size_;
+}
+
+void ShellUtilityWindowAsh::OnFocus() {
+ web_view_->RequestFocus();
+}
+
+// NativeShellWindow implementation
+
+void ShellUtilityWindowAsh::SetFullscreen(bool fullscreen) {
+}
+
+bool ShellUtilityWindowAsh::IsFullscreenOrPending() const {
+ return false;
+}
+
+void ShellUtilityWindowAsh::UpdateWindowIcon() {
+ window_->UpdateWindowIcon();
+}
+
+void ShellUtilityWindowAsh::UpdateWindowTitle() {
+ window_->UpdateWindowTitle();
+}
+
+void ShellUtilityWindowAsh::UpdateDraggableRegions(
+ const std::vector<extensions::DraggableRegion>& regions) {
+}
+
+void ShellUtilityWindowAsh::HandleKeyboardEvent(
+ const content::NativeWebKeyboardEvent& event) {
+}
+
+void ShellUtilityWindowAsh::RenderViewHostChanged() {
+}

Powered by Google App Engine
This is Rietveld 408576698