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

Unified Diff: chrome/browser/ui/views/apps/chrome_native_app_window_views.cc

Issue 616253002: Extract NativeAppWindow from src/extensions Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: might fix athena. similarity=33 Created 6 years, 3 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/chrome_native_app_window_views.cc
diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc
index 519c53cecbd6f5eee03706864601c83dd769737e..ae147eac757907b90ab3a55f7fc52745508107c0 100644
--- a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc
+++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/ui/zoom/zoom_controller.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_switches.h"
+#include "extensions/browser/app_window/app_window.h"
#include "extensions/common/extension.h"
#include "ui/aura/window.h"
#include "ui/base/hit_test.h"
@@ -56,8 +57,6 @@
#include "ash/shell_window_ids.h"
#endif
-using extensions::AppWindow;
-
namespace {
const int kMinPanelWidth = 100;
@@ -128,8 +127,9 @@ class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate,
public ash::wm::WindowStateObserver,
public aura::WindowObserver {
public:
- NativeAppWindowStateDelegate(AppWindow* app_window,
- extensions::NativeAppWindow* native_app_window)
+ NativeAppWindowStateDelegate(
+ extensions::AppWindow* app_window,
+ native_app_window::NativeAppWindow* native_app_window)
: app_window_(app_window),
window_state_(
ash::wm::GetWindowState(native_app_window->GetNativeWindow())) {
@@ -186,7 +186,7 @@ class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate,
}
// Not owned.
- AppWindow* app_window_;
+ extensions::AppWindow* app_window_;
ash::wm::WindowState* window_state_;
DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate);
@@ -195,11 +195,13 @@ class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate,
} // namespace
-ChromeNativeAppWindowViews::ChromeNativeAppWindowViews()
+ChromeNativeAppWindowViews::ChromeNativeAppWindowViews(
+ extensions::AppWindow* extensions_app_window)
: is_fullscreen_(false),
has_frame_color_(false),
active_frame_color_(SK_ColorBLACK),
- inactive_frame_color_(SK_ColorBLACK) {
+ inactive_frame_color_(SK_ColorBLACK),
+ extensions_app_window_(extensions_app_window) {
}
ChromeNativeAppWindowViews::~ChromeNativeAppWindowViews() {}
@@ -209,9 +211,9 @@ void ChromeNativeAppWindowViews::OnBeforeWidgetInit(
views::Widget* widget) {}
void ChromeNativeAppWindowViews::InitializeDefaultWindow(
- const AppWindow::CreateParams& create_params) {
+ const native_app_window::AppWindowCreateParams& create_params) {
std::string app_name = web_app::GenerateApplicationNameFromExtensionId(
- app_window()->extension_id());
+ extensions_app_window_->extension_id());
views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW);
init_params.delegate = this;
@@ -250,7 +252,7 @@ void ChromeNativeAppWindowViews::InitializeDefaultWindow(
SetContentSizeConstraints(create_params.GetContentMinimumSize(frame_insets),
create_params.GetContentMaximumSize(frame_insets));
if (!window_bounds.IsEmpty()) {
- typedef AppWindow::BoundsSpecification BoundsSpecification;
+ typedef native_app_window::BoundsSpecification BoundsSpecification;
bool position_specified =
window_bounds.x() != BoundsSpecification::kUnspecifiedPosition &&
window_bounds.y() != BoundsSpecification::kUnspecifiedPosition;
@@ -308,7 +310,7 @@ void ChromeNativeAppWindowViews::InitializeDefaultWindow(
}
void ChromeNativeAppWindowViews::InitializePanelWindow(
- const AppWindow::CreateParams& create_params) {
+ const native_app_window::AppWindowCreateParams& create_params) {
views::Widget::InitParams params(views::Widget::InitParams::TYPE_PANEL);
params.delegate = this;
@@ -446,7 +448,7 @@ ui::WindowShowState ChromeNativeAppWindowViews::GetRestoredState() const {
}
bool ChromeNativeAppWindowViews::IsAlwaysOnTop() const {
- if (app_window()->window_type_is_panel()) {
+ if (app_window()->WindowTypeIsPanel()) {
#if defined(USE_ASH)
return ash::wm::GetWindowState(widget()->GetNativeWindow())
->panel_attached();
@@ -495,7 +497,7 @@ void ChromeNativeAppWindowViews::ShowContextMenuForView(
// views::WidgetDelegate implementation.
gfx::ImageSkia ChromeNativeAppWindowViews::GetWindowAppIcon() {
- gfx::Image app_icon = app_window()->app_icon();
+ gfx::Image app_icon = extensions_app_window_->app_icon();
if (app_icon.IsEmpty())
return GetWindowIcon();
else
@@ -503,7 +505,7 @@ gfx::ImageSkia ChromeNativeAppWindowViews::GetWindowAppIcon() {
}
gfx::ImageSkia ChromeNativeAppWindowViews::GetWindowIcon() {
- content::WebContents* web_contents = app_window()->web_contents();
+ content::WebContents* web_contents = app_window()->GetWebContents();
if (web_contents) {
FaviconTabHelper* favicon_tab_helper =
FaviconTabHelper::FromWebContents(web_contents);
@@ -520,11 +522,12 @@ views::NonClientFrameView* ChromeNativeAppWindowViews::CreateNonClientFrameView(
if (chrome::IsNativeViewInAsh(widget->GetNativeView())) {
// Set the delegate now because CustomFrameViewAsh sets the
// WindowStateDelegate if one is not already set.
- ash::wm::GetWindowState(GetNativeWindow())->SetDelegate(
- scoped_ptr<ash::wm::WindowStateDelegate>(
- new NativeAppWindowStateDelegate(app_window(), this)).Pass());
+ ash::wm::GetWindowState(GetNativeWindow())
+ ->SetDelegate(scoped_ptr<ash::wm::WindowStateDelegate>(
+ new NativeAppWindowStateDelegate(
+ extensions_app_window_, this)).Pass());
- if (app_window()->window_type_is_panel()) {
+ if (app_window()->WindowTypeIsPanel()) {
ash::PanelFrameView::FrameType frame_type = IsFrameless() ?
ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH;
views::NonClientFrameView* frame_view =
@@ -601,9 +604,10 @@ bool ChromeNativeAppWindowViews::AcceleratorPressed(
void ChromeNativeAppWindowViews::SetFullscreen(int fullscreen_types) {
// Fullscreen not supported by panels.
- if (app_window()->window_type_is_panel())
+ if (app_window()->WindowTypeIsPanel())
return;
- is_fullscreen_ = (fullscreen_types != AppWindow::FULLSCREEN_TYPE_NONE);
+ is_fullscreen_ =
+ (fullscreen_types != native_app_window::FULLSCREEN_TYPE_NONE);
widget()->SetFullscreen(is_fullscreen_);
// TODO(oshima): Remove USE_ATHENA once athena has its own NativeAppWindow.
@@ -613,13 +617,13 @@ void ChromeNativeAppWindowViews::SetFullscreen(int fullscreen_types) {
// fullscreen is the fullscreen type used by the OS.
immersive_fullscreen_controller_->SetEnabled(
ash::ImmersiveFullscreenController::WINDOW_TYPE_PACKAGED_APP,
- (fullscreen_types & AppWindow::FULLSCREEN_TYPE_OS) != 0);
+ (fullscreen_types & native_app_window::FULLSCREEN_TYPE_OS) != 0);
// Autohide the shelf instead of hiding the shelf completely when only in
// OS fullscreen.
ash::wm::WindowState* window_state =
ash::wm::GetWindowState(widget()->GetNativeWindow());
- window_state->set_hide_shelf_when_fullscreen(fullscreen_types !=
- AppWindow::FULLSCREEN_TYPE_OS);
+ window_state->set_hide_shelf_when_fullscreen(
+ fullscreen_types != native_app_window::FULLSCREEN_TYPE_OS);
DCHECK(ash::Shell::HasInstance());
ash::Shell::GetInstance()->UpdateShelfVisibility();
}
@@ -636,8 +640,8 @@ bool ChromeNativeAppWindowViews::IsFullscreenOrPending() const {
void ChromeNativeAppWindowViews::UpdateBadgeIcon() {
const gfx::Image* icon = NULL;
- if (!app_window()->badge_icon().IsEmpty()) {
- icon = &app_window()->badge_icon();
+ if (!extensions_app_window_->badge_icon().IsEmpty()) {
+ icon = &extensions_app_window_->badge_icon();
// chrome::DrawTaskbarDecoration can do interesting things with non-square
// bitmaps.
// TODO(benwells): Refactor chrome::DrawTaskbarDecoration to not be avatar
@@ -684,20 +688,20 @@ SkColor ChromeNativeAppWindowViews::InactiveFrameColor() const {
// NativeAppWindowViews implementation.
void ChromeNativeAppWindowViews::InitializeWindow(
- AppWindow* app_window,
- const AppWindow::CreateParams& create_params) {
+ native_app_window::NativeAppWindowDelegate* app_window,
+ const native_app_window::AppWindowCreateParams& create_params) {
DCHECK(widget());
has_frame_color_ = create_params.has_frame_color;
active_frame_color_ = create_params.active_frame_color;
inactive_frame_color_ = create_params.inactive_frame_color;
- if (create_params.window_type == AppWindow::WINDOW_TYPE_PANEL ||
- create_params.window_type == AppWindow::WINDOW_TYPE_V1_PANEL) {
+ if (create_params.window_type == native_app_window::WINDOW_TYPE_PANEL ||
+ create_params.window_type == native_app_window::WINDOW_TYPE_V1_PANEL) {
InitializePanelWindow(create_params);
} else {
InitializeDefaultWindow(create_params);
}
extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews(
- Profile::FromBrowserContext(app_window->browser_context()),
+ Profile::FromBrowserContext(app_window->GetBrowserContext()),
widget()->GetFocusManager(),
extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
NULL));

Powered by Google App Engine
This is Rietveld 408576698