| 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/exclusive_access_bubble_views.h" | 5 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 views::LabelButton* deny_button() const { return deny_button_; } | 55 views::LabelButton* deny_button() const { return deny_button_; } |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 views::LabelButton* accept_button_; | 58 views::LabelButton* accept_button_; |
| 59 views::LabelButton* deny_button_; | 59 views::LabelButton* deny_button_; |
| 60 DISALLOW_COPY_AND_ASSIGN(ButtonView); | 60 DISALLOW_COPY_AND_ASSIGN(ButtonView); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 ButtonView::ButtonView(views::ButtonListener* listener, | 63 ButtonView::ButtonView(views::ButtonListener* listener, |
| 64 int between_button_spacing) | 64 int between_button_spacing) |
| 65 : accept_button_(NULL), deny_button_(NULL) { | 65 : accept_button_(nullptr), deny_button_(nullptr) { |
| 66 accept_button_ = new views::LabelButton(listener, base::string16()); | 66 accept_button_ = new views::LabelButton(listener, base::string16()); |
| 67 accept_button_->SetStyle(views::Button::STYLE_BUTTON); | 67 accept_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 68 accept_button_->SetFocusable(false); | 68 accept_button_->SetFocusable(false); |
| 69 AddChildView(accept_button_); | 69 AddChildView(accept_button_); |
| 70 | 70 |
| 71 deny_button_ = new views::LabelButton(listener, base::string16()); | 71 deny_button_ = new views::LabelButton(listener, base::string16()); |
| 72 deny_button_->SetStyle(views::Button::STYLE_BUTTON); | 72 deny_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 73 deny_button_->SetFocusable(false); | 73 deny_button_->SetFocusable(false); |
| 74 AddChildView(deny_button_); | 74 AddChildView(deny_button_); |
| 75 | 75 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessView); | 120 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessView); |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 ExclusiveAccessBubbleViews::ExclusiveAccessView::ExclusiveAccessView( | 123 ExclusiveAccessBubbleViews::ExclusiveAccessView::ExclusiveAccessView( |
| 124 ExclusiveAccessBubbleViews* bubble, | 124 ExclusiveAccessBubbleViews* bubble, |
| 125 const base::string16& accelerator, | 125 const base::string16& accelerator, |
| 126 const GURL& url, | 126 const GURL& url, |
| 127 ExclusiveAccessBubbleType bubble_type) | 127 ExclusiveAccessBubbleType bubble_type) |
| 128 : bubble_(bubble), | 128 : bubble_(bubble), |
| 129 link_(NULL), | 129 link_(nullptr), |
| 130 mouse_lock_exit_instruction_(NULL), | 130 mouse_lock_exit_instruction_(nullptr), |
| 131 message_label_(NULL), | 131 message_label_(nullptr), |
| 132 button_view_(NULL), | 132 button_view_(nullptr), |
| 133 browser_fullscreen_exit_accelerator_(accelerator) { | 133 browser_fullscreen_exit_accelerator_(accelerator) { |
| 134 scoped_ptr<views::BubbleBorder> bubble_border( | 134 scoped_ptr<views::BubbleBorder> bubble_border( |
| 135 new views::BubbleBorder(views::BubbleBorder::NONE, | 135 new views::BubbleBorder(views::BubbleBorder::NONE, |
| 136 views::BubbleBorder::BIG_SHADOW, SK_ColorWHITE)); | 136 views::BubbleBorder::BIG_SHADOW, SK_ColorWHITE)); |
| 137 set_background(new views::BubbleBackground(bubble_border.get())); | 137 set_background(new views::BubbleBackground(bubble_border.get())); |
| 138 SetBorder(bubble_border.Pass()); | 138 SetBorder(bubble_border.Pass()); |
| 139 SetFocusable(false); | 139 SetFocusable(false); |
| 140 | 140 |
| 141 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 141 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 142 const gfx::FontList& medium_font_list = | 142 const gfx::FontList& medium_font_list = |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // ExclusiveAccessBubbleViews -------------------------------------------------- | 256 // ExclusiveAccessBubbleViews -------------------------------------------------- |
| 257 | 257 |
| 258 ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews( | 258 ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews( |
| 259 ExclusiveAccessBubbleViewsContext* context, | 259 ExclusiveAccessBubbleViewsContext* context, |
| 260 const GURL& url, | 260 const GURL& url, |
| 261 ExclusiveAccessBubbleType bubble_type) | 261 ExclusiveAccessBubbleType bubble_type) |
| 262 : ExclusiveAccessBubble(context->GetExclusiveAccessManager(), | 262 : ExclusiveAccessBubble(context->GetExclusiveAccessManager(), |
| 263 url, | 263 url, |
| 264 bubble_type), | 264 bubble_type), |
| 265 bubble_view_context_(context), | 265 bubble_view_context_(context), |
| 266 popup_(NULL), | 266 popup_(nullptr), |
| 267 animation_(new gfx::SlideAnimation(this)), | 267 animation_(new gfx::SlideAnimation(this)), |
| 268 animated_attribute_(ANIMATED_ATTRIBUTE_BOUNDS) { | 268 animated_attribute_(ANIMATED_ATTRIBUTE_BOUNDS) { |
| 269 animation_->Reset(1); | 269 animation_->Reset(1); |
| 270 | 270 |
| 271 // Create the contents view. | 271 // Create the contents view. |
| 272 ui::Accelerator accelerator(ui::VKEY_UNKNOWN, ui::EF_NONE); | 272 ui::Accelerator accelerator(ui::VKEY_UNKNOWN, ui::EF_NONE); |
| 273 bool got_accelerator = | 273 bool got_accelerator = |
| 274 bubble_view_context_->GetBubbleAssociatedWidget()->GetAccelerator( | 274 bubble_view_context_->GetBubbleAssociatedWidget()->GetAccelerator( |
| 275 IDC_FULLSCREEN, &accelerator); | 275 IDC_FULLSCREEN, &accelerator); |
| 276 DCHECK(got_accelerator); | 276 DCHECK(got_accelerator); |
| 277 view_ = new ExclusiveAccessView(this, accelerator.GetShortcutText(), url, | 277 view_ = new ExclusiveAccessView(this, accelerator.GetShortcutText(), url, |
| 278 bubble_type_); | 278 bubble_type_); |
| 279 | 279 |
| 280 // TODO(yzshen): Change to use the new views bubble, BubbleDelegateView. | 280 // TODO(yzshen): Change to use the new views bubble, BubbleDelegateView. |
| 281 // TODO(pkotwicz): When this becomes a views bubble, make sure that this | 281 // TODO(pkotwicz): When this becomes a views bubble, make sure that this |
| 282 // bubble is ignored by ImmersiveModeControllerAsh::BubbleManager. | 282 // bubble is ignored by ImmersiveModeControllerAsh::BubbleManager. |
| 283 // Initialize the popup. | 283 // Initialize the popup. |
| 284 popup_ = new views::Widget; | 284 popup_ = new views::Widget; |
| 285 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 285 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
| 286 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 286 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 287 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 287 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 288 params.parent = | 288 params.parent = |
| 289 bubble_view_context_->GetBubbleAssociatedWidget()->GetNativeView(); | 289 bubble_view_context_->GetBubbleAssociatedWidget()->GetNativeView(); |
| 290 params.bounds = GetPopupRect(false); | 290 params.bounds = GetPopupRect(false); |
| 291 popup_->Init(params); | 291 popup_->Init(params); |
| 292 gfx::Size size = GetPopupRect(true).size(); | 292 gfx::Size size = GetPopupRect(true).size(); |
| 293 popup_->SetContentsView(view_); | 293 popup_->SetContentsView(view_); |
| 294 // We set layout manager to NULL to prevent the widget from sizing its | 294 // We set layout manager to nullptr to prevent the widget from sizing its |
| 295 // contents to the same size as itself. This prevents the widget contents from | 295 // contents to the same size as itself. This prevents the widget contents from |
| 296 // shrinking while we animate the height of the popup to give the impression | 296 // shrinking while we animate the height of the popup to give the impression |
| 297 // that it is sliding off the top of the screen. | 297 // that it is sliding off the top of the screen. |
| 298 popup_->GetRootView()->SetLayoutManager(NULL); | 298 popup_->GetRootView()->SetLayoutManager(nullptr); |
| 299 view_->SetBounds(0, 0, size.width(), size.height()); | 299 view_->SetBounds(0, 0, size.width(), size.height()); |
| 300 popup_->ShowInactive(); // This does not activate the popup. | 300 popup_->ShowInactive(); // This does not activate the popup. |
| 301 | 301 |
| 302 popup_->AddObserver(this); | 302 popup_->AddObserver(this); |
| 303 | 303 |
| 304 registrar_.Add(this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, | 304 registrar_.Add(this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
| 305 content::Source<FullscreenController>( | 305 content::Source<FullscreenController>( |
| 306 bubble_view_context_->GetExclusiveAccessManager() | 306 bubble_view_context_->GetExclusiveAccessManager() |
| 307 ->fullscreen_controller())); | 307 ->fullscreen_controller())); |
| 308 | 308 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 StopWatchingMouse(); | 347 StopWatchingMouse(); |
| 348 | 348 |
| 349 UpdateMouseWatcher(); | 349 UpdateMouseWatcher(); |
| 350 } | 350 } |
| 351 | 351 |
| 352 void ExclusiveAccessBubbleViews::RepositionIfVisible() { | 352 void ExclusiveAccessBubbleViews::RepositionIfVisible() { |
| 353 if (popup_->IsVisible()) | 353 if (popup_->IsVisible()) |
| 354 UpdateBounds(); | 354 UpdateBounds(); |
| 355 } | 355 } |
| 356 | 356 |
| 357 views::View* ExclusiveAccessBubbleViews::GetView() { |
| 358 return view_; |
| 359 } |
| 360 |
| 357 void ExclusiveAccessBubbleViews::UpdateMouseWatcher() { | 361 void ExclusiveAccessBubbleViews::UpdateMouseWatcher() { |
| 358 bool should_watch_mouse = false; | 362 bool should_watch_mouse = false; |
| 359 if (popup_->IsVisible()) | 363 if (popup_->IsVisible()) |
| 360 should_watch_mouse = | 364 should_watch_mouse = |
| 361 !exclusive_access_bubble::ShowButtonsForType(bubble_type_); | 365 !exclusive_access_bubble::ShowButtonsForType(bubble_type_); |
| 362 else | 366 else |
| 363 should_watch_mouse = CanMouseTriggerSlideIn(); | 367 should_watch_mouse = CanMouseTriggerSlideIn(); |
| 364 | 368 |
| 365 if (should_watch_mouse == IsWatchingMouse()) | 369 if (should_watch_mouse == IsWatchingMouse()) |
| 366 return; | 370 return; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 const content::NotificationDetails& details) { | 518 const content::NotificationDetails& details) { |
| 515 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); | 519 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); |
| 516 UpdateForImmersiveState(); | 520 UpdateForImmersiveState(); |
| 517 } | 521 } |
| 518 | 522 |
| 519 void ExclusiveAccessBubbleViews::OnWidgetVisibilityChanged( | 523 void ExclusiveAccessBubbleViews::OnWidgetVisibilityChanged( |
| 520 views::Widget* widget, | 524 views::Widget* widget, |
| 521 bool visible) { | 525 bool visible) { |
| 522 UpdateMouseWatcher(); | 526 UpdateMouseWatcher(); |
| 523 } | 527 } |
| OLD | NEW |