This source file includes following definitions.
- ToggleFullscreen
- browser_view_
- OnWindowDestroying
- OnWindowTargetVisibilityChanged
- AsNativeWidget
- AsNativeWidget
- UsesNativeSystemMenu
- GetMinimizeButtonOffset
- SetWindowAutoManaged
#include "chrome/browser/ui/views/frame/browser_frame_ash.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_state_delegate.h"
#include "ash/wm/window_util.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/views/frame/browser_shutdown.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/views/view.h"
using aura::Window;
namespace {
class BrowserWindowStateDelegate : public ash::wm::WindowStateDelegate {
public:
explicit BrowserWindowStateDelegate(Browser* browser)
: browser_(browser) {
DCHECK(browser_);
}
virtual ~BrowserWindowStateDelegate(){}
virtual bool ToggleFullscreen(ash::wm::WindowState* window_state) OVERRIDE {
DCHECK(window_state->IsFullscreen() || window_state->CanMaximize());
if (!window_state->IsFullscreen() && !window_state->CanMaximize())
return true;
chrome::ToggleFullscreenMode(browser_);
return true;
}
private:
Browser* browser_;
DISALLOW_COPY_AND_ASSIGN(BrowserWindowStateDelegate);
};
}
const char BrowserFrameAsh::kWindowName[] = "BrowserFrameAsh";
BrowserFrameAsh::BrowserFrameAsh(BrowserFrame* browser_frame,
BrowserView* browser_view)
: views::NativeWidgetAura(browser_frame),
browser_view_(browser_view) {
GetNativeWindow()->SetName(kWindowName);
Browser* browser = browser_view->browser();
ash::wm::WindowState* window_state =
ash::wm::GetWindowState(GetNativeWindow());
window_state->SetDelegate(
scoped_ptr<ash::wm::WindowStateDelegate>(
new BrowserWindowStateDelegate(browser)).Pass());
if (!browser->bounds_overridden() && !browser->is_session_restore())
SetWindowAutoManaged();
#if defined(OS_CHROMEOS)
window_state->set_can_consume_system_keys(browser->is_app());
#endif
}
void BrowserFrameAsh::OnWindowDestroying(aura::Window* window) {
DestroyBrowserWebContents(browser_view_->browser());
NativeWidgetAura::OnWindowDestroying(window);
}
void BrowserFrameAsh::OnWindowTargetVisibilityChanged(bool visible) {
if (visible) {
SetWindowAutoManaged();
}
views::NativeWidgetAura::OnWindowTargetVisibilityChanged(visible);
}
views::NativeWidget* BrowserFrameAsh::AsNativeWidget() {
return this;
}
const views::NativeWidget* BrowserFrameAsh::AsNativeWidget() const {
return this;
}
bool BrowserFrameAsh::UsesNativeSystemMenu() const {
return false;
}
int BrowserFrameAsh::GetMinimizeButtonOffset() const {
return 0;
}
BrowserFrameAsh::~BrowserFrameAsh() {
}
void BrowserFrameAsh::SetWindowAutoManaged() {
if (browser_view_->browser()->type() != Browser::TYPE_POPUP ||
browser_view_->browser()->is_app()) {
ash::wm::GetWindowState(GetNativeWindow())->
set_window_position_managed(true);
}
}