Chromium Code Reviews| 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 26 matching lines...) Expand all Loading... | |
| 37 #include "ui/base/l10n/l10n_util_win.h" | 37 #include "ui/base/l10n/l10n_util_win.h" |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 // ExclusiveAccessView --------------------------------------------------------- | 40 // ExclusiveAccessView --------------------------------------------------------- |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 // Space between the site info label and the buttons / link. | 44 // Space between the site info label and the buttons / link. |
| 45 const int kMiddlePaddingPx = 30; | 45 const int kMiddlePaddingPx = 30; |
| 46 | 46 |
| 47 // Gets the opacity of the bubble when not animating. | 47 // Opacity of the background (out of 25). Only used with |
|
msw
2015/10/26 16:53:39
"out of 255"?
Matt Giuca
2015/10/26 23:25:39
Done.
| |
| 48 int GetMaximumOpacity() { | 48 // IsSimplifiedFullscreenUIEnabled. |
| 49 return ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 180 : 255; | 49 const unsigned char kBackgroundOpacity = 180; |
| 50 } | |
| 51 | 50 |
| 52 class ButtonView : public views::View { | 51 class ButtonView : public views::View { |
| 53 public: | 52 public: |
| 54 ButtonView(views::ButtonListener* listener, int between_button_spacing); | 53 ButtonView(views::ButtonListener* listener, int between_button_spacing); |
| 55 ~ButtonView() override; | 54 ~ButtonView() override; |
| 56 | 55 |
| 57 // Returns an empty size when the view is not visible. | 56 // Returns an empty size when the view is not visible. |
| 58 gfx::Size GetPreferredSize() const override; | 57 gfx::Size GetPreferredSize() const override; |
| 59 | 58 |
| 60 views::LabelButton* accept_button() const { return accept_button_; } | 59 views::LabelButton* accept_button() const { return accept_button_; } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 button_view_(nullptr), | 137 button_view_(nullptr), |
| 139 browser_fullscreen_exit_accelerator_(accelerator) { | 138 browser_fullscreen_exit_accelerator_(accelerator) { |
| 140 views::BubbleBorder::Shadow shadow_type = views::BubbleBorder::BIG_SHADOW; | 139 views::BubbleBorder::Shadow shadow_type = views::BubbleBorder::BIG_SHADOW; |
| 141 #if defined(OS_LINUX) | 140 #if defined(OS_LINUX) |
| 142 // Use a smaller shadow on Linux (including ChromeOS) as the shadow assets can | 141 // Use a smaller shadow on Linux (including ChromeOS) as the shadow assets can |
| 143 // overlap each other in a fullscreen notification bubble. | 142 // overlap each other in a fullscreen notification bubble. |
| 144 // See http://crbug.com/462983. | 143 // See http://crbug.com/462983. |
| 145 shadow_type = views::BubbleBorder::SMALL_SHADOW; | 144 shadow_type = views::BubbleBorder::SMALL_SHADOW; |
| 146 #endif | 145 #endif |
| 147 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) | 146 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) |
| 148 shadow_type = views::BubbleBorder::NO_SHADOW; | 147 shadow_type = views::BubbleBorder::NO_ASSETS; |
| 149 | 148 |
| 150 ui::NativeTheme* theme = ui::NativeTheme::instance(); | 149 ui::NativeTheme* theme = ui::NativeTheme::instance(); |
| 151 SkColor background_color = | 150 SkColor background_color = |
| 152 ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() | 151 ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() |
| 153 ? SK_ColorBLACK | 152 ? SkColorSetARGBMacro(kBackgroundOpacity, 0, 0, 0) |
|
msw
2015/10/26 16:53:39
SkColorSetA would let you still use SK_ColorBLACK.
Matt Giuca
2015/10/26 23:25:39
Done.
| |
| 154 : theme->GetSystemColor(ui::NativeTheme::kColorId_BubbleBackground); | 153 : theme->GetSystemColor(ui::NativeTheme::kColorId_BubbleBackground); |
| 155 SkColor foreground_color = | 154 SkColor foreground_color = |
| 156 ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() | 155 ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() |
| 157 ? SK_ColorWHITE | 156 ? SK_ColorWHITE |
| 158 : theme->GetSystemColor(ui::NativeTheme::kColorId_LabelEnabledColor); | 157 : theme->GetSystemColor(ui::NativeTheme::kColorId_LabelEnabledColor); |
| 159 | 158 |
| 160 scoped_ptr<views::BubbleBorder> bubble_border(new views::BubbleBorder( | 159 scoped_ptr<views::BubbleBorder> bubble_border(new views::BubbleBorder( |
| 161 views::BubbleBorder::NONE, shadow_type, background_color)); | 160 views::BubbleBorder::NONE, shadow_type, background_color)); |
| 162 set_background(new views::BubbleBackground(bubble_border.get())); | 161 set_background(new views::BubbleBackground(bubble_border.get())); |
| 163 SetBorder(bubble_border.Pass()); | 162 SetBorder(bubble_border.Pass()); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 params.parent = | 333 params.parent = |
| 335 bubble_view_context_->GetBubbleAssociatedWidget()->GetNativeView(); | 334 bubble_view_context_->GetBubbleAssociatedWidget()->GetNativeView(); |
| 336 // The simplified UI just shows a notice; clicks should go through to the | 335 // The simplified UI just shows a notice; clicks should go through to the |
| 337 // underlying window. | 336 // underlying window. |
| 338 params.accept_events = | 337 params.accept_events = |
| 339 !ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled(); | 338 !ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled(); |
| 340 popup_->Init(params); | 339 popup_->Init(params); |
| 341 popup_->SetContentsView(view_); | 340 popup_->SetContentsView(view_); |
| 342 gfx::Size size = GetPopupRect(true).size(); | 341 gfx::Size size = GetPopupRect(true).size(); |
| 343 popup_->SetBounds(GetPopupRect(false)); | 342 popup_->SetBounds(GetPopupRect(false)); |
| 344 popup_->SetOpacity(GetMaximumOpacity()); | |
| 345 // We set layout manager to nullptr to prevent the widget from sizing its | 343 // We set layout manager to nullptr to prevent the widget from sizing its |
| 346 // contents to the same size as itself. This prevents the widget contents from | 344 // contents to the same size as itself. This prevents the widget contents from |
| 347 // shrinking while we animate the height of the popup to give the impression | 345 // shrinking while we animate the height of the popup to give the impression |
| 348 // that it is sliding off the top of the screen. | 346 // that it is sliding off the top of the screen. |
| 349 popup_->GetRootView()->SetLayoutManager(nullptr); | 347 popup_->GetRootView()->SetLayoutManager(nullptr); |
| 350 view_->SetBounds(0, 0, size.width(), size.height()); | 348 view_->SetBounds(0, 0, size.width(), size.height()); |
| 351 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) | 349 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) |
| 352 popup_->ShowInactive(); // This does not activate the popup. | 350 popup_->ShowInactive(); // This does not activate the popup. |
| 353 | 351 |
| 354 popup_->AddObserver(this); | 352 popup_->AddObserver(this); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 // switching the animated attribute midway through the animation looks | 436 // switching the animated attribute midway through the animation looks |
| 439 // weird. | 437 // weird. |
| 440 animation_->End(); | 438 animation_->End(); |
| 441 | 439 |
| 442 animated_attribute_ = expected_animated_attribute; | 440 animated_attribute_ = expected_animated_attribute; |
| 443 | 441 |
| 444 // We may have finished hiding |popup_|. However, the bounds animation | 442 // We may have finished hiding |popup_|. However, the bounds animation |
| 445 // assumes |popup_| has the opacity when it is fully shown and the opacity | 443 // assumes |popup_| has the opacity when it is fully shown and the opacity |
| 446 // animation assumes |popup_| has the bounds when |popup_| is fully shown. | 444 // animation assumes |popup_| has the bounds when |popup_| is fully shown. |
| 447 if (animated_attribute_ == ANIMATED_ATTRIBUTE_BOUNDS) | 445 if (animated_attribute_ == ANIMATED_ATTRIBUTE_BOUNDS) |
| 448 popup_->SetOpacity(GetMaximumOpacity()); | 446 popup_->SetOpacity(255); |
| 449 else | 447 else |
| 450 UpdateBounds(); | 448 UpdateBounds(); |
| 451 } | 449 } |
| 452 | 450 |
| 453 UpdateMouseWatcher(); | 451 UpdateMouseWatcher(); |
| 454 } | 452 } |
| 455 | 453 |
| 456 void ExclusiveAccessBubbleViews::UpdateBounds() { | 454 void ExclusiveAccessBubbleViews::UpdateBounds() { |
| 457 gfx::Rect popup_rect(GetPopupRect(false)); | 455 gfx::Rect popup_rect(GetPopupRect(false)); |
| 458 if (!popup_rect.IsEmpty()) { | 456 if (!popup_rect.IsEmpty()) { |
| 459 popup_->SetBounds(popup_rect); | 457 popup_->SetBounds(popup_rect); |
| 460 view_->SetY(popup_rect.height() - view_->height()); | 458 view_->SetY(popup_rect.height() - view_->height()); |
| 461 } | 459 } |
| 462 } | 460 } |
| 463 | 461 |
| 464 views::View* ExclusiveAccessBubbleViews::GetBrowserRootView() const { | 462 views::View* ExclusiveAccessBubbleViews::GetBrowserRootView() const { |
| 465 return bubble_view_context_->GetBubbleAssociatedWidget()->GetRootView(); | 463 return bubble_view_context_->GetBubbleAssociatedWidget()->GetRootView(); |
| 466 } | 464 } |
| 467 | 465 |
| 468 void ExclusiveAccessBubbleViews::AnimationProgressed( | 466 void ExclusiveAccessBubbleViews::AnimationProgressed( |
| 469 const gfx::Animation* animation) { | 467 const gfx::Animation* animation) { |
| 470 if (animated_attribute_ == ANIMATED_ATTRIBUTE_OPACITY) { | 468 if (animated_attribute_ == ANIMATED_ATTRIBUTE_OPACITY) { |
| 471 int opacity = animation_->CurrentValueBetween(0, GetMaximumOpacity()); | 469 int opacity = animation_->CurrentValueBetween(0, 255); |
| 472 if (opacity == 0) { | 470 if (opacity == 0) { |
| 473 popup_->Hide(); | 471 popup_->Hide(); |
| 474 } else { | 472 } else { |
| 475 popup_->Show(); | 473 popup_->Show(); |
| 476 popup_->SetOpacity(opacity); | 474 popup_->SetOpacity(opacity); |
| 477 } | 475 } |
| 478 } else { | 476 } else { |
| 479 if (GetPopupRect(false).IsEmpty()) { | 477 if (GetPopupRect(false).IsEmpty()) { |
| 480 popup_->Hide(); | 478 popup_->Hide(); |
| 481 } else { | 479 } else { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 573 const content::NotificationDetails& details) { | 571 const content::NotificationDetails& details) { |
| 574 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); | 572 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); |
| 575 UpdateForImmersiveState(); | 573 UpdateForImmersiveState(); |
| 576 } | 574 } |
| 577 | 575 |
| 578 void ExclusiveAccessBubbleViews::OnWidgetVisibilityChanged( | 576 void ExclusiveAccessBubbleViews::OnWidgetVisibilityChanged( |
| 579 views::Widget* widget, | 577 views::Widget* widget, |
| 580 bool visible) { | 578 bool visible) { |
| 581 UpdateMouseWatcher(); | 579 UpdateMouseWatcher(); |
| 582 } | 580 } |
| OLD | NEW |