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

Unified Diff: chrome/browser/ui/ash/shell_panel_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: . 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_panel_ash.cc
diff --git a/chrome/browser/ui/ash/shell_panel_ash.cc b/chrome/browser/ui/ash/shell_panel_ash.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d632d6740e13bf02ad4fc22b7c21ab7422624f19
--- /dev/null
+++ b/chrome/browser/ui/ash/shell_panel_ash.cc
@@ -0,0 +1,222 @@
+// 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_panel_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/widget/widget.h"
+#include "ui/views/controls/webview/webview.h"
+
+namespace {
+const int kMinWidth = 100;
+const int kMinHeight = 100;
+const int kDefaultWidth = 200;
+const int kDefaultHeight = 300;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// ShellPanelAsh
+
+ShellPanelAsh::ShellPanelAsh(ShellWindow* shell_window,
+ const ShellWindow::CreateParams& win_params)
+ : shell_window_(shell_window),
+ web_view_(NULL),
+ window_(NULL),
+ frameless_(win_params.frame != ShellWindow::CreateParams::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);
+}
+
+ShellPanelAsh::~ShellPanelAsh() {
+ web_view_->SetWebContents(NULL);
+}
+
+// BaseWindow implementation:
+
+bool ShellPanelAsh::IsActive() const {
+ return window_->IsActive();
+}
+
+bool ShellPanelAsh::IsMaximized() const {
+ return window_->IsMaximized();
+}
+
+bool ShellPanelAsh::IsMinimized() const {
+ return window_->IsMinimized();
+}
+
+bool ShellPanelAsh::IsFullscreen() const {
+ return window_->IsFullscreen();
+}
+
+gfx::NativeWindow ShellPanelAsh::GetNativeWindow() {
+ return window_->GetNativeWindow();
+}
+
+gfx::Rect ShellPanelAsh::GetRestoredBounds() const {
+ return window_->GetRestoredBounds();
+}
+
+gfx::Rect ShellPanelAsh::GetBounds() const {
+ return window_->GetWindowBoundsInScreen();
+}
+
+void ShellPanelAsh::Show() {
+ window_->Show();
+}
+
+void ShellPanelAsh::ShowInactive() {
+ window_->ShowInactive();
+}
+
+void ShellPanelAsh::Hide() {
+ window_->Hide();
+}
+
+void ShellPanelAsh::Close() {
+ window_->Close();
+}
+
+void ShellPanelAsh::Activate() {
+ window_->Activate();
+}
+
+void ShellPanelAsh::Deactivate() {
+ window_->Deactivate();
+}
+
+void ShellPanelAsh::Maximize() {
+ // Maximize is not implemented for panels.
+}
+
+void ShellPanelAsh::Minimize() {
+ window_->Minimize();
+}
+
+void ShellPanelAsh::Restore() {
+ window_->Restore();
+}
+
+void ShellPanelAsh::SetBounds(const gfx::Rect& bounds) {
+ window_->SetBounds(bounds);
+}
+
+void ShellPanelAsh::FlashFrame(bool flash) {
+ // TODO(stevenjb): Implement
+ NOTIMPLEMENTED();
+}
+
+bool ShellPanelAsh::IsAlwaysOnTop() const {
+ return true;
+}
+
+// views::WidgetDelegate implementation:
+void ShellPanelAsh::DeleteDelegate() {
+ shell_window_->OnNativeClose();
+}
+
+bool ShellPanelAsh::CanResize() const {
+ return true;
+}
+
+views::View* ShellPanelAsh::GetContentsView() {
+ return this;
+}
+
+views::NonClientFrameView* ShellPanelAsh::CreateNonClientFrameView(
+ views::Widget* widget) {
+ ash::PanelFrameView* frame_view =
+ new ash::PanelFrameView(widget, !frameless_);
+ return frame_view;
+}
+
+string16 ShellPanelAsh::GetWindowTitle() const {
+ return shell_window_->GetTitle();
+}
+
+bool ShellPanelAsh::ShouldShowWindowTitle() const {
+ return true;
+}
+
+views::Widget* ShellPanelAsh::GetWidget() {
+ return window_;
+}
+
+const views::Widget* ShellPanelAsh::GetWidget() const {
+ return window_;
+}
+
+views::View* ShellPanelAsh::GetInitiallyFocusedView() {
+ return web_view_;
+}
+
+// views::View implementation:
+void ShellPanelAsh::Layout() {
+ DCHECK(web_view_);
+ web_view_->SetBounds(0, 0, width(), height());
+}
+
+void ShellPanelAsh::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 ShellPanelAsh::GetPreferredSize() {
+ return preferred_size_;
+}
+
+void ShellPanelAsh::OnFocus() {
+ web_view_->RequestFocus();
+}
+
+// NativeShellWindow implementation.
+void ShellPanelAsh::SetFullscreen(bool fullscreen) {
+}
+
+bool ShellPanelAsh::IsFullscreenOrPending() const {
+ return false;
+}
+
+void ShellPanelAsh::UpdateWindowIcon() {
+ window_->UpdateWindowIcon();
+}
+
+void ShellPanelAsh::UpdateWindowTitle() {
+ window_->UpdateWindowTitle();
+}
+
+void ShellPanelAsh::UpdateDraggableRegions(
+ const std::vector<extensions::DraggableRegion>& regions) {
+}
+
+void ShellPanelAsh::HandleKeyboardEvent(
+ const content::NativeWebKeyboardEvent& event) {
+}
+
+void ShellPanelAsh::RenderViewHostChanged() {
+}

Powered by Google App Engine
This is Rietveld 408576698