| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/apps/native_app_window_views.h" | 5 #include "chrome/browser/ui/views/apps/native_app_window_views.h" |
| 6 | 6 |
| 7 #include "apps/shell_window.h" | 7 #include "apps/app_window.h" |
| 8 #include "apps/ui/views/shell_window_frame_view.h" | 8 #include "apps/ui/views/app_window_frame_view.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/threading/sequenced_worker_pool.h" | 12 #include "base/threading/sequenced_worker_pool.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "chrome/browser/app_mode/app_mode_utils.h" | 14 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 15 #include "chrome/browser/chrome_page_zoom.h" | 15 #include "chrome/browser/chrome_page_zoom.h" |
| 16 #include "chrome/browser/extensions/extension_host.h" | 16 #include "chrome/browser/extensions/extension_host.h" |
| 17 #include "chrome/browser/favicon/favicon_tab_helper.h" | 17 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 #include "ui/aura/client/aura_constants.h" | 64 #include "ui/aura/client/aura_constants.h" |
| 65 #include "ui/aura/client/window_tree_client.h" | 65 #include "ui/aura/client/window_tree_client.h" |
| 66 #include "ui/aura/window.h" | 66 #include "ui/aura/window.h" |
| 67 #include "ui/aura/window_observer.h" | 67 #include "ui/aura/window_observer.h" |
| 68 #endif | 68 #endif |
| 69 | 69 |
| 70 #if defined(USE_AURA) | 70 #if defined(USE_AURA) |
| 71 #include "ui/aura/window.h" | 71 #include "ui/aura/window.h" |
| 72 #endif | 72 #endif |
| 73 | 73 |
| 74 using apps::ShellWindow; | 74 using apps::AppWindow; |
| 75 | 75 |
| 76 namespace { | 76 namespace { |
| 77 | 77 |
| 78 const int kMinPanelWidth = 100; | 78 const int kMinPanelWidth = 100; |
| 79 const int kMinPanelHeight = 100; | 79 const int kMinPanelHeight = 100; |
| 80 const int kDefaultPanelWidth = 200; | 80 const int kDefaultPanelWidth = 200; |
| 81 const int kDefaultPanelHeight = 300; | 81 const int kDefaultPanelHeight = 300; |
| 82 const int kResizeInsideBoundsSize = 5; | 82 const int kResizeInsideBoundsSize = 5; |
| 83 const int kResizeAreaCornerSize = 16; | 83 const int kResizeAreaCornerSize = 16; |
| 84 | 84 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon); | 171 web_app::internals::CheckAndSaveIcon(icon_file, shortcut_info.favicon); |
| 172 } | 172 } |
| 173 #endif | 173 #endif |
| 174 | 174 |
| 175 #if defined(USE_ASH) | 175 #if defined(USE_ASH) |
| 176 // This class handles a user's fullscreen request (Shift+F4/F4). | 176 // This class handles a user's fullscreen request (Shift+F4/F4). |
| 177 class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate, | 177 class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate, |
| 178 public ash::wm::WindowStateObserver, | 178 public ash::wm::WindowStateObserver, |
| 179 public aura::WindowObserver { | 179 public aura::WindowObserver { |
| 180 public: | 180 public: |
| 181 NativeAppWindowStateDelegate(ShellWindow* shell_window, | 181 NativeAppWindowStateDelegate(AppWindow* app_window, |
| 182 apps::NativeAppWindow* native_app_window) | 182 apps::NativeAppWindow* native_app_window) |
| 183 : shell_window_(shell_window), | 183 : app_window_(app_window), |
| 184 window_state_( | 184 window_state_( |
| 185 ash::wm::GetWindowState(native_app_window->GetNativeWindow())) { | 185 ash::wm::GetWindowState(native_app_window->GetNativeWindow())) { |
| 186 // Add a window state observer to exit fullscreen properly in case | 186 // Add a window state observer to exit fullscreen properly in case |
| 187 // fullscreen is exited without going through ShellWindow::Restore(). This | 187 // fullscreen is exited without going through AppWindow::Restore(). This |
| 188 // is the case when exiting immersive fullscreen via the "Restore" window | 188 // is the case when exiting immersive fullscreen via the "Restore" window |
| 189 // control. | 189 // control. |
| 190 // TODO(pkotwicz): This is a hack. Remove ASAP. http://crbug.com/319048 | 190 // TODO(pkotwicz): This is a hack. Remove ASAP. http://crbug.com/319048 |
| 191 window_state_->AddObserver(this); | 191 window_state_->AddObserver(this); |
| 192 window_state_->window()->AddObserver(this); | 192 window_state_->window()->AddObserver(this); |
| 193 } | 193 } |
| 194 virtual ~NativeAppWindowStateDelegate(){ | 194 virtual ~NativeAppWindowStateDelegate(){ |
| 195 if (window_state_) { | 195 if (window_state_) { |
| 196 window_state_->RemoveObserver(this); | 196 window_state_->RemoveObserver(this); |
| 197 window_state_->window()->RemoveObserver(this); | 197 window_state_->window()->RemoveObserver(this); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 | 200 |
| 201 private: | 201 private: |
| 202 // Overridden from ash::wm::WindowStateDelegate. | 202 // Overridden from ash::wm::WindowStateDelegate. |
| 203 virtual bool ToggleFullscreen(ash::wm::WindowState* window_state) OVERRIDE { | 203 virtual bool ToggleFullscreen(ash::wm::WindowState* window_state) OVERRIDE { |
| 204 // Windows which cannot be maximized should not be fullscreened. | 204 // Windows which cannot be maximized should not be fullscreened. |
| 205 DCHECK(window_state->IsFullscreen() || window_state->CanMaximize()); | 205 DCHECK(window_state->IsFullscreen() || window_state->CanMaximize()); |
| 206 if (window_state->IsFullscreen()) | 206 if (window_state->IsFullscreen()) |
| 207 shell_window_->Restore(); | 207 app_window_->Restore(); |
| 208 else if (window_state->CanMaximize()) | 208 else if (window_state->CanMaximize()) |
| 209 shell_window_->OSFullscreen(); | 209 app_window_->OSFullscreen(); |
| 210 return true; | 210 return true; |
| 211 } | 211 } |
| 212 | 212 |
| 213 // Overridden from ash::wm::WindowStateObserver: | 213 // Overridden from ash::wm::WindowStateObserver: |
| 214 virtual void OnPostWindowShowTypeChange( | 214 virtual void OnPostWindowShowTypeChange( |
| 215 ash::wm::WindowState* window_state, | 215 ash::wm::WindowState* window_state, |
| 216 ash::wm::WindowShowType old_type) OVERRIDE { | 216 ash::wm::WindowShowType old_type) OVERRIDE { |
| 217 if (!window_state->IsFullscreen() && | 217 if (!window_state->IsFullscreen() && !window_state->IsMinimized() && |
| 218 !window_state->IsMinimized() && | 218 app_window_->GetBaseWindow()->IsFullscreenOrPending()) { |
| 219 shell_window_->GetBaseWindow()->IsFullscreenOrPending()) { | 219 app_window_->Restore(); |
| 220 shell_window_->Restore(); | |
| 221 // Usually OnNativeWindowChanged() is called when the window bounds are | 220 // Usually OnNativeWindowChanged() is called when the window bounds are |
| 222 // changed as a result of a show type change. Because the change in show | 221 // changed as a result of a show type change. Because the change in show |
| 223 // type has already occurred, we need to call OnNativeWindowChanged() | 222 // type has already occurred, we need to call OnNativeWindowChanged() |
| 224 // explicitly. | 223 // explicitly. |
| 225 shell_window_->OnNativeWindowChanged(); | 224 app_window_->OnNativeWindowChanged(); |
| 226 } | 225 } |
| 227 } | 226 } |
| 228 | 227 |
| 229 // Overridden from aura::WindowObserver: | 228 // Overridden from aura::WindowObserver: |
| 230 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { | 229 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { |
| 231 window_state_->RemoveObserver(this); | 230 window_state_->RemoveObserver(this); |
| 232 window_state_->window()->RemoveObserver(this); | 231 window_state_->window()->RemoveObserver(this); |
| 233 window_state_ = NULL; | 232 window_state_ = NULL; |
| 234 } | 233 } |
| 235 | 234 |
| 236 // Not owned. | 235 // Not owned. |
| 237 ShellWindow* shell_window_; | 236 AppWindow* app_window_; |
| 238 ash::wm::WindowState* window_state_; | 237 ash::wm::WindowState* window_state_; |
| 239 | 238 |
| 240 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate); | 239 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate); |
| 241 }; | 240 }; |
| 242 #endif // USE_ASH | 241 #endif // USE_ASH |
| 243 | 242 |
| 244 } // namespace | 243 } // namespace |
| 245 | 244 |
| 246 NativeAppWindowViews::NativeAppWindowViews() | 245 NativeAppWindowViews::NativeAppWindowViews() |
| 247 : web_view_(NULL), | 246 : web_view_(NULL), |
| 248 window_(NULL), | 247 window_(NULL), |
| 249 is_fullscreen_(false), | 248 is_fullscreen_(false), |
| 250 weak_ptr_factory_(this) { | 249 weak_ptr_factory_(this) { |
| 251 } | 250 } |
| 252 | 251 |
| 253 void NativeAppWindowViews::Init( | 252 void NativeAppWindowViews::Init(apps::AppWindow* app_window, |
| 254 apps::ShellWindow* shell_window, | 253 const AppWindow::CreateParams& create_params) { |
| 255 const ShellWindow::CreateParams& create_params) { | 254 app_window_ = app_window; |
| 256 shell_window_ = shell_window; | 255 frameless_ = create_params.frame == AppWindow::FRAME_NONE; |
| 257 frameless_ = create_params.frame == ShellWindow::FRAME_NONE; | |
| 258 transparent_background_ = create_params.transparent_background; | 256 transparent_background_ = create_params.transparent_background; |
| 259 resizable_ = create_params.resizable; | 257 resizable_ = create_params.resizable; |
| 260 Observe(web_contents()); | 258 Observe(web_contents()); |
| 261 | 259 |
| 262 window_ = new views::Widget; | 260 window_ = new views::Widget; |
| 263 if (create_params.window_type == ShellWindow::WINDOW_TYPE_PANEL || | 261 if (create_params.window_type == AppWindow::WINDOW_TYPE_PANEL || |
| 264 create_params.window_type == ShellWindow::WINDOW_TYPE_V1_PANEL) { | 262 create_params.window_type == AppWindow::WINDOW_TYPE_V1_PANEL) { |
| 265 InitializePanelWindow(create_params); | 263 InitializePanelWindow(create_params); |
| 266 } else { | 264 } else { |
| 267 InitializeDefaultWindow(create_params); | 265 InitializeDefaultWindow(create_params); |
| 268 } | 266 } |
| 269 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( | 267 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( |
| 270 Profile::FromBrowserContext(browser_context()), | 268 Profile::FromBrowserContext(browser_context()), |
| 271 window_->GetFocusManager(), | 269 window_->GetFocusManager(), |
| 272 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, | 270 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, |
| 273 shell_window_)); | 271 app_window_)); |
| 274 | 272 |
| 275 OnViewWasResized(); | 273 OnViewWasResized(); |
| 276 window_->AddObserver(this); | 274 window_->AddObserver(this); |
| 277 } | 275 } |
| 278 | 276 |
| 279 NativeAppWindowViews::~NativeAppWindowViews() { | 277 NativeAppWindowViews::~NativeAppWindowViews() { |
| 280 web_view_->SetWebContents(NULL); | 278 web_view_->SetWebContents(NULL); |
| 281 } | 279 } |
| 282 | 280 |
| 283 void NativeAppWindowViews::OnBeforeWidgetInit( | 281 void NativeAppWindowViews::OnBeforeWidgetInit( |
| 284 views::Widget::InitParams* init_params, | 282 views::Widget::InitParams* init_params, |
| 285 views::Widget* widget) {} | 283 views::Widget* widget) {} |
| 286 | 284 |
| 287 void NativeAppWindowViews::InitializeDefaultWindow( | 285 void NativeAppWindowViews::InitializeDefaultWindow( |
| 288 const ShellWindow::CreateParams& create_params) { | 286 const AppWindow::CreateParams& create_params) { |
| 289 std::string app_name = | 287 std::string app_name = |
| 290 web_app::GenerateApplicationNameFromExtensionId(extension()->id()); | 288 web_app::GenerateApplicationNameFromExtensionId(extension()->id()); |
| 291 | 289 |
| 292 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); | 290 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); |
| 293 init_params.delegate = this; | 291 init_params.delegate = this; |
| 294 init_params.remove_standard_frame = ShouldUseChromeStyleFrame(); | 292 init_params.remove_standard_frame = ShouldUseChromeStyleFrame(); |
| 295 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 293 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 296 // On Linux, remove the standard frame. Instead, we will use CustomFrameView | 294 // On Linux, remove the standard frame. Instead, we will use CustomFrameView |
| 297 // to draw a native-like frame. | 295 // to draw a native-like frame. |
| 298 // TODO(mgiuca): Remove this during fix for http://crbug.com/322256. | 296 // TODO(mgiuca): Remove this during fix for http://crbug.com/322256. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 base::Bind(&CreateIconAndSetRelaunchDetails, | 394 base::Bind(&CreateIconAndSetRelaunchDetails, |
| 397 web_app_path, icon_file, shortcut_info, hwnd)); | 395 web_app_path, icon_file, shortcut_info, hwnd)); |
| 398 } | 396 } |
| 399 | 397 |
| 400 HWND NativeAppWindowViews::GetNativeAppWindowHWND() const { | 398 HWND NativeAppWindowViews::GetNativeAppWindowHWND() const { |
| 401 return views::HWNDForWidget(window_->GetTopLevelWidget()); | 399 return views::HWNDForWidget(window_->GetTopLevelWidget()); |
| 402 } | 400 } |
| 403 #endif | 401 #endif |
| 404 | 402 |
| 405 void NativeAppWindowViews::InitializePanelWindow( | 403 void NativeAppWindowViews::InitializePanelWindow( |
| 406 const ShellWindow::CreateParams& create_params) { | 404 const AppWindow::CreateParams& create_params) { |
| 407 views::Widget::InitParams params(views::Widget::InitParams::TYPE_PANEL); | 405 views::Widget::InitParams params(views::Widget::InitParams::TYPE_PANEL); |
| 408 params.delegate = this; | 406 params.delegate = this; |
| 409 | 407 |
| 410 preferred_size_ = gfx::Size(create_params.bounds.width(), | 408 preferred_size_ = gfx::Size(create_params.bounds.width(), |
| 411 create_params.bounds.height()); | 409 create_params.bounds.height()); |
| 412 if (preferred_size_.width() == 0) | 410 if (preferred_size_.width() == 0) |
| 413 preferred_size_.set_width(kDefaultPanelWidth); | 411 preferred_size_.set_width(kDefaultPanelWidth); |
| 414 else if (preferred_size_.width() < kMinPanelWidth) | 412 else if (preferred_size_.width() < kMinPanelWidth) |
| 415 preferred_size_.set_width(kMinPanelWidth); | 413 preferred_size_.set_width(kMinPanelWidth); |
| 416 | 414 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 459 |
| 462 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 460 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 463 // Linux always uses native style frames. | 461 // Linux always uses native style frames. |
| 464 return false; | 462 return false; |
| 465 #endif | 463 #endif |
| 466 | 464 |
| 467 return !CommandLine::ForCurrentProcess()->HasSwitch( | 465 return !CommandLine::ForCurrentProcess()->HasSwitch( |
| 468 switches::kAppsUseNativeFrame); | 466 switches::kAppsUseNativeFrame); |
| 469 } | 467 } |
| 470 | 468 |
| 471 apps::ShellWindowFrameView* NativeAppWindowViews::CreateShellWindowFrameView() { | 469 apps::AppWindowFrameView* NativeAppWindowViews::CreateAppWindowFrameView() { |
| 472 // By default the user can resize the window from slightly inside the bounds. | 470 // By default the user can resize the window from slightly inside the bounds. |
| 473 int resize_inside_bounds_size = kResizeInsideBoundsSize; | 471 int resize_inside_bounds_size = kResizeInsideBoundsSize; |
| 474 int resize_outside_bounds_size = 0; | 472 int resize_outside_bounds_size = 0; |
| 475 int resize_outside_scale_for_touch = 1; | 473 int resize_outside_scale_for_touch = 1; |
| 476 int resize_area_corner_size = kResizeAreaCornerSize; | 474 int resize_area_corner_size = kResizeAreaCornerSize; |
| 477 #if defined(USE_ASH) | 475 #if defined(USE_ASH) |
| 478 // For Aura windows on the Ash desktop the sizes are different and the user | 476 // For Aura windows on the Ash desktop the sizes are different and the user |
| 479 // can resize the window from slightly outside the bounds as well. | 477 // can resize the window from slightly outside the bounds as well. |
| 480 if (chrome::IsNativeWindowInAsh(window_->GetNativeWindow())) { | 478 if (chrome::IsNativeWindowInAsh(window_->GetNativeWindow())) { |
| 481 resize_inside_bounds_size = ash::kResizeInsideBoundsSize; | 479 resize_inside_bounds_size = ash::kResizeInsideBoundsSize; |
| 482 resize_outside_bounds_size = ash::kResizeOutsideBoundsSize; | 480 resize_outside_bounds_size = ash::kResizeOutsideBoundsSize; |
| 483 resize_outside_scale_for_touch = ash::kResizeOutsideBoundsScaleForTouch; | 481 resize_outside_scale_for_touch = ash::kResizeOutsideBoundsScaleForTouch; |
| 484 resize_area_corner_size = ash::kResizeAreaCornerSize; | 482 resize_area_corner_size = ash::kResizeAreaCornerSize; |
| 485 } | 483 } |
| 486 #endif | 484 #endif |
| 487 apps::ShellWindowFrameView* frame_view = new apps::ShellWindowFrameView(this); | 485 apps::AppWindowFrameView* frame_view = new apps::AppWindowFrameView(this); |
| 488 frame_view->Init(window_, | 486 frame_view->Init(window_, |
| 489 resize_inside_bounds_size, | 487 resize_inside_bounds_size, |
| 490 resize_outside_bounds_size, | 488 resize_outside_bounds_size, |
| 491 resize_outside_scale_for_touch, | 489 resize_outside_scale_for_touch, |
| 492 resize_area_corner_size); | 490 resize_area_corner_size); |
| 493 return frame_view; | 491 return frame_view; |
| 494 } | 492 } |
| 495 | 493 |
| 496 // ui::BaseWindow implementation. | 494 // ui::BaseWindow implementation. |
| 497 | 495 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 | 605 |
| 608 void NativeAppWindowViews::SetBounds(const gfx::Rect& bounds) { | 606 void NativeAppWindowViews::SetBounds(const gfx::Rect& bounds) { |
| 609 window_->SetBounds(bounds); | 607 window_->SetBounds(bounds); |
| 610 } | 608 } |
| 611 | 609 |
| 612 void NativeAppWindowViews::FlashFrame(bool flash) { | 610 void NativeAppWindowViews::FlashFrame(bool flash) { |
| 613 window_->FlashFrame(flash); | 611 window_->FlashFrame(flash); |
| 614 } | 612 } |
| 615 | 613 |
| 616 bool NativeAppWindowViews::IsAlwaysOnTop() const { | 614 bool NativeAppWindowViews::IsAlwaysOnTop() const { |
| 617 if (shell_window_->window_type_is_panel()) { | 615 if (app_window_->window_type_is_panel()) { |
| 618 #if defined(USE_ASH) | 616 #if defined(USE_ASH) |
| 619 return ash::wm::GetWindowState(window_->GetNativeWindow())-> | 617 return ash::wm::GetWindowState(window_->GetNativeWindow())-> |
| 620 panel_attached(); | 618 panel_attached(); |
| 621 #else | 619 #else |
| 622 return true; | 620 return true; |
| 623 #endif | 621 #endif |
| 624 } else { | 622 } else { |
| 625 return window_->IsAlwaysOnTop(); | 623 return window_->IsAlwaysOnTop(); |
| 626 } | 624 } |
| 627 } | 625 } |
| 628 | 626 |
| 629 void NativeAppWindowViews::SetAlwaysOnTop(bool always_on_top) { | 627 void NativeAppWindowViews::SetAlwaysOnTop(bool always_on_top) { |
| 630 window_->SetAlwaysOnTop(always_on_top); | 628 window_->SetAlwaysOnTop(always_on_top); |
| 631 } | 629 } |
| 632 | 630 |
| 633 void NativeAppWindowViews::ShowContextMenuForView( | 631 void NativeAppWindowViews::ShowContextMenuForView( |
| 634 views::View* source, | 632 views::View* source, |
| 635 const gfx::Point& p, | 633 const gfx::Point& p, |
| 636 ui::MenuSourceType source_type) { | 634 ui::MenuSourceType source_type) { |
| 637 #if defined(USE_ASH) & defined(OS_CHROMEOS) | 635 #if defined(USE_ASH) & defined(OS_CHROMEOS) |
| 638 scoped_ptr<ui::MenuModel> model = CreateMultiUserContextMenu( | 636 scoped_ptr<ui::MenuModel> model = |
| 639 shell_window_->GetNativeWindow()); | 637 CreateMultiUserContextMenu(app_window_->GetNativeWindow()); |
| 640 if (!model.get()) | 638 if (!model.get()) |
| 641 return; | 639 return; |
| 642 | 640 |
| 643 // Only show context menu if point is in caption. | 641 // Only show context menu if point is in caption. |
| 644 gfx::Point point_in_view_coords(p); | 642 gfx::Point point_in_view_coords(p); |
| 645 views::View::ConvertPointFromScreen(window_->non_client_view(), | 643 views::View::ConvertPointFromScreen(window_->non_client_view(), |
| 646 &point_in_view_coords); | 644 &point_in_view_coords); |
| 647 int hit_test = window_->non_client_view()->NonClientHitTest( | 645 int hit_test = window_->non_client_view()->NonClientHitTest( |
| 648 point_in_view_coords); | 646 point_in_view_coords); |
| 649 if (hit_test == HTCAPTION) { | 647 if (hit_test == HTCAPTION) { |
| 650 menu_runner_.reset(new views::MenuRunner(model.get())); | 648 menu_runner_.reset(new views::MenuRunner(model.get())); |
| 651 if (menu_runner_->RunMenuAt(source->GetWidget(), NULL, | 649 if (menu_runner_->RunMenuAt(source->GetWidget(), NULL, |
| 652 gfx::Rect(p, gfx::Size(0,0)), views::MenuItemView::TOPLEFT, | 650 gfx::Rect(p, gfx::Size(0,0)), views::MenuItemView::TOPLEFT, |
| 653 source_type, | 651 source_type, |
| 654 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == | 652 views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU) == |
| 655 views::MenuRunner::MENU_DELETED) | 653 views::MenuRunner::MENU_DELETED) |
| 656 return; | 654 return; |
| 657 } | 655 } |
| 658 #endif | 656 #endif |
| 659 } | 657 } |
| 660 | 658 |
| 661 gfx::NativeView NativeAppWindowViews::GetHostView() const { | 659 gfx::NativeView NativeAppWindowViews::GetHostView() const { |
| 662 return window_->GetNativeView(); | 660 return window_->GetNativeView(); |
| 663 } | 661 } |
| 664 | 662 |
| 665 gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) { | 663 gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) { |
| 666 gfx::Size shell_window_size = window_->GetWindowBoundsInScreen().size(); | 664 gfx::Size app_window_size = window_->GetWindowBoundsInScreen().size(); |
| 667 return gfx::Point(shell_window_size.width() / 2 - size.width() / 2, | 665 return gfx::Point(app_window_size.width() / 2 - size.width() / 2, |
| 668 shell_window_size.height() / 2 - size.height() / 2); | 666 app_window_size.height() / 2 - size.height() / 2); |
| 669 } | 667 } |
| 670 | 668 |
| 671 gfx::Size NativeAppWindowViews::GetMaximumDialogSize() { | 669 gfx::Size NativeAppWindowViews::GetMaximumDialogSize() { |
| 672 return window_->GetWindowBoundsInScreen().size(); | 670 return window_->GetWindowBoundsInScreen().size(); |
| 673 } | 671 } |
| 674 | 672 |
| 675 void NativeAppWindowViews::AddObserver( | 673 void NativeAppWindowViews::AddObserver( |
| 676 web_modal::ModalDialogHostObserver* observer) { | 674 web_modal::ModalDialogHostObserver* observer) { |
| 677 observer_list_.AddObserver(observer); | 675 observer_list_.AddObserver(observer); |
| 678 } | 676 } |
| 679 void NativeAppWindowViews::RemoveObserver( | 677 void NativeAppWindowViews::RemoveObserver( |
| 680 web_modal::ModalDialogHostObserver* observer) { | 678 web_modal::ModalDialogHostObserver* observer) { |
| 681 observer_list_.RemoveObserver(observer); | 679 observer_list_.RemoveObserver(observer); |
| 682 } | 680 } |
| 683 | 681 |
| 684 // Private method. TODO(stevenjb): Move this below InitializePanelWindow() | 682 // Private method. TODO(stevenjb): Move this below InitializePanelWindow() |
| 685 // to match declaration order. | 683 // to match declaration order. |
| 686 void NativeAppWindowViews::OnViewWasResized() { | 684 void NativeAppWindowViews::OnViewWasResized() { |
| 687 FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver, | 685 FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver, |
| 688 observer_list_, | 686 observer_list_, |
| 689 OnPositionRequiresUpdate()); | 687 OnPositionRequiresUpdate()); |
| 690 } | 688 } |
| 691 | 689 |
| 692 // WidgetDelegate implementation. | 690 // WidgetDelegate implementation. |
| 693 | 691 |
| 694 void NativeAppWindowViews::OnWidgetMove() { | 692 void NativeAppWindowViews::OnWidgetMove() { |
| 695 shell_window_->OnNativeWindowChanged(); | 693 app_window_->OnNativeWindowChanged(); |
| 696 } | 694 } |
| 697 | 695 |
| 698 views::View* NativeAppWindowViews::GetInitiallyFocusedView() { | 696 views::View* NativeAppWindowViews::GetInitiallyFocusedView() { |
| 699 return web_view_; | 697 return web_view_; |
| 700 } | 698 } |
| 701 | 699 |
| 702 bool NativeAppWindowViews::CanResize() const { | 700 bool NativeAppWindowViews::CanResize() const { |
| 703 return resizable_ && !shell_window_->size_constraints().HasFixedSize(); | 701 return resizable_ && !app_window_->size_constraints().HasFixedSize(); |
| 704 } | 702 } |
| 705 | 703 |
| 706 bool NativeAppWindowViews::CanMaximize() const { | 704 bool NativeAppWindowViews::CanMaximize() const { |
| 707 return resizable_ && !shell_window_->size_constraints().HasMaximumSize() && | 705 return resizable_ && !app_window_->size_constraints().HasMaximumSize() && |
| 708 !shell_window_->window_type_is_panel(); | 706 !app_window_->window_type_is_panel(); |
| 709 } | 707 } |
| 710 | 708 |
| 711 base::string16 NativeAppWindowViews::GetWindowTitle() const { | 709 base::string16 NativeAppWindowViews::GetWindowTitle() const { |
| 712 return shell_window_->GetTitle(); | 710 return app_window_->GetTitle(); |
| 713 } | 711 } |
| 714 | 712 |
| 715 bool NativeAppWindowViews::ShouldShowWindowTitle() const { | 713 bool NativeAppWindowViews::ShouldShowWindowTitle() const { |
| 716 return shell_window_->window_type() == ShellWindow::WINDOW_TYPE_V1_PANEL; | 714 return app_window_->window_type() == AppWindow::WINDOW_TYPE_V1_PANEL; |
| 717 } | 715 } |
| 718 | 716 |
| 719 gfx::ImageSkia NativeAppWindowViews::GetWindowAppIcon() { | 717 gfx::ImageSkia NativeAppWindowViews::GetWindowAppIcon() { |
| 720 gfx::Image app_icon = shell_window_->app_icon(); | 718 gfx::Image app_icon = app_window_->app_icon(); |
| 721 if (app_icon.IsEmpty()) | 719 if (app_icon.IsEmpty()) |
| 722 return GetWindowIcon(); | 720 return GetWindowIcon(); |
| 723 else | 721 else |
| 724 return *app_icon.ToImageSkia(); | 722 return *app_icon.ToImageSkia(); |
| 725 } | 723 } |
| 726 | 724 |
| 727 gfx::ImageSkia NativeAppWindowViews::GetWindowIcon() { | 725 gfx::ImageSkia NativeAppWindowViews::GetWindowIcon() { |
| 728 content::WebContents* web_contents = shell_window_->web_contents(); | 726 content::WebContents* web_contents = app_window_->web_contents(); |
| 729 if (web_contents) { | 727 if (web_contents) { |
| 730 FaviconTabHelper* favicon_tab_helper = | 728 FaviconTabHelper* favicon_tab_helper = |
| 731 FaviconTabHelper::FromWebContents(web_contents); | 729 FaviconTabHelper::FromWebContents(web_contents); |
| 732 gfx::Image app_icon = favicon_tab_helper->GetFavicon(); | 730 gfx::Image app_icon = favicon_tab_helper->GetFavicon(); |
| 733 if (!app_icon.IsEmpty()) | 731 if (!app_icon.IsEmpty()) |
| 734 return *app_icon.ToImageSkia(); | 732 return *app_icon.ToImageSkia(); |
| 735 } | 733 } |
| 736 return gfx::ImageSkia(); | 734 return gfx::ImageSkia(); |
| 737 } | 735 } |
| 738 | 736 |
| 739 bool NativeAppWindowViews::ShouldShowWindowIcon() const { | 737 bool NativeAppWindowViews::ShouldShowWindowIcon() const { |
| 740 return shell_window_->window_type() == ShellWindow::WINDOW_TYPE_V1_PANEL; | 738 return app_window_->window_type() == AppWindow::WINDOW_TYPE_V1_PANEL; |
| 741 } | 739 } |
| 742 | 740 |
| 743 void NativeAppWindowViews::SaveWindowPlacement(const gfx::Rect& bounds, | 741 void NativeAppWindowViews::SaveWindowPlacement(const gfx::Rect& bounds, |
| 744 ui::WindowShowState show_state) { | 742 ui::WindowShowState show_state) { |
| 745 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); | 743 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); |
| 746 shell_window_->OnNativeWindowChanged(); | 744 app_window_->OnNativeWindowChanged(); |
| 747 } | 745 } |
| 748 | 746 |
| 749 void NativeAppWindowViews::DeleteDelegate() { | 747 void NativeAppWindowViews::DeleteDelegate() { |
| 750 window_->RemoveObserver(this); | 748 window_->RemoveObserver(this); |
| 751 shell_window_->OnNativeClose(); | 749 app_window_->OnNativeClose(); |
| 752 } | 750 } |
| 753 | 751 |
| 754 views::Widget* NativeAppWindowViews::GetWidget() { | 752 views::Widget* NativeAppWindowViews::GetWidget() { |
| 755 return window_; | 753 return window_; |
| 756 } | 754 } |
| 757 | 755 |
| 758 const views::Widget* NativeAppWindowViews::GetWidget() const { | 756 const views::Widget* NativeAppWindowViews::GetWidget() const { |
| 759 return window_; | 757 return window_; |
| 760 } | 758 } |
| 761 | 759 |
| 762 views::View* NativeAppWindowViews::GetContentsView() { | 760 views::View* NativeAppWindowViews::GetContentsView() { |
| 763 return this; | 761 return this; |
| 764 } | 762 } |
| 765 | 763 |
| 766 views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView( | 764 views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView( |
| 767 views::Widget* widget) { | 765 views::Widget* widget) { |
| 768 #if defined(USE_ASH) | 766 #if defined(USE_ASH) |
| 769 if (chrome::IsNativeViewInAsh(widget->GetNativeView())) { | 767 if (chrome::IsNativeViewInAsh(widget->GetNativeView())) { |
| 770 // Set the delegate now because CustomFrameViewAsh sets the | 768 // Set the delegate now because CustomFrameViewAsh sets the |
| 771 // WindowStateDelegate if one is not already set. | 769 // WindowStateDelegate if one is not already set. |
| 772 ash::wm::GetWindowState(GetNativeWindow())->SetDelegate( | 770 ash::wm::GetWindowState(GetNativeWindow())->SetDelegate( |
| 773 scoped_ptr<ash::wm::WindowStateDelegate>( | 771 scoped_ptr<ash::wm::WindowStateDelegate>( |
| 774 new NativeAppWindowStateDelegate(shell_window_, this)).Pass()); | 772 new NativeAppWindowStateDelegate(app_window_, this)).Pass()); |
| 775 | 773 |
| 776 if (shell_window_->window_type_is_panel()) { | 774 if (app_window_->window_type_is_panel()) { |
| 777 ash::PanelFrameView::FrameType frame_type = frameless_ ? | 775 ash::PanelFrameView::FrameType frame_type = frameless_ ? |
| 778 ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH; | 776 ash::PanelFrameView::FRAME_NONE : ash::PanelFrameView::FRAME_ASH; |
| 779 views::NonClientFrameView* frame_view = | 777 views::NonClientFrameView* frame_view = |
| 780 new ash::PanelFrameView(widget, frame_type); | 778 new ash::PanelFrameView(widget, frame_type); |
| 781 frame_view->set_context_menu_controller(this); | 779 frame_view->set_context_menu_controller(this); |
| 782 return frame_view; | 780 return frame_view; |
| 783 } | 781 } |
| 784 | 782 |
| 785 if (!frameless_) { | 783 if (!frameless_) { |
| 786 ash::CustomFrameViewAsh* custom_frame_view = | 784 ash::CustomFrameViewAsh* custom_frame_view = |
| 787 new ash::CustomFrameViewAsh(widget); | 785 new ash::CustomFrameViewAsh(widget); |
| 788 #if defined(OS_CHROMEOS) | 786 #if defined(OS_CHROMEOS) |
| 789 // Non-frameless app windows can be put into immersive fullscreen. | 787 // Non-frameless app windows can be put into immersive fullscreen. |
| 790 // TODO(pkotwicz): Investigate if immersive fullscreen can be enabled for | 788 // TODO(pkotwicz): Investigate if immersive fullscreen can be enabled for |
| 791 // Windows Ash. | 789 // Windows Ash. |
| 792 if (ash::switches::UseImmersiveFullscreenForAllWindows()) { | 790 if (ash::switches::UseImmersiveFullscreenForAllWindows()) { |
| 793 immersive_fullscreen_controller_.reset( | 791 immersive_fullscreen_controller_.reset( |
| 794 new ash::ImmersiveFullscreenController()); | 792 new ash::ImmersiveFullscreenController()); |
| 795 custom_frame_view->InitImmersiveFullscreenControllerForView( | 793 custom_frame_view->InitImmersiveFullscreenControllerForView( |
| 796 immersive_fullscreen_controller_.get()); | 794 immersive_fullscreen_controller_.get()); |
| 797 } | 795 } |
| 798 #endif | 796 #endif |
| 799 custom_frame_view->GetHeaderView()->set_context_menu_controller(this); | 797 custom_frame_view->GetHeaderView()->set_context_menu_controller(this); |
| 800 return custom_frame_view; | 798 return custom_frame_view; |
| 801 } | 799 } |
| 802 } | 800 } |
| 803 #endif | 801 #endif |
| 804 if (ShouldUseChromeStyleFrame()) | 802 if (ShouldUseChromeStyleFrame()) |
| 805 return CreateShellWindowFrameView(); | 803 return CreateAppWindowFrameView(); |
| 806 return views::WidgetDelegateView::CreateNonClientFrameView(widget); | 804 return views::WidgetDelegateView::CreateNonClientFrameView(widget); |
| 807 } | 805 } |
| 808 | 806 |
| 809 bool NativeAppWindowViews::WidgetHasHitTestMask() const { | 807 bool NativeAppWindowViews::WidgetHasHitTestMask() const { |
| 810 return shape_ != NULL; | 808 return shape_ != NULL; |
| 811 } | 809 } |
| 812 | 810 |
| 813 void NativeAppWindowViews::GetWidgetHitTestMask(gfx::Path* mask) const { | 811 void NativeAppWindowViews::GetWidgetHitTestMask(gfx::Path* mask) const { |
| 814 shape_->getBoundaryPath(mask); | 812 shape_->getBoundaryPath(mask); |
| 815 } | 813 } |
| 816 | 814 |
| 817 bool NativeAppWindowViews::ShouldDescendIntoChildForEventHandling( | 815 bool NativeAppWindowViews::ShouldDescendIntoChildForEventHandling( |
| 818 gfx::NativeView child, | 816 gfx::NativeView child, |
| 819 const gfx::Point& location) { | 817 const gfx::Point& location) { |
| 820 #if defined(USE_AURA) | 818 #if defined(USE_AURA) |
| 821 if (child->Contains(web_view_->web_contents()->GetView()->GetNativeView())) { | 819 if (child->Contains(web_view_->web_contents()->GetView()->GetNativeView())) { |
| 822 // Shell window should claim mouse events that fall within the draggable | 820 // App window should claim mouse events that fall within the draggable |
| 823 // region. | 821 // region. |
| 824 return !draggable_region_.get() || | 822 return !draggable_region_.get() || |
| 825 !draggable_region_->contains(location.x(), location.y()); | 823 !draggable_region_->contains(location.x(), location.y()); |
| 826 } | 824 } |
| 827 #endif | 825 #endif |
| 828 | 826 |
| 829 return true; | 827 return true; |
| 830 } | 828 } |
| 831 | 829 |
| 832 // WidgetObserver implementation. | 830 // WidgetObserver implementation. |
| 833 | 831 |
| 834 void NativeAppWindowViews::OnWidgetVisibilityChanged(views::Widget* widget, | 832 void NativeAppWindowViews::OnWidgetVisibilityChanged(views::Widget* widget, |
| 835 bool visible) { | 833 bool visible) { |
| 836 shell_window_->OnNativeWindowChanged(); | 834 app_window_->OnNativeWindowChanged(); |
| 837 } | 835 } |
| 838 | 836 |
| 839 void NativeAppWindowViews::OnWidgetActivationChanged(views::Widget* widget, | 837 void NativeAppWindowViews::OnWidgetActivationChanged(views::Widget* widget, |
| 840 bool active) { | 838 bool active) { |
| 841 shell_window_->OnNativeWindowChanged(); | 839 app_window_->OnNativeWindowChanged(); |
| 842 if (active) | 840 if (active) |
| 843 shell_window_->OnNativeWindowActivated(); | 841 app_window_->OnNativeWindowActivated(); |
| 844 } | 842 } |
| 845 | 843 |
| 846 // WebContentsObserver implementation. | 844 // WebContentsObserver implementation. |
| 847 | 845 |
| 848 void NativeAppWindowViews::RenderViewCreated( | 846 void NativeAppWindowViews::RenderViewCreated( |
| 849 content::RenderViewHost* render_view_host) { | 847 content::RenderViewHost* render_view_host) { |
| 850 if (transparent_background_) { | 848 if (transparent_background_) { |
| 851 // Use a background with transparency to trigger transparency in Webkit. | 849 // Use a background with transparency to trigger transparency in Webkit. |
| 852 SkBitmap background; | 850 SkBitmap background; |
| 853 background.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); | 851 background.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 883 } | 881 } |
| 884 } | 882 } |
| 885 | 883 |
| 886 gfx::Size NativeAppWindowViews::GetPreferredSize() { | 884 gfx::Size NativeAppWindowViews::GetPreferredSize() { |
| 887 if (!preferred_size_.IsEmpty()) | 885 if (!preferred_size_.IsEmpty()) |
| 888 return preferred_size_; | 886 return preferred_size_; |
| 889 return views::View::GetPreferredSize(); | 887 return views::View::GetPreferredSize(); |
| 890 } | 888 } |
| 891 | 889 |
| 892 gfx::Size NativeAppWindowViews::GetMinimumSize() { | 890 gfx::Size NativeAppWindowViews::GetMinimumSize() { |
| 893 return shell_window_->size_constraints().GetMinimumSize(); | 891 return app_window_->size_constraints().GetMinimumSize(); |
| 894 } | 892 } |
| 895 | 893 |
| 896 gfx::Size NativeAppWindowViews::GetMaximumSize() { | 894 gfx::Size NativeAppWindowViews::GetMaximumSize() { |
| 897 return shell_window_->size_constraints().GetMaximumSize(); | 895 return app_window_->size_constraints().GetMaximumSize(); |
| 898 } | 896 } |
| 899 | 897 |
| 900 void NativeAppWindowViews::OnFocus() { | 898 void NativeAppWindowViews::OnFocus() { |
| 901 web_view_->RequestFocus(); | 899 web_view_->RequestFocus(); |
| 902 } | 900 } |
| 903 | 901 |
| 904 bool NativeAppWindowViews::AcceleratorPressed( | 902 bool NativeAppWindowViews::AcceleratorPressed( |
| 905 const ui::Accelerator& accelerator) { | 903 const ui::Accelerator& accelerator) { |
| 906 const std::map<ui::Accelerator, int>& accelerator_table = | 904 const std::map<ui::Accelerator, int>& accelerator_table = |
| 907 GetAcceleratorTable(); | 905 GetAcceleratorTable(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 928 default: | 926 default: |
| 929 NOTREACHED() << "Unknown accelerator sent to app window."; | 927 NOTREACHED() << "Unknown accelerator sent to app window."; |
| 930 } | 928 } |
| 931 return false; | 929 return false; |
| 932 } | 930 } |
| 933 | 931 |
| 934 // NativeAppWindow implementation. | 932 // NativeAppWindow implementation. |
| 935 | 933 |
| 936 void NativeAppWindowViews::SetFullscreen(int fullscreen_types) { | 934 void NativeAppWindowViews::SetFullscreen(int fullscreen_types) { |
| 937 // Fullscreen not supported by panels. | 935 // Fullscreen not supported by panels. |
| 938 if (shell_window_->window_type_is_panel()) | 936 if (app_window_->window_type_is_panel()) |
| 939 return; | 937 return; |
| 940 is_fullscreen_ = (fullscreen_types != ShellWindow::FULLSCREEN_TYPE_NONE); | 938 is_fullscreen_ = (fullscreen_types != AppWindow::FULLSCREEN_TYPE_NONE); |
| 941 window_->SetFullscreen(is_fullscreen_); | 939 window_->SetFullscreen(is_fullscreen_); |
| 942 | 940 |
| 943 #if defined(USE_ASH) | 941 #if defined(USE_ASH) |
| 944 if (immersive_fullscreen_controller_.get()) { | 942 if (immersive_fullscreen_controller_.get()) { |
| 945 // |immersive_fullscreen_controller_| should only be set if immersive | 943 // |immersive_fullscreen_controller_| should only be set if immersive |
| 946 // fullscreen is the fullscreen type used by the OS. | 944 // fullscreen is the fullscreen type used by the OS. |
| 947 immersive_fullscreen_controller_->SetEnabled( | 945 immersive_fullscreen_controller_->SetEnabled( |
| 948 ash::ImmersiveFullscreenController::WINDOW_TYPE_PACKAGED_APP, | 946 ash::ImmersiveFullscreenController::WINDOW_TYPE_PACKAGED_APP, |
| 949 (fullscreen_types & ShellWindow::FULLSCREEN_TYPE_OS) != 0); | 947 (fullscreen_types & AppWindow::FULLSCREEN_TYPE_OS) != 0); |
| 950 // Autohide the shelf instead of hiding the shelf completely when only in | 948 // Autohide the shelf instead of hiding the shelf completely when only in |
| 951 // OS fullscreen. | 949 // OS fullscreen. |
| 952 ash::wm::WindowState* window_state = | 950 ash::wm::WindowState* window_state = |
| 953 ash::wm::GetWindowState(window_->GetNativeWindow()); | 951 ash::wm::GetWindowState(window_->GetNativeWindow()); |
| 954 window_state->set_hide_shelf_when_fullscreen( | 952 window_state->set_hide_shelf_when_fullscreen(fullscreen_types != |
| 955 fullscreen_types != ShellWindow::FULLSCREEN_TYPE_OS); | 953 AppWindow::FULLSCREEN_TYPE_OS); |
| 956 DCHECK(ash::Shell::HasInstance()); | 954 DCHECK(ash::Shell::HasInstance()); |
| 957 ash::Shell::GetInstance()->UpdateShelfVisibility(); | 955 ash::Shell::GetInstance()->UpdateShelfVisibility(); |
| 958 } | 956 } |
| 959 #endif | 957 #endif |
| 960 | 958 |
| 961 // TODO(jeremya) we need to call RenderViewHost::ExitFullscreen() if we | 959 // TODO(jeremya) we need to call RenderViewHost::ExitFullscreen() if we |
| 962 // ever drop the window out of fullscreen in response to something that | 960 // ever drop the window out of fullscreen in response to something that |
| 963 // wasn't the app calling webkitCancelFullScreen(). | 961 // wasn't the app calling webkitCancelFullScreen(). |
| 964 } | 962 } |
| 965 | 963 |
| 966 bool NativeAppWindowViews::IsFullscreenOrPending() const { | 964 bool NativeAppWindowViews::IsFullscreenOrPending() const { |
| 967 return is_fullscreen_; | 965 return is_fullscreen_; |
| 968 } | 966 } |
| 969 | 967 |
| 970 bool NativeAppWindowViews::IsDetached() const { | 968 bool NativeAppWindowViews::IsDetached() const { |
| 971 if (!shell_window_->window_type_is_panel()) | 969 if (!app_window_->window_type_is_panel()) |
| 972 return false; | 970 return false; |
| 973 #if defined(USE_ASH) | 971 #if defined(USE_ASH) |
| 974 return !ash::wm::GetWindowState(window_->GetNativeWindow())->panel_attached(); | 972 return !ash::wm::GetWindowState(window_->GetNativeWindow())->panel_attached(); |
| 975 #else | 973 #else |
| 976 return false; | 974 return false; |
| 977 #endif | 975 #endif |
| 978 } | 976 } |
| 979 | 977 |
| 980 void NativeAppWindowViews::UpdateWindowIcon() { | 978 void NativeAppWindowViews::UpdateWindowIcon() { |
| 981 window_->UpdateWindowIcon(); | 979 window_->UpdateWindowIcon(); |
| 982 } | 980 } |
| 983 | 981 |
| 984 void NativeAppWindowViews::UpdateWindowTitle() { | 982 void NativeAppWindowViews::UpdateWindowTitle() { |
| 985 window_->UpdateWindowTitle(); | 983 window_->UpdateWindowTitle(); |
| 986 } | 984 } |
| 987 | 985 |
| 988 void NativeAppWindowViews::UpdateBadgeIcon() { | 986 void NativeAppWindowViews::UpdateBadgeIcon() { |
| 989 const gfx::Image* icon = NULL; | 987 const gfx::Image* icon = NULL; |
| 990 if (!shell_window_->badge_icon().IsEmpty()) { | 988 if (!app_window_->badge_icon().IsEmpty()) { |
| 991 icon = &shell_window_->badge_icon(); | 989 icon = &app_window_->badge_icon(); |
| 992 // chrome::DrawTaskbarDecoration can do interesting things with non-square | 990 // chrome::DrawTaskbarDecoration can do interesting things with non-square |
| 993 // bitmaps. | 991 // bitmaps. |
| 994 // TODO(benwells): Refactor chrome::DrawTaskbarDecoration to not be avatar | 992 // TODO(benwells): Refactor chrome::DrawTaskbarDecoration to not be avatar |
| 995 // specific, and lift this restriction. | 993 // specific, and lift this restriction. |
| 996 if (icon->Width() != icon->Height()) { | 994 if (icon->Width() != icon->Height()) { |
| 997 LOG(ERROR) << "Attempt to set a non-square badge; request ignored."; | 995 LOG(ERROR) << "Attempt to set a non-square badge; request ignored."; |
| 998 return; | 996 return; |
| 999 } | 997 } |
| 1000 } | 998 } |
| 1001 chrome::DrawTaskbarDecoration(GetNativeWindow(), icon); | 999 chrome::DrawTaskbarDecoration(GetNativeWindow(), icon); |
| 1002 } | 1000 } |
| 1003 | 1001 |
| 1004 void NativeAppWindowViews::UpdateDraggableRegions( | 1002 void NativeAppWindowViews::UpdateDraggableRegions( |
| 1005 const std::vector<extensions::DraggableRegion>& regions) { | 1003 const std::vector<extensions::DraggableRegion>& regions) { |
| 1006 // Draggable region is not supported for non-frameless window. | 1004 // Draggable region is not supported for non-frameless window. |
| 1007 if (!frameless_) | 1005 if (!frameless_) |
| 1008 return; | 1006 return; |
| 1009 | 1007 |
| 1010 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); | 1008 draggable_region_.reset(AppWindow::RawDraggableRegionsToSkRegion(regions)); |
| 1011 OnViewWasResized(); | 1009 OnViewWasResized(); |
| 1012 } | 1010 } |
| 1013 | 1011 |
| 1014 SkRegion* NativeAppWindowViews::GetDraggableRegion() { | 1012 SkRegion* NativeAppWindowViews::GetDraggableRegion() { |
| 1015 return draggable_region_.get(); | 1013 return draggable_region_.get(); |
| 1016 } | 1014 } |
| 1017 | 1015 |
| 1018 void NativeAppWindowViews::UpdateShape(scoped_ptr<SkRegion> region) { | 1016 void NativeAppWindowViews::UpdateShape(scoped_ptr<SkRegion> region) { |
| 1019 bool had_shape = shape_; | 1017 bool had_shape = shape_; |
| 1020 shape_ = region.Pass(); | 1018 shape_ = region.Pass(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 gfx::Rect client_bounds = gfx::Rect(1000, 1000); | 1053 gfx::Rect client_bounds = gfx::Rect(1000, 1000); |
| 1056 gfx::Rect window_bounds = | 1054 gfx::Rect window_bounds = |
| 1057 window_->non_client_view()->GetWindowBoundsForClientBounds( | 1055 window_->non_client_view()->GetWindowBoundsForClientBounds( |
| 1058 client_bounds); | 1056 client_bounds); |
| 1059 return window_bounds.InsetsFrom(client_bounds); | 1057 return window_bounds.InsetsFrom(client_bounds); |
| 1060 } | 1058 } |
| 1061 | 1059 |
| 1062 void NativeAppWindowViews::HideWithApp() {} | 1060 void NativeAppWindowViews::HideWithApp() {} |
| 1063 void NativeAppWindowViews::ShowWithApp() {} | 1061 void NativeAppWindowViews::ShowWithApp() {} |
| 1064 void NativeAppWindowViews::UpdateWindowMinMaxSize() {} | 1062 void NativeAppWindowViews::UpdateWindowMinMaxSize() {} |
| OLD | NEW |