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

Unified Diff: chrome/browser/ui/views/apps/native_app_window_views.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
Index: chrome/browser/ui/views/apps/native_app_window_views.cc
diff --git a/chrome/browser/ui/views/apps/native_app_window_views.cc b/chrome/browser/ui/views/apps/native_app_window_views.cc
index b835356a10fe1851ee6e4cad8874e5a104ab057b..2cc1883661c5cef5d309909644bea3a9122b48f0 100644
--- a/chrome/browser/ui/views/apps/native_app_window_views.cc
+++ b/chrome/browser/ui/views/apps/native_app_window_views.cc
@@ -1,39 +1,25 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// 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 "chrome/browser/ui/views/apps/native_app_window_views.h"
-#include "apps/app_window.h"
#include "apps/ui/views/app_window_frame_view.h"
#include "base/command_line.h"
-#include "base/threading/sequenced_worker_pool.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/chrome_page_zoom.h"
-#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h"
-#include "chrome/browser/ui/host_desktop.h"
-#include "chrome/browser/ui/views/apps/shaped_app_window_targeter.h"
#include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views.h"
#include "chrome/browser/ui/views/frame/taskbar_decorator.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_switches.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/render_view_host.h"
-#include "content/public/browser/render_widget_host_view.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_view.h"
-#include "extensions/common/draggable_region.h"
#include "extensions/common/extension.h"
-#include "ui/base/hit_test.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/controls/webview/webview.h"
#include "ui/views/widget/widget.h"
-#include "ui/views/window/non_client_view.h"
#if defined(OS_LINUX)
#include "chrome/browser/shell_integration_linux.h"
@@ -51,16 +37,13 @@
#include "ash/wm/window_state_delegate.h"
#include "ash/wm/window_state_observer.h"
#include "chrome/browser/ui/ash/ash_util.h"
+#include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#endif
-#if defined(USE_AURA)
-#include "ui/aura/window.h"
-#endif
-
using apps::AppWindow;
namespace {
@@ -199,47 +182,16 @@ class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate,
} // namespace
-NativeAppWindowViews::NativeAppWindowViews()
- : web_view_(NULL),
- window_(NULL),
- is_fullscreen_(false),
- weak_ptr_factory_(this) {
-}
+ChromeNativeAppWindowViews::ChromeNativeAppWindowViews()
+ : is_fullscreen_(false) {}
-void NativeAppWindowViews::Init(apps::AppWindow* app_window,
- const AppWindow::CreateParams& create_params) {
- app_window_ = app_window;
- frameless_ = create_params.frame == AppWindow::FRAME_NONE;
- transparent_background_ = create_params.transparent_background;
- resizable_ = create_params.resizable;
- Observe(web_contents());
+ChromeNativeAppWindowViews::~ChromeNativeAppWindowViews() {}
- window_ = new views::Widget;
- if (create_params.window_type == AppWindow::WINDOW_TYPE_PANEL ||
- create_params.window_type == AppWindow::WINDOW_TYPE_V1_PANEL) {
- InitializePanelWindow(create_params);
- } else {
- InitializeDefaultWindow(create_params);
- }
- extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
- Profile::FromBrowserContext(browser_context()),
- window_->GetFocusManager(),
- extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
- app_window_));
-
- OnViewWasResized();
- window_->AddObserver(this);
-}
-
-NativeAppWindowViews::~NativeAppWindowViews() {
- web_view_->SetWebContents(NULL);
-}
-
-void NativeAppWindowViews::OnBeforeWidgetInit(
+void ChromeNativeAppWindowViews::OnBeforeWidgetInit(
views::Widget::InitParams* init_params,
views::Widget* widget) {}
-void NativeAppWindowViews::InitializeDefaultWindow(
+void ChromeNativeAppWindowViews::InitializeDefaultWindow(
const AppWindow::CreateParams& create_params) {
std::string app_name =
web_app::GenerateApplicationNameFromExtensionId(extension()->id());
@@ -275,16 +227,16 @@ void NativeAppWindowViews::InitializeDefaultWindow(
init_params.wm_role_name = std::string(kX11WindowRoleApp);
#endif
- OnBeforeWidgetInit(&init_params, window_);
- window_->Init(init_params);
+ OnBeforeWidgetInit(&init_params, window());
+ window()->Init(init_params);
gfx::Rect adjusted_bounds = window_bounds;
adjusted_bounds.Inset(-GetFrameInsets());
// Center window if no position was specified.
if (!position_specified)
- window_->CenterWindow(adjusted_bounds.size());
+ window()->CenterWindow(adjusted_bounds.size());
else if (!adjusted_bounds.IsEmpty() && adjusted_bounds != window_bounds)
- window_->SetBounds(adjusted_bounds);
+ window()->SetBounds(adjusted_bounds);
// Register accelarators supported by app windows.
// TODO(jeremya/stevenjb): should these be registered for panels too?
@@ -314,7 +266,7 @@ void NativeAppWindowViews::InitializeDefaultWindow(
}
}
-void NativeAppWindowViews::InitializePanelWindow(
+void ChromeNativeAppWindowViews::InitializePanelWindow(
const AppWindow::CreateParams& create_params) {
views::Widget::InitParams params(views::Widget::InitParams::TYPE_PANEL);
params.delegate = this;
@@ -345,8 +297,8 @@ void NativeAppWindowViews::InitializePanelWindow(
// TODO(erg): Conceptually, these are toplevel windows, but we theoretically
// could plumb context through to here in some cases.
params.top_level = true;
- window_->Init(params);
- window_->set_focus_on_creation(create_params.focused);
+ window()->Init(params);
+ window()->set_focus_on_creation(create_params.focused);
#if defined(USE_ASH)
if (create_params.state == ui::SHOW_STATE_DETACHED) {
@@ -359,7 +311,7 @@ void NativeAppWindowViews::InitializePanelWindow(
aura::client::ParentWindowWithContext(native_window,
native_window->GetRootWindow(),
native_window->GetBoundsInScreen());
- window_->SetBounds(window_bounds);
+ window()->SetBounds(window_bounds);
}
#else
// TODO(stevenjb): NativeAppWindow panels need to be implemented for other
@@ -367,71 +319,9 @@ void NativeAppWindowViews::InitializePanelWindow(
#endif
}
-bool NativeAppWindowViews::ShouldUseChromeStyleFrame() const {
- if (frameless_)
- return true;
-
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
- // Linux always uses native style frames.
- return false;
-#endif
-
- return !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAppsUseNativeFrame);
-}
-
-apps::AppWindowFrameView* NativeAppWindowViews::CreateAppWindowFrameView() {
- // By default the user can resize the window from slightly inside the bounds.
- int resize_inside_bounds_size = kResizeInsideBoundsSize;
- int resize_outside_bounds_size = 0;
- int resize_outside_scale_for_touch = 1;
- int resize_area_corner_size = kResizeAreaCornerSize;
-#if defined(USE_ASH)
- // For Aura windows on the Ash desktop the sizes are different and the user
- // can resize the window from slightly outside the bounds as well.
- if (chrome::IsNativeWindowInAsh(window_->GetNativeWindow())) {
- resize_inside_bounds_size = ash::kResizeInsideBoundsSize;
- resize_outside_bounds_size = ash::kResizeOutsideBoundsSize;
- resize_outside_scale_for_touch = ash::kResizeOutsideBoundsScaleForTouch;
- resize_area_corner_size = ash::kResizeAreaCornerSize;
- }
-#endif
- apps::AppWindowFrameView* frame_view = new apps::AppWindowFrameView(this);
- frame_view->Init(window_,
- resize_inside_bounds_size,
- resize_outside_bounds_size,
- resize_outside_scale_for_touch,
- resize_area_corner_size);
- return frame_view;
-}
-
-// ui::BaseWindow implementation.
+// ui::BaseWindow overrides:
-bool NativeAppWindowViews::IsActive() const {
- return window_->IsActive();
-}
-
-bool NativeAppWindowViews::IsMaximized() const {
- return window_->IsMaximized();
-}
-
-bool NativeAppWindowViews::IsMinimized() const {
- return window_->IsMinimized();
-}
-
-bool NativeAppWindowViews::IsFullscreen() const {
- return window_->IsFullscreen();
-}
-
-gfx::NativeWindow NativeAppWindowViews::GetNativeWindow() {
- return window_->GetNativeWindow();
-}
-
-gfx::Rect NativeAppWindowViews::GetRestoredBounds() const {
- return window_->GetRestoredBounds();
-}
-
-ui::WindowShowState NativeAppWindowViews::GetRestoredState() const {
+ui::WindowShowState ChromeNativeAppWindowViews::GetRestoredState() const {
if (IsMaximized())
return ui::SHOW_STATE_MAXIMIZED;
if (IsFullscreen()) {
@@ -470,83 +360,26 @@ ui::WindowShowState NativeAppWindowViews::GetRestoredState() const {
return ui::SHOW_STATE_NORMAL;
}
-gfx::Rect NativeAppWindowViews::GetBounds() const {
- return window_->GetWindowBoundsInScreen();
-}
-
-void NativeAppWindowViews::Show() {
- if (window_->IsVisible()) {
- window_->Activate();
- return;
- }
-
- window_->Show();
-}
-
-void NativeAppWindowViews::ShowInactive() {
- if (window_->IsVisible())
- return;
- window_->ShowInactive();
-}
-
-void NativeAppWindowViews::Hide() {
- window_->Hide();
-}
-
-void NativeAppWindowViews::Close() {
- window_->Close();
-}
-
-void NativeAppWindowViews::Activate() {
- window_->Activate();
-}
-
-void NativeAppWindowViews::Deactivate() {
- window_->Deactivate();
-}
-
-void NativeAppWindowViews::Maximize() {
- window_->Maximize();
-}
-
-void NativeAppWindowViews::Minimize() {
- window_->Minimize();
-}
-
-void NativeAppWindowViews::Restore() {
- window_->Restore();
-}
-
-void NativeAppWindowViews::SetBounds(const gfx::Rect& bounds) {
- window_->SetBounds(bounds);
-}
-
-void NativeAppWindowViews::FlashFrame(bool flash) {
- window_->FlashFrame(flash);
-}
-
-bool NativeAppWindowViews::IsAlwaysOnTop() const {
- if (app_window_->window_type_is_panel()) {
+bool ChromeNativeAppWindowViews::IsAlwaysOnTop() const {
+ if (app_window()->window_type_is_panel()) {
#if defined(USE_ASH)
- return ash::wm::GetWindowState(window_->GetNativeWindow())->
+ return ash::wm::GetWindowState(window()->GetNativeWindow())->
panel_attached();
#else
return true;
#endif
} else {
- return window_->IsAlwaysOnTop();
+ return window()->IsAlwaysOnTop();
}
}
-void NativeAppWindowViews::SetAlwaysOnTop(bool always_on_top) {
- window_->SetAlwaysOnTop(always_on_top);
-}
+// views::ContextMenuController overrides:
-void NativeAppWindowViews::ShowContextMenuForView(
+void ChromeNativeAppWindowViews::ShowContextMenuForView(
views::View* source,
const gfx::Point& p,
ui::MenuSourceType source_type) {
-#if defined(USE_ASH) & defined(OS_CHROMEOS)
+#if defined(USE_ASH) && defined(OS_CHROMEOS)
scoped_ptr<ui::MenuModel> model =
CreateMultiUserContextMenu(app_window_->GetNativeWindow());
if (!model.get())
@@ -570,74 +403,10 @@ void NativeAppWindowViews::ShowContextMenuForView(
#endif
}
-gfx::NativeView NativeAppWindowViews::GetHostView() const {
- return window_->GetNativeView();
-}
-
-gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) {
- gfx::Size app_window_size = window_->GetWindowBoundsInScreen().size();
- return gfx::Point(app_window_size.width() / 2 - size.width() / 2,
- app_window_size.height() / 2 - size.height() / 2);
-}
-
-gfx::Size NativeAppWindowViews::GetMaximumDialogSize() {
- return window_->GetWindowBoundsInScreen().size();
-}
-
-void NativeAppWindowViews::AddObserver(
- web_modal::ModalDialogHostObserver* observer) {
- observer_list_.AddObserver(observer);
-}
-void NativeAppWindowViews::RemoveObserver(
- web_modal::ModalDialogHostObserver* observer) {
- observer_list_.RemoveObserver(observer);
-}
-
-// Private method. TODO(stevenjb): Move this below InitializePanelWindow()
-// to match declaration order.
-void NativeAppWindowViews::OnViewWasResized() {
- FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver,
- observer_list_,
- OnPositionRequiresUpdate());
-}
-
-// WidgetDelegate implementation.
-
-void NativeAppWindowViews::OnWidgetMove() {
- app_window_->OnNativeWindowChanged();
-}
-
-views::View* NativeAppWindowViews::GetInitiallyFocusedView() {
- return web_view_;
-}
-
-bool NativeAppWindowViews::CanResize() const {
- return resizable_ && !app_window_->size_constraints().HasFixedSize();
-}
-
-bool NativeAppWindowViews::CanMaximize() const {
- return resizable_ && !app_window_->size_constraints().HasMaximumSize() &&
- !app_window_->window_type_is_panel();
-}
-
-base::string16 NativeAppWindowViews::GetWindowTitle() const {
- return app_window_->GetTitle();
-}
-
-bool NativeAppWindowViews::ShouldShowWindowTitle() const {
- return app_window_->window_type() == AppWindow::WINDOW_TYPE_V1_PANEL;
-}
+// views::WidgetDelegate overrides:
-gfx::ImageSkia NativeAppWindowViews::GetWindowAppIcon() {
- gfx::Image app_icon = app_window_->app_icon();
- if (app_icon.IsEmpty())
- return GetWindowIcon();
- else
- return *app_icon.ToImageSkia();
-}
-
-gfx::ImageSkia NativeAppWindowViews::GetWindowIcon() {
- content::WebContents* web_contents = app_window_->web_contents();
+gfx::ImageSkia ChromeNativeAppWindowViews::GetWindowIcon() {
+ content::WebContents* web_contents = app_window()->web_contents();
if (web_contents) {
FaviconTabHelper* favicon_tab_helper =
FaviconTabHelper::FromWebContents(web_contents);
@@ -648,34 +417,7 @@ gfx::ImageSkia NativeAppWindowViews::GetWindowIcon() {
return gfx::ImageSkia();
}
-bool NativeAppWindowViews::ShouldShowWindowIcon() const {
- return app_window_->window_type() == AppWindow::WINDOW_TYPE_V1_PANEL;
-}
-
-void NativeAppWindowViews::SaveWindowPlacement(const gfx::Rect& bounds,
- ui::WindowShowState show_state) {
- views::WidgetDelegate::SaveWindowPlacement(bounds, show_state);
- app_window_->OnNativeWindowChanged();
-}
-
-void NativeAppWindowViews::DeleteDelegate() {
- window_->RemoveObserver(this);
- app_window_->OnNativeClose();
-}
-
-views::Widget* NativeAppWindowViews::GetWidget() {
- return window_;
-}
-
-const views::Widget* NativeAppWindowViews::GetWidget() const {
- return window_;
-}
-
-views::View* NativeAppWindowViews::GetContentsView() {
- return this;
-}
-
-views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView(
+views::NonClientFrameView* ChromeNativeAppWindowViews::CreateNonClientFrameView(
views::Widget* widget) {
#if defined(USE_ASH)
if (chrome::IsNativeViewInAsh(widget->GetNativeView())) {
@@ -683,10 +425,10 @@ views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView(
// WindowStateDelegate if one is not already set.
ash::wm::GetWindowState(GetNativeWindow())->SetDelegate(
scoped_ptr<ash::wm::WindowStateDelegate>(
- new NativeAppWindowStateDelegate(app_window_, this)).Pass());
+ new NativeAppWindowStateDelegate(app_window(), this)).Pass());
- if (app_window_->window_type_is_panel()) {
- ash::PanelFrameView::FrameType frame_type = frameless_ ?
+ if (app_window()->window_type_is_panel()) {
+ ash::PanelFrameView::FrameType frame_type = IsFrameless() ?
ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH;
views::NonClientFrameView* frame_view =
new ash::PanelFrameView(widget, frame_type);
@@ -694,7 +436,7 @@ views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView(
return frame_view;
}
- if (!frameless_) {
+ if (!IsFrameless()) {
ash::CustomFrameViewAsh* custom_frame_view =
new ash::CustomFrameViewAsh(widget);
#if defined(OS_CHROMEOS)
@@ -718,102 +460,15 @@ views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView(
return views::WidgetDelegateView::CreateNonClientFrameView(widget);
}
-bool NativeAppWindowViews::WidgetHasHitTestMask() const {
- return shape_ != NULL;
-}
-
-void NativeAppWindowViews::GetWidgetHitTestMask(gfx::Path* mask) const {
- shape_->getBoundaryPath(mask);
-}
-
-bool NativeAppWindowViews::ShouldDescendIntoChildForEventHandling(
- gfx::NativeView child,
- const gfx::Point& location) {
-#if defined(USE_AURA)
- if (child->Contains(web_view_->web_contents()->GetView()->GetNativeView())) {
- // App window should claim mouse events that fall within the draggable
- // region.
- return !draggable_region_.get() ||
- !draggable_region_->contains(location.x(), location.y());
- }
-#endif
-
- return true;
-}
-
-// WidgetObserver implementation.
-
-void NativeAppWindowViews::OnWidgetVisibilityChanged(views::Widget* widget,
- bool visible) {
- app_window_->OnNativeWindowChanged();
-}
-
-void NativeAppWindowViews::OnWidgetActivationChanged(views::Widget* widget,
- bool active) {
- app_window_->OnNativeWindowChanged();
- if (active)
- app_window_->OnNativeWindowActivated();
-}
-
-// WebContentsObserver implementation.
+// views::View overrides:
-void NativeAppWindowViews::RenderViewCreated(
- content::RenderViewHost* render_view_host) {
- if (transparent_background_) {
- // Use a background with transparency to trigger transparency in Webkit.
- SkBitmap background;
- background.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
- background.allocPixels();
- background.eraseARGB(0x00, 0x00, 0x00, 0x00);
-
- content::RenderWidgetHostView* view = render_view_host->GetView();
- DCHECK(view);
- view->SetBackground(background);
- }
-}
-
-void NativeAppWindowViews::RenderViewHostChanged(
- content::RenderViewHost* old_host,
- content::RenderViewHost* new_host) {
- OnViewWasResized();
-}
-
-// views::View implementation.
-
-void NativeAppWindowViews::Layout() {
- DCHECK(web_view_);
- web_view_->SetBounds(0, 0, width(), height());
- OnViewWasResized();
-}
-
-void NativeAppWindowViews::ViewHierarchyChanged(
- const ViewHierarchyChangedDetails& details) {
- if (details.is_add && details.child == this) {
- web_view_ = new views::WebView(NULL);
- AddChildView(web_view_);
- web_view_->SetWebContents(web_contents());
- }
-}
-
-gfx::Size NativeAppWindowViews::GetPreferredSize() {
+gfx::Size ChromeNativeAppWindowViews::GetPreferredSize() {
if (!preferred_size_.IsEmpty())
return preferred_size_;
- return views::View::GetPreferredSize();
-}
-
-gfx::Size NativeAppWindowViews::GetMinimumSize() {
- return app_window_->size_constraints().GetMinimumSize();
-}
-
-gfx::Size NativeAppWindowViews::GetMaximumSize() {
- return app_window_->size_constraints().GetMaximumSize();
+ return NativeAppWindowViews::GetPreferredSize();
}
-void NativeAppWindowViews::OnFocus() {
- web_view_->RequestFocus();
-}
-
-bool NativeAppWindowViews::AcceleratorPressed(
+bool ChromeNativeAppWindowViews::AcceleratorPressed(
const ui::Accelerator& accelerator) {
const std::map<ui::Accelerator, int>& accelerator_table =
GetAcceleratorTable();
@@ -826,31 +481,31 @@ bool NativeAppWindowViews::AcceleratorPressed(
Close();
return true;
case IDC_ZOOM_MINUS:
- chrome_page_zoom::Zoom(web_view_->GetWebContents(),
+ chrome_page_zoom::Zoom(web_view()->GetWebContents(),
content::PAGE_ZOOM_OUT);
return true;
case IDC_ZOOM_NORMAL:
- chrome_page_zoom::Zoom(web_view_->GetWebContents(),
+ chrome_page_zoom::Zoom(web_view()->GetWebContents(),
content::PAGE_ZOOM_RESET);
return true;
case IDC_ZOOM_PLUS:
- chrome_page_zoom::Zoom(web_view_->GetWebContents(),
+ chrome_page_zoom::Zoom(web_view()->GetWebContents(),
content::PAGE_ZOOM_IN);
return true;
default:
NOTREACHED() << "Unknown accelerator sent to app window.";
}
- return false;
+ return NativeAppWindowViews::AcceleratorPressed(accelerator);
}
-// NativeAppWindow implementation.
+// NativeAppWindow overrides:
-void NativeAppWindowViews::SetFullscreen(int fullscreen_types) {
+void ChromeNativeAppWindowViews::SetFullscreen(int fullscreen_types) {
// Fullscreen not supported by panels.
- if (app_window_->window_type_is_panel())
+ if (app_window()->window_type_is_panel())
return;
is_fullscreen_ = (fullscreen_types != AppWindow::FULLSCREEN_TYPE_NONE);
- window_->SetFullscreen(is_fullscreen_);
+ window()->SetFullscreen(is_fullscreen_);
#if defined(USE_ASH)
if (immersive_fullscreen_controller_.get()) {
@@ -862,7 +517,7 @@ void NativeAppWindowViews::SetFullscreen(int fullscreen_types) {
// Autohide the shelf instead of hiding the shelf completely when only in
// OS fullscreen.
ash::wm::WindowState* window_state =
- ash::wm::GetWindowState(window_->GetNativeWindow());
+ ash::wm::GetWindowState(window()->GetNativeWindow());
window_state->set_hide_shelf_when_fullscreen(fullscreen_types !=
AppWindow::FULLSCREEN_TYPE_OS);
DCHECK(ash::Shell::HasInstance());
@@ -875,32 +530,24 @@ void NativeAppWindowViews::SetFullscreen(int fullscreen_types) {
// wasn't the app calling webkitCancelFullScreen().
}
-bool NativeAppWindowViews::IsFullscreenOrPending() const {
+bool ChromeNativeAppWindowViews::IsFullscreenOrPending() const {
return is_fullscreen_;
}
-bool NativeAppWindowViews::IsDetached() const {
- if (!app_window_->window_type_is_panel())
+bool ChromeNativeAppWindowViews::IsDetached() const {
+ if (!app_window()->window_type_is_panel())
return false;
#if defined(USE_ASH)
- return !ash::wm::GetWindowState(window_->GetNativeWindow())->panel_attached();
+ return !ash::wm::GetWindowState(window()->GetNativeWindow())->panel_attached();
#else
return false;
#endif
}
-void NativeAppWindowViews::UpdateWindowIcon() {
- window_->UpdateWindowIcon();
-}
-
-void NativeAppWindowViews::UpdateWindowTitle() {
- window_->UpdateWindowTitle();
-}
-
-void NativeAppWindowViews::UpdateBadgeIcon() {
+void ChromeNativeAppWindowViews::UpdateBadgeIcon() {
const gfx::Image* icon = NULL;
- if (!app_window_->badge_icon().IsEmpty()) {
- icon = &app_window_->badge_icon();
+ if (!app_window()->badge_icon().IsEmpty()) {
+ icon = &app_window()->badge_icon();
// chrome::DrawTaskbarDecoration can do interesting things with non-square
// bitmaps.
// TODO(benwells): Refactor chrome::DrawTaskbarDecoration to not be avatar
@@ -913,64 +560,62 @@ void NativeAppWindowViews::UpdateBadgeIcon() {
chrome::DrawTaskbarDecoration(GetNativeWindow(), icon);
}
-void NativeAppWindowViews::UpdateDraggableRegions(
- const std::vector<extensions::DraggableRegion>& regions) {
- // Draggable region is not supported for non-frameless window.
- if (!frameless_)
- return;
-
- draggable_region_.reset(AppWindow::RawDraggableRegionsToSkRegion(regions));
- OnViewWasResized();
-}
+// NativeAppWindowViews overrides:
-SkRegion* NativeAppWindowViews::GetDraggableRegion() {
- return draggable_region_.get();
-}
-
-void NativeAppWindowViews::UpdateShape(scoped_ptr<SkRegion> region) {
- bool had_shape = shape_;
- shape_ = region.Pass();
-
- aura::Window* native_window = window_->GetNativeWindow();
- if (shape_) {
- window_->SetShape(new SkRegion(*shape_));
- if (!had_shape) {
- native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
- new ShapedAppWindowTargeter(native_window, this)));
- }
+void ChromeNativeAppWindowViews::InitializeWindow(
+ AppWindow* app_window,
+ const AppWindow::CreateParams& create_params) {
+ DCHECK(window());
+ if (create_params.window_type == AppWindow::WINDOW_TYPE_PANEL ||
+ create_params.window_type == AppWindow::WINDOW_TYPE_V1_PANEL) {
+ InitializePanelWindow(create_params);
} else {
- window_->SetShape(NULL);
- if (had_shape)
- native_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>());
+ InitializeDefaultWindow(create_params);
}
+ extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
+ Profile::FromBrowserContext(browser_context()),
+ window()->GetFocusManager(),
+ extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
+ app_window));
}
-void NativeAppWindowViews::HandleKeyboardEvent(
- const content::NativeWebKeyboardEvent& event) {
- unhandled_keyboard_event_handler_.HandleKeyboardEvent(event,
- GetFocusManager());
-}
+// private methods:
-bool NativeAppWindowViews::IsFrameless() const {
- return frameless_;
-}
+bool ChromeNativeAppWindowViews::ShouldUseChromeStyleFrame() const {
+ if (IsFrameless())
+ return true;
-gfx::Insets NativeAppWindowViews::GetFrameInsets() const {
- if (frameless_)
- return gfx::Insets();
-
- // The pretend client_bounds passed in need to be large enough to ensure that
- // GetWindowBoundsForClientBounds() doesn't decide that it needs more than
- // the specified amount of space to fit the window controls in, and return a
- // number larger than the real frame insets. Most window controls are smaller
- // than 1000x1000px, so this should be big enough.
- gfx::Rect client_bounds = gfx::Rect(1000, 1000);
- gfx::Rect window_bounds =
- window_->non_client_view()->GetWindowBoundsForClientBounds(
- client_bounds);
- return window_bounds.InsetsFrom(client_bounds);
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ // Linux always uses native style frames.
+ return false;
+#endif
+
+ return !CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAppsUseNativeFrame);
}
-void NativeAppWindowViews::HideWithApp() {}
-void NativeAppWindowViews::ShowWithApp() {}
-void NativeAppWindowViews::UpdateWindowMinMaxSize() {}
+apps::AppWindowFrameView*
+ChromeNativeAppWindowViews::CreateAppWindowFrameView() {
+ // By default the user can resize the window from slightly inside the bounds.
+ int resize_inside_bounds_size = kResizeInsideBoundsSize;
+ int resize_outside_bounds_size = 0;
+ int resize_outside_scale_for_touch = 1;
+ int resize_area_corner_size = kResizeAreaCornerSize;
+#if defined(USE_ASH)
+ // For Aura windows on the Ash desktop the sizes are different and the user
+ // can resize the window from slightly outside the bounds as well.
+ if (chrome::IsNativeWindowInAsh(window()->GetNativeWindow())) {
+ resize_inside_bounds_size = ash::kResizeInsideBoundsSize;
+ resize_outside_bounds_size = ash::kResizeOutsideBoundsSize;
+ resize_outside_scale_for_touch = ash::kResizeOutsideBoundsScaleForTouch;
+ resize_area_corner_size = ash::kResizeAreaCornerSize;
+ }
+#endif
+ apps::AppWindowFrameView* frame_view = new apps::AppWindowFrameView(this);
+ frame_view->Init(window(),
+ resize_inside_bounds_size,
+ resize_outside_bounds_size,
+ resize_outside_scale_for_touch,
+ resize_area_corner_size);
+ return frame_view;
+}
« no previous file with comments | « chrome/browser/ui/views/apps/native_app_window_views.h ('k') | chrome/browser/ui/views/apps/native_app_window_views_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698