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

Unified Diff: apps/shell/browser/shell_native_app_window.cc

Issue 171523005: BACKUP: NativeAppWindowView - before splitting CL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
« no previous file with comments | « apps/shell/browser/shell_native_app_window.h ('k') | apps/shell/browser/shell_shell_window_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/shell/browser/shell_native_app_window.cc
diff --git a/apps/shell/browser/shell_native_app_window.cc b/apps/shell/browser/shell_native_app_window.cc
new file mode 100644
index 0000000000000000000000000000000000000000..85ce5e50c64d0223ac09d17a7751ebd71fdbc1c8
--- /dev/null
+++ b/apps/shell/browser/shell_native_app_window.cc
@@ -0,0 +1,341 @@
+// Copyright 2014 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 "apps/shell/browser/shell_native_app_window.h"
+
+#include "apps/app_window.h"
+#include "apps/ui/views/app_window_frame_view.h"
+#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/rect.h"
+#include "ui/views/controls/webview/webview.h"
+#include "ui/views/widget/widget.h"
+
+namespace apps {
+
+ShellNativeAppWindow::ShellNativeAppWindow()
+ : shell_window_(NULL),
+ web_view_(NULL),
+ window_(NULL) {
+}
+
+void ShellNativeAppWindow::Init(AppWindow* shell_window,
+ const gfx::Rect& window_bounds) {
+ shell_window_ = shell_window;
+
+ window_ = new views::Widget;
+ InitializeWindow(window_bounds);
+
+ OnViewWasResized();
+ window_->AddObserver(this);
+}
+
+ShellNativeAppWindow::~ShellNativeAppWindow() {
+ web_view_->SetWebContents(NULL);
+}
+
+void ShellNativeAppWindow::InitializeWindow(const gfx::Rect& window_bounds) {
+ views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW);
+ init_params.delegate = this;
+ init_params.top_level = true;
+ window_->Init(init_params);
+ window_->CenterWindow(window_bounds.size());
+}
+
+void ShellNativeAppWindow::OnViewWasResized() {
+ FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver,
+ observer_list_,
+ OnPositionRequiresUpdate());
+}
+
+const extensions::Extension* ShellNativeAppWindow::GetExtension() {
+ return shell_window_->extension();
+}
+
+content::WebContents* ShellNativeAppWindow::GetWebContents() {
+ return shell_window_->web_contents();
+}
+
+// ui::BaseWindow implementation.
+
+bool ShellNativeAppWindow::IsActive() const {
+ return window_->IsActive();
+}
+
+bool ShellNativeAppWindow::IsMaximized() const {
+ return false;
+}
+
+bool ShellNativeAppWindow::IsMinimized() const {
+ return false;
+}
+
+bool ShellNativeAppWindow::IsFullscreen() const {
+ return false;
+}
+
+gfx::NativeWindow ShellNativeAppWindow::GetNativeWindow() {
+ return window_->GetNativeWindow();
+}
+
+gfx::Rect ShellNativeAppWindow::GetRestoredBounds() const {
+ return window_->GetRestoredBounds();
+}
+
+ui::WindowShowState ShellNativeAppWindow::GetRestoredState() const {
+ return ui::SHOW_STATE_NORMAL;
+}
+
+gfx::Rect ShellNativeAppWindow::GetBounds() const {
+ return window_->GetWindowBoundsInScreen();
+}
+
+void ShellNativeAppWindow::Show() {
+ if (window_->IsVisible()) {
+ window_->Activate();
+ return;
+ }
+ window_->Show();
+}
+
+void ShellNativeAppWindow::ShowInactive() {
+ if (window_->IsVisible())
+ return;
+ window_->ShowInactive();
+}
+
+void ShellNativeAppWindow::Hide() {
+ window_->Hide();
+}
+
+void ShellNativeAppWindow::Close() {
+ window_->Close();
+}
+
+void ShellNativeAppWindow::Activate() {
+ window_->Activate();
+}
+
+void ShellNativeAppWindow::Deactivate() {
+ window_->Deactivate();
+}
+
+void ShellNativeAppWindow::Maximize() {}
+
+void ShellNativeAppWindow::Minimize() {}
+
+void ShellNativeAppWindow::Restore() {}
+
+void ShellNativeAppWindow::SetBounds(const gfx::Rect& bounds) {
+ window_->SetBounds(bounds);
+}
+
+void ShellNativeAppWindow::FlashFrame(bool flash) {}
+
+bool ShellNativeAppWindow::IsAlwaysOnTop() const {
+ return window_->IsAlwaysOnTop();
+}
+
+void ShellNativeAppWindow::SetAlwaysOnTop(bool always_on_top) {
+ window_->SetAlwaysOnTop(always_on_top);
+}
+
+gfx::NativeView ShellNativeAppWindow::GetHostView() const {
+ return window_->GetNativeView();
+}
+
+gfx::Point ShellNativeAppWindow::GetDialogPosition(const gfx::Size& size) {
+ gfx::Size shell_window_size = window_->GetWindowBoundsInScreen().size();
+ return gfx::Point(shell_window_size.width() / 2 - size.width() / 2,
+ shell_window_size.height() / 2 - size.height() / 2);
+}
+
+gfx::Size ShellNativeAppWindow::GetMaximumDialogSize() {
+ return window_->GetWindowBoundsInScreen().size();
+}
+
+void ShellNativeAppWindow::AddObserver(
+ web_modal::ModalDialogHostObserver* observer) {
+ observer_list_.AddObserver(observer);
+}
+
+void ShellNativeAppWindow::RemoveObserver(
+ web_modal::ModalDialogHostObserver* observer) {
+ observer_list_.RemoveObserver(observer);
+}
+
+// WidgetDelegate implementation.
+
+void ShellNativeAppWindow::OnWidgetMove() {
+ shell_window_->OnNativeWindowChanged();
+}
+
+views::View* ShellNativeAppWindow::GetInitiallyFocusedView() {
+ return web_view_;
+}
+
+bool ShellNativeAppWindow::CanResize() const {
+ return false;
+}
+
+bool ShellNativeAppWindow::CanMaximize() const {
+ return false;
+}
+
+base::string16 ShellNativeAppWindow::GetWindowTitle() const {
+ return base::string16();
+}
+
+bool ShellNativeAppWindow::ShouldShowWindowTitle() const {
+ return false;
+}
+
+gfx::ImageSkia ShellNativeAppWindow::GetWindowAppIcon() {
+ return gfx::ImageSkia();
+}
+
+gfx::ImageSkia ShellNativeAppWindow::GetWindowIcon() {
+ return gfx::ImageSkia();
+}
+
+bool ShellNativeAppWindow::ShouldShowWindowIcon() const {
+ return false;
+}
+
+void ShellNativeAppWindow::SaveWindowPlacement(const gfx::Rect& bounds,
+ ui::WindowShowState show_state) {
+ views::WidgetDelegate::SaveWindowPlacement(bounds, show_state);
+ shell_window_->OnNativeWindowChanged();
+}
+
+void ShellNativeAppWindow::DeleteDelegate() {
+ window_->RemoveObserver(this);
+ shell_window_->OnNativeClose();
+}
+
+views::Widget* ShellNativeAppWindow::GetWidget() {
+ return window_;
+}
+
+const views::Widget* ShellNativeAppWindow::GetWidget() const {
+ return window_;
+}
+
+views::View* ShellNativeAppWindow::GetContentsView() {
+ return this;
+}
+
+views::NonClientFrameView* ShellNativeAppWindow::CreateNonClientFrameView(
+ views::Widget* widget) {
+ AppWindowFrameView* frame_view = new AppWindowFrameView(this);
+ // Window is not resizable, so no bounds inset or corner resize area.
+ frame_view->Init(window_, 0, 0, 1, 0);
+ return frame_view;
+}
+
+bool ShellNativeAppWindow::WidgetHasHitTestMask() const {
+ return false;
+}
+
+void ShellNativeAppWindow::GetWidgetHitTestMask(gfx::Path* mask) const {
+}
+
+bool ShellNativeAppWindow::ShouldDescendIntoChildForEventHandling(
+ gfx::NativeView child,
+ const gfx::Point& location) {
+ return true;
+}
+
+// WidgetObserver implementation.
+
+void ShellNativeAppWindow::OnWidgetVisibilityChanged(views::Widget* widget,
+ bool visible) {
+ shell_window_->OnNativeWindowChanged();
+}
+
+void ShellNativeAppWindow::OnWidgetActivationChanged(views::Widget* widget,
+ bool active) {
+ shell_window_->OnNativeWindowChanged();
+ if (active)
+ shell_window_->OnNativeWindowActivated();
+}
+
+// views::View implementation.
+
+void ShellNativeAppWindow::Layout() {
+ DCHECK(web_view_);
+ web_view_->SetBounds(0, 0, width(), height());
+ OnViewWasResized();
+}
+
+void ShellNativeAppWindow::ViewHierarchyChanged(
+ const ViewHierarchyChangedDetails& details) {
+ if (details.is_add && details.child == this) {
+ web_view_ = new views::WebView(NULL);
+ AddChildView(web_view_);
+ web_view_->SetWebContents(GetWebContents());
+ }
+}
+
+gfx::Size ShellNativeAppWindow::GetMinimumSize() {
+ return shell_window_->size_constraints().GetMinimumSize();
+}
+
+gfx::Size ShellNativeAppWindow::GetMaximumSize() {
+ return shell_window_->size_constraints().GetMaximumSize();
+}
+
+void ShellNativeAppWindow::OnFocus() {
+ web_view_->RequestFocus();
+}
+
+bool ShellNativeAppWindow::AcceleratorPressed(
+ const ui::Accelerator& accelerator) {
+ return false;
+}
+
+// NativeAppWindow implementation.
+
+void ShellNativeAppWindow::SetFullscreen(int fullscreen_types) {}
+
+bool ShellNativeAppWindow::IsFullscreenOrPending() const {
+ return false;
+}
+
+bool ShellNativeAppWindow::IsDetached() const {
+ return false;
+}
+
+void ShellNativeAppWindow::UpdateWindowIcon() {}
+
+void ShellNativeAppWindow::UpdateWindowTitle() {}
+
+void ShellNativeAppWindow::UpdateBadgeIcon() {}
+
+void ShellNativeAppWindow::UpdateDraggableRegions(
+ const std::vector<extensions::DraggableRegion>& regions) {}
+
+SkRegion* ShellNativeAppWindow::GetDraggableRegion() {
+ return NULL;
+}
+
+void ShellNativeAppWindow::UpdateShape(scoped_ptr<SkRegion> region) {}
+
+void ShellNativeAppWindow::HandleKeyboardEvent(
+ const content::NativeWebKeyboardEvent& event) {}
+
+bool ShellNativeAppWindow::IsFrameless() const {
+ return true;
+}
+
+gfx::Insets ShellNativeAppWindow::GetFrameInsets() const {
+ return gfx::Insets();
+}
+
+void ShellNativeAppWindow::HideWithApp() {}
+
+void ShellNativeAppWindow::ShowWithApp() {}
+
+void ShellNativeAppWindow::UpdateWindowMinMaxSize() {}
+
+} // namespace apps
« no previous file with comments | « apps/shell/browser/shell_native_app_window.h ('k') | apps/shell/browser/shell_shell_window_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698