| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/native_app_window_views.h" | 5 #include "chrome/browser/ui/views/extensions/native_app_window_views.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 return window_->GetNativeView(); | 410 return window_->GetNativeView(); |
| 411 } | 411 } |
| 412 | 412 |
| 413 gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) { | 413 gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) { |
| 414 gfx::Size shell_window_size = window_->GetWindowBoundsInScreen().size(); | 414 gfx::Size shell_window_size = window_->GetWindowBoundsInScreen().size(); |
| 415 return gfx::Point(shell_window_size.width() / 2 - size.width() / 2, | 415 return gfx::Point(shell_window_size.width() / 2 - size.width() / 2, |
| 416 shell_window_size.height() / 2 - size.height() / 2); | 416 shell_window_size.height() / 2 - size.height() / 2); |
| 417 } | 417 } |
| 418 | 418 |
| 419 void NativeAppWindowViews::AddObserver( | 419 void NativeAppWindowViews::AddObserver( |
| 420 WebContentsModalDialogHostObserver* observer) { | 420 web_modal::WebContentsModalDialogHostObserver* observer) { |
| 421 observer_list_.AddObserver(observer); | 421 observer_list_.AddObserver(observer); |
| 422 } | 422 } |
| 423 void NativeAppWindowViews::RemoveObserver( | 423 void NativeAppWindowViews::RemoveObserver( |
| 424 WebContentsModalDialogHostObserver* observer) { | 424 web_modal::WebContentsModalDialogHostObserver* observer) { |
| 425 observer_list_.RemoveObserver(observer); | 425 observer_list_.RemoveObserver(observer); |
| 426 } | 426 } |
| 427 | 427 |
| 428 // Private method. TODO(stevenjb): Move this below InitializePanelWindow() | 428 // Private method. TODO(stevenjb): Move this below InitializePanelWindow() |
| 429 // to match declaration order. | 429 // to match declaration order. |
| 430 void NativeAppWindowViews::OnViewWasResized() { | 430 void NativeAppWindowViews::OnViewWasResized() { |
| 431 // TODO(jeremya): this doesn't seem like a terribly elegant way to keep the | 431 // TODO(jeremya): this doesn't seem like a terribly elegant way to keep the |
| 432 // window shape in sync. | 432 // window shape in sync. |
| 433 #if defined(OS_WIN) && !defined(USE_AURA) | 433 #if defined(OS_WIN) && !defined(USE_AURA) |
| 434 DCHECK(window_); | 434 DCHECK(window_); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 rgn->op(width - kResizeInsideBoundsSize, 0, width, height, | 474 rgn->op(width - kResizeInsideBoundsSize, 0, width, height, |
| 475 SkRegion::kUnion_Op); | 475 SkRegion::kUnion_Op); |
| 476 rgn->op(0, height - kResizeInsideBoundsSize, width, height, | 476 rgn->op(0, height - kResizeInsideBoundsSize, width, height, |
| 477 SkRegion::kUnion_Op); | 477 SkRegion::kUnion_Op); |
| 478 } | 478 } |
| 479 } | 479 } |
| 480 if (web_contents()->GetRenderViewHost()->GetView()) | 480 if (web_contents()->GetRenderViewHost()->GetView()) |
| 481 web_contents()->GetRenderViewHost()->GetView()->SetClickthroughRegion(rgn); | 481 web_contents()->GetRenderViewHost()->GetView()->SetClickthroughRegion(rgn); |
| 482 #endif | 482 #endif |
| 483 | 483 |
| 484 FOR_EACH_OBSERVER(WebContentsModalDialogHostObserver, | 484 FOR_EACH_OBSERVER(web_modal::WebContentsModalDialogHostObserver, |
| 485 observer_list_, | 485 observer_list_, |
| 486 OnPositionRequiresUpdate()); | 486 OnPositionRequiresUpdate()); |
| 487 } | 487 } |
| 488 | 488 |
| 489 bool NativeAppWindowViews::ShouldUseChromeStyleFrame() const { | 489 bool NativeAppWindowViews::ShouldUseChromeStyleFrame() const { |
| 490 return !CommandLine::ForCurrentProcess()->HasSwitch( | 490 return !CommandLine::ForCurrentProcess()->HasSwitch( |
| 491 switches::kAppsUseNativeFrame) || frameless_; | 491 switches::kAppsUseNativeFrame) || frameless_; |
| 492 } | 492 } |
| 493 | 493 |
| 494 // WidgetDelegate implementation. | 494 // WidgetDelegate implementation. |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 } | 742 } |
| 743 | 743 |
| 744 //------------------------------------------------------------------------------ | 744 //------------------------------------------------------------------------------ |
| 745 // NativeAppWindow::Create | 745 // NativeAppWindow::Create |
| 746 | 746 |
| 747 // static | 747 // static |
| 748 NativeAppWindow* NativeAppWindow::Create( | 748 NativeAppWindow* NativeAppWindow::Create( |
| 749 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { | 749 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { |
| 750 return new NativeAppWindowViews(shell_window, params); | 750 return new NativeAppWindowViews(shell_window, params); |
| 751 } | 751 } |
| OLD | NEW |