| 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 10 matching lines...) Expand all Loading... |
| 21 #include "ui/gfx/animation/slide_animation.h" | 21 #include "ui/gfx/animation/slide_animation.h" |
| 22 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
| 23 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
| 24 #include "ui/native_theme/native_theme.h" | 24 #include "ui/native_theme/native_theme.h" |
| 25 #include "ui/strings/grit/ui_strings.h" | 25 #include "ui/strings/grit/ui_strings.h" |
| 26 #include "ui/views/bubble/bubble_border.h" | 26 #include "ui/views/bubble/bubble_border.h" |
| 27 #include "ui/views/controls/button/label_button.h" | 27 #include "ui/views/controls/button/label_button.h" |
| 28 #include "ui/views/controls/link.h" | 28 #include "ui/views/controls/link.h" |
| 29 #include "ui/views/controls/link_listener.h" | 29 #include "ui/views/controls/link_listener.h" |
| 30 #include "ui/views/layout/box_layout.h" | 30 #include "ui/views/layout/box_layout.h" |
| 31 #include "ui/views/layout/grid_layout.h" | |
| 32 #include "ui/views/view.h" | 31 #include "ui/views/view.h" |
| 33 #include "ui/views/widget/widget.h" | 32 #include "ui/views/widget/widget.h" |
| 34 #include "url/gurl.h" | 33 #include "url/gurl.h" |
| 35 | 34 |
| 36 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
| 37 #include "ui/base/l10n/l10n_util_win.h" | 36 #include "ui/base/l10n/l10n_util_win.h" |
| 38 #endif | 37 #endif |
| 39 | 38 |
| 40 // ExclusiveAccessView --------------------------------------------------------- | 39 // ExclusiveAccessView --------------------------------------------------------- |
| 41 | 40 |
| 42 namespace { | 41 namespace { |
| 43 | 42 |
| 44 // Space between the site info label and the buttons / link. | 43 // Space between the site info label and the buttons / link. |
| 45 const int kMiddlePaddingPx = 30; | 44 const int kMiddlePaddingPx = 30; |
| 46 | 45 |
| 47 // Opacity of the background (out of 255). Only used with | 46 // Opacity of the background (out of 255). Only used with |
| 48 // IsSimplifiedFullscreenUIEnabled. | 47 // IsSimplifiedFullscreenUIEnabled. |
| 49 const unsigned char kBackgroundOpacity = 180; | 48 const unsigned char kBackgroundOpacity = 180; |
| 50 | 49 |
| 51 class ButtonView : public views::View { | 50 class ButtonView : public views::View { |
| 52 public: | 51 public: |
| 53 ButtonView(views::ButtonListener* listener, int between_button_spacing); | 52 ButtonView(views::ButtonListener* listener, int between_button_spacing); |
| 54 ~ButtonView() override; | 53 ~ButtonView() override; |
| 55 | 54 |
| 56 // Returns an empty size when the view is not visible. | |
| 57 gfx::Size GetPreferredSize() const override; | |
| 58 | |
| 59 views::LabelButton* accept_button() const { return accept_button_; } | 55 views::LabelButton* accept_button() const { return accept_button_; } |
| 60 views::LabelButton* deny_button() const { return deny_button_; } | 56 views::LabelButton* deny_button() const { return deny_button_; } |
| 61 | 57 |
| 62 private: | 58 private: |
| 63 views::LabelButton* accept_button_; | 59 views::LabelButton* accept_button_; |
| 64 views::LabelButton* deny_button_; | 60 views::LabelButton* deny_button_; |
| 65 DISALLOW_COPY_AND_ASSIGN(ButtonView); | 61 DISALLOW_COPY_AND_ASSIGN(ButtonView); |
| 66 }; | 62 }; |
| 67 | 63 |
| 68 ButtonView::ButtonView(views::ButtonListener* listener, | 64 ButtonView::ButtonView(views::ButtonListener* listener, |
| 69 int between_button_spacing) | 65 int between_button_spacing) |
| 70 : accept_button_(nullptr), deny_button_(nullptr) { | 66 : accept_button_(nullptr), deny_button_(nullptr) { |
| 71 accept_button_ = new views::LabelButton(listener, base::string16()); | 67 accept_button_ = new views::LabelButton(listener, base::string16()); |
| 72 accept_button_->SetStyle(views::Button::STYLE_BUTTON); | 68 accept_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 73 accept_button_->SetFocusable(false); | 69 accept_button_->SetFocusable(false); |
| 74 AddChildView(accept_button_); | 70 AddChildView(accept_button_); |
| 75 | 71 |
| 76 deny_button_ = new views::LabelButton(listener, base::string16()); | 72 deny_button_ = new views::LabelButton(listener, base::string16()); |
| 77 deny_button_->SetStyle(views::Button::STYLE_BUTTON); | 73 deny_button_->SetStyle(views::Button::STYLE_BUTTON); |
| 78 deny_button_->SetFocusable(false); | 74 deny_button_->SetFocusable(false); |
| 79 AddChildView(deny_button_); | 75 AddChildView(deny_button_); |
| 80 | 76 |
| 81 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, | 77 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, |
| 82 between_button_spacing)); | 78 between_button_spacing)); |
| 83 } | 79 } |
| 84 | 80 |
| 85 ButtonView::~ButtonView() { | 81 ButtonView::~ButtonView() { |
| 86 } | 82 } |
| 87 | 83 |
| 88 gfx::Size ButtonView::GetPreferredSize() const { | |
| 89 return visible() ? views::View::GetPreferredSize() : gfx::Size(); | |
| 90 } | |
| 91 | |
| 92 } // namespace | 84 } // namespace |
| 93 | 85 |
| 94 class ExclusiveAccessBubbleViews::ExclusiveAccessView | 86 class ExclusiveAccessBubbleViews::ExclusiveAccessView |
| 95 : public views::View, | 87 : public views::View, |
| 96 public views::ButtonListener, | 88 public views::ButtonListener, |
| 97 public views::LinkListener { | 89 public views::LinkListener { |
| 98 public: | 90 public: |
| 99 ExclusiveAccessView(ExclusiveAccessBubbleViews* bubble, | 91 ExclusiveAccessView(ExclusiveAccessBubbleViews* bubble, |
| 100 const base::string16& accelerator, | 92 const base::string16& accelerator, |
| 101 const GURL& url, | 93 const GURL& url, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 rb.GetFontList(ui::ResourceBundle::MediumFont); | 163 rb.GetFontList(ui::ResourceBundle::MediumFont); |
| 172 | 164 |
| 173 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { | 165 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { |
| 174 message_label_ = new views::Label(base::string16(), medium_font_list); | 166 message_label_ = new views::Label(base::string16(), medium_font_list); |
| 175 message_label_->SetEnabledColor(foreground_color); | 167 message_label_->SetEnabledColor(foreground_color); |
| 176 message_label_->SetBackgroundColor(background_color); | 168 message_label_->SetBackgroundColor(background_color); |
| 177 } | 169 } |
| 178 | 170 |
| 179 exit_instruction_ = | 171 exit_instruction_ = |
| 180 new views::Label(bubble_->GetInstructionText(), medium_font_list); | 172 new views::Label(bubble_->GetInstructionText(), medium_font_list); |
| 181 exit_instruction_->set_collapse_when_hidden(true); | |
| 182 | |
| 183 exit_instruction_->SetEnabledColor(foreground_color); | 173 exit_instruction_->SetEnabledColor(foreground_color); |
| 184 exit_instruction_->SetBackgroundColor(background_color); | 174 exit_instruction_->SetBackgroundColor(background_color); |
| 185 | 175 |
| 186 link_ = new views::Link(); | 176 link_ = new views::Link(); |
| 187 link_->set_collapse_when_hidden(true); | |
| 188 link_->SetFocusable(false); | 177 link_->SetFocusable(false); |
| 189 #if defined(OS_CHROMEOS) | 178 #if defined(OS_CHROMEOS) |
| 190 // On CrOS, the link text doesn't change, since it doesn't show the shortcut. | 179 // On CrOS, the link text doesn't change, since it doesn't show the shortcut. |
| 191 link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE)); | 180 link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE)); |
| 192 #endif | 181 #endif |
| 193 link_->set_listener(this); | 182 link_->set_listener(this); |
| 194 link_->SetFontList(medium_font_list); | 183 link_->SetFontList(medium_font_list); |
| 195 link_->SetPressedColor(foreground_color); | 184 link_->SetPressedColor(foreground_color); |
| 196 link_->SetEnabledColor(foreground_color); | 185 link_->SetEnabledColor(foreground_color); |
| 197 link_->SetBackgroundColor(background_color); | 186 link_->SetBackgroundColor(background_color); |
| 198 link_->SetVisible(false); | 187 link_->SetVisible(false); |
| 199 | 188 |
| 200 button_view_ = new ButtonView(this, kPaddingPx); | 189 button_view_ = new ButtonView(this, kPaddingPx); |
| 201 | 190 |
| 202 views::GridLayout* layout = new views::GridLayout(this); | |
| 203 views::ColumnSet* columns = layout->AddColumnSet(0); | |
| 204 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { | |
| 205 // In the simplified UI, do not show the message label, only the exit | |
| 206 // instruction. | |
| 207 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0, | |
| 208 views::GridLayout::USE_PREF, 0, 0); | |
| 209 columns->AddPaddingColumn(1, kMiddlePaddingPx); | |
| 210 } | |
| 211 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0, | |
| 212 views::GridLayout::USE_PREF, 0, 0); | |
| 213 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0, | |
| 214 views::GridLayout::USE_PREF, 0, 0); | |
| 215 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0, | |
| 216 views::GridLayout::USE_PREF, 0, 0); | |
| 217 | |
| 218 layout->StartRow(0, 0); | |
| 219 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { | 191 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { |
| 220 DCHECK(message_label_); | 192 DCHECK(message_label_); |
| 221 layout->AddView(message_label_); | 193 AddChildView(message_label_); |
| 222 } | 194 } |
| 223 layout->AddView(button_view_); | 195 AddChildView(button_view_); |
| 224 layout->AddView(exit_instruction_); | 196 AddChildView(exit_instruction_); |
| 225 layout->AddView(link_); | 197 AddChildView(link_); |
| 226 | 198 |
| 227 gfx::Insets padding(kPaddingPx, kPaddingPx, kPaddingPx, kPaddingPx); | 199 views::BoxLayout* layout = new views::BoxLayout( |
| 228 padding += GetInsets(); | 200 views::BoxLayout::kHorizontal, kPaddingPx, kPaddingPx, kMiddlePaddingPx); |
| 229 layout->SetInsets(padding); | |
| 230 SetLayoutManager(layout); | 201 SetLayoutManager(layout); |
| 231 | 202 |
| 232 UpdateContent(url, bubble_type); | 203 UpdateContent(url, bubble_type); |
| 233 } | 204 } |
| 234 | 205 |
| 235 ExclusiveAccessBubbleViews::ExclusiveAccessView::~ExclusiveAccessView() { | 206 ExclusiveAccessBubbleViews::ExclusiveAccessView::~ExclusiveAccessView() { |
| 236 } | 207 } |
| 237 | 208 |
| 238 void ExclusiveAccessBubbleViews::ExclusiveAccessView::ButtonPressed( | 209 void ExclusiveAccessBubbleViews::ExclusiveAccessView::ButtonPressed( |
| 239 views::Button* sender, | 210 views::Button* sender, |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 const content::NotificationDetails& details) { | 546 const content::NotificationDetails& details) { |
| 576 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); | 547 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); |
| 577 UpdateForImmersiveState(); | 548 UpdateForImmersiveState(); |
| 578 } | 549 } |
| 579 | 550 |
| 580 void ExclusiveAccessBubbleViews::OnWidgetVisibilityChanged( | 551 void ExclusiveAccessBubbleViews::OnWidgetVisibilityChanged( |
| 581 views::Widget* widget, | 552 views::Widget* widget, |
| 582 bool visible) { | 553 bool visible) { |
| 583 UpdateMouseWatcher(); | 554 UpdateMouseWatcher(); |
| 584 } | 555 } |
| OLD | NEW |