This source file includes following definitions.
- appearance_delay_ms_
- SetSnapType
- GetBubbleWindow
- DelayCreation
- OnButtonClicked
- OnButtonHover
- GetButtonForUnitTest
- RequestDestructionThroughOwner
- CreateBubble
#include "ash/frame/caption_buttons/maximize_bubble_controller.h"
#include "ash/frame/caption_buttons/frame_maximize_button.h"
#include "ash/frame/caption_buttons/maximize_bubble_controller_bubble.h"
#include "base/timer/timer.h"
namespace ash {
MaximizeBubbleController::MaximizeBubbleController(
FrameMaximizeButton* frame_maximize_button,
MaximizeBubbleFrameState maximize_type,
int appearance_delay_ms)
: frame_maximize_button_(frame_maximize_button),
bubble_(NULL),
maximize_type_(maximize_type),
snap_type_for_creation_(SNAP_NONE),
appearance_delay_ms_(appearance_delay_ms) {
base::OneShotTimer<MaximizeBubbleController>* new_timer =
new base::OneShotTimer<MaximizeBubbleController>();
new_timer->Start(
FROM_HERE,
base::TimeDelta::FromMilliseconds(
appearance_delay_ms_ ? appearance_delay_ms_ : 10),
this,
&MaximizeBubbleController::CreateBubble);
timer_.reset(new_timer);
if (!appearance_delay_ms_)
CreateBubble();
}
MaximizeBubbleController::~MaximizeBubbleController() {
timer_.reset();
if (bubble_) {
bubble_->ControllerRequestsCloseAndDelete();
bubble_ = NULL;
}
}
void MaximizeBubbleController::SetSnapType(SnapType snap_type) {
if (bubble_) {
bubble_->SetSnapType(snap_type);
} else {
snap_type_for_creation_ = snap_type;
}
}
aura::Window* MaximizeBubbleController::GetBubbleWindow() {
return bubble_ ? bubble_->GetBubbleWindow() : NULL;
}
void MaximizeBubbleController::DelayCreation() {
if (timer_.get() && timer_->IsRunning())
timer_->Reset();
}
void MaximizeBubbleController::OnButtonClicked(SnapType snap_type) {
frame_maximize_button_->ExecuteSnapAndCloseMenu(snap_type);
}
void MaximizeBubbleController::OnButtonHover(SnapType snap_type) {
frame_maximize_button_->SnapButtonHovered(snap_type);
}
views::CustomButton* MaximizeBubbleController::GetButtonForUnitTest(
SnapType state) {
return bubble_ ? bubble_->GetButtonForUnitTest(state) : NULL;
}
void MaximizeBubbleController::RequestDestructionThroughOwner() {
if (timer_) {
timer_.reset(NULL);
frame_maximize_button_->DestroyMaximizeMenu();
}
}
void MaximizeBubbleController::CreateBubble() {
if (!bubble_) {
bubble_ = new MaximizeBubbleControllerBubble(this, appearance_delay_ms_,
snap_type_for_creation_);
frame_maximize_button_->OnMaximizeBubbleShown(bubble_->GetWidget());
}
timer_->Stop();
}
}