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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/strings/string_split.h" | |
| 12 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 13 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 14 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 15 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
| 17 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 16 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| 18 #include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h" | 17 #include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h" |
| 19 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 18 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
| 20 #include "chrome/browser/ui/views/frame/top_container_view.h" | 19 #include "chrome/browser/ui/views/frame/top_container_view.h" |
| 20 #include "chrome/browser/ui/views/subtle_notification_view.h" | |
| 21 #include "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | |
| 25 #include "ui/events/keycodes/keyboard_codes.h" | 24 #include "ui/events/keycodes/keyboard_codes.h" |
| 26 #include "ui/gfx/animation/slide_animation.h" | 25 #include "ui/gfx/animation/slide_animation.h" |
| 27 #include "ui/gfx/canvas.h" | 26 #include "ui/gfx/canvas.h" |
| 28 #include "ui/strings/grit/ui_strings.h" | 27 #include "ui/strings/grit/ui_strings.h" |
| 29 #include "ui/views/bubble/bubble_border.h" | 28 #include "ui/views/bubble/bubble_border.h" |
| 30 #include "ui/views/controls/link.h" | 29 #include "ui/views/controls/link.h" |
| 31 #include "ui/views/controls/link_listener.h" | |
| 32 #include "ui/views/layout/box_layout.h" | |
| 33 #include "ui/views/view.h" | 30 #include "ui/views/view.h" |
| 34 #include "ui/views/widget/widget.h" | 31 #include "ui/views/widget/widget.h" |
| 35 #include "url/gurl.h" | 32 #include "url/gurl.h" |
| 36 | 33 |
| 37 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
| 38 #include "ui/base/l10n/l10n_util_win.h" | 35 #include "ui/base/l10n/l10n_util_win.h" |
| 39 #endif | 36 #endif |
| 40 | 37 |
| 41 // ExclusiveAccessView --------------------------------------------------------- | |
| 42 | |
| 43 namespace { | |
| 44 | |
| 45 // Space between the site info label and the link. | |
| 46 const int kMiddlePaddingPx = 30; | |
| 47 | |
| 48 const int kOuterPaddingHorizPx = 40; | |
| 49 const int kOuterPaddingVertPx = 8; | |
| 50 | |
| 51 // Partially-transparent background color. | |
| 52 const SkColor kBackgroundColor = SkColorSetARGB(0xcc, 0x28, 0x2c, 0x32); | |
| 53 | |
| 54 // Class containing the exit instruction text. Contains fancy styling on the | |
| 55 // keyboard key (not just a simple label). | |
| 56 class InstructionView : public views::View { | |
| 57 public: | |
| 58 // Creates an InstructionView with specific text. |text| may contain a single | |
| 59 // segment delimited by a pair of pipes ('|'); this segment will be displayed | |
| 60 // as a keyboard key. e.g., "Press |Esc| to exit" will have "Esc" rendered as | |
| 61 // a key. | |
| 62 InstructionView(const base::string16& text, | |
| 63 const gfx::FontList& font_list, | |
| 64 SkColor foreground_color, | |
| 65 SkColor background_color); | |
| 66 | |
| 67 void SetText(const base::string16& text); | |
| 68 | |
| 69 private: | |
| 70 views::Label* before_key_; | |
| 71 views::Label* key_name_label_; | |
| 72 views::View* key_name_; | |
| 73 views::Label* after_key_; | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(InstructionView); | |
| 76 }; | |
| 77 | |
| 78 InstructionView::InstructionView(const base::string16& text, | |
| 79 const gfx::FontList& font_list, | |
| 80 SkColor foreground_color, | |
| 81 SkColor background_color) { | |
| 82 // Spacing around the escape key name. | |
| 83 const int kKeyNameMarginHorizPx = 7; | |
| 84 const int kKeyNameBorderPx = 1; | |
| 85 const int kKeyNameCornerRadius = 2; | |
| 86 const int kKeyNamePaddingPx = 5; | |
| 87 | |
| 88 // The |between_child_spacing| is the horizontal margin of the key name. | |
| 89 views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kHorizontal, | |
| 90 0, 0, kKeyNameMarginHorizPx); | |
| 91 SetLayoutManager(layout); | |
| 92 | |
| 93 before_key_ = new views::Label(base::string16(), font_list); | |
| 94 before_key_->SetEnabledColor(foreground_color); | |
| 95 before_key_->SetBackgroundColor(background_color); | |
| 96 AddChildView(before_key_); | |
| 97 | |
| 98 key_name_label_ = new views::Label(base::string16(), font_list); | |
| 99 key_name_label_->SetEnabledColor(foreground_color); | |
| 100 key_name_label_->SetBackgroundColor(background_color); | |
| 101 | |
| 102 key_name_ = new views::View; | |
| 103 views::BoxLayout* key_name_layout = new views::BoxLayout( | |
| 104 views::BoxLayout::kHorizontal, kKeyNamePaddingPx, 0, 0); | |
| 105 key_name_layout->set_minimum_cross_axis_size( | |
| 106 key_name_label_->GetPreferredSize().height() + kKeyNamePaddingPx * 2); | |
| 107 key_name_->SetLayoutManager(key_name_layout); | |
| 108 key_name_->AddChildView(key_name_label_); | |
| 109 // The key name has a border around it. | |
| 110 std::unique_ptr<views::Border> border(views::Border::CreateRoundedRectBorder( | |
| 111 kKeyNameBorderPx, kKeyNameCornerRadius, foreground_color)); | |
| 112 key_name_->SetBorder(std::move(border)); | |
| 113 AddChildView(key_name_); | |
| 114 | |
| 115 after_key_ = new views::Label(base::string16(), font_list); | |
| 116 after_key_->SetEnabledColor(foreground_color); | |
| 117 after_key_->SetBackgroundColor(background_color); | |
| 118 AddChildView(after_key_); | |
| 119 | |
| 120 SetText(text); | |
| 121 } | |
| 122 | |
| 123 void InstructionView::SetText(const base::string16& text) { | |
| 124 // Parse |text|, looking for pipe-delimited segment. | |
| 125 std::vector<base::string16> segments = | |
| 126 base::SplitString(text, base::ASCIIToUTF16("|"), base::TRIM_WHITESPACE, | |
| 127 base::SPLIT_WANT_ALL); | |
| 128 // Expect 1 or 3 pieces (either no pipe-delimited segments, or one). | |
| 129 DCHECK(segments.size() <= 1 || segments.size() == 3); | |
| 130 | |
| 131 before_key_->SetText(segments.size() ? segments[0] : base::string16()); | |
| 132 | |
| 133 if (segments.size() < 3) { | |
| 134 key_name_->SetVisible(false); | |
| 135 after_key_->SetVisible(false); | |
| 136 return; | |
| 137 } | |
| 138 | |
| 139 before_key_->SetText(segments[0]); | |
| 140 key_name_label_->SetText(segments[1]); | |
| 141 key_name_->SetVisible(true); | |
| 142 after_key_->SetVisible(true); | |
| 143 after_key_->SetText(segments[2]); | |
| 144 } | |
| 145 | |
| 146 } // namespace | |
| 147 | |
| 148 class ExclusiveAccessBubbleViews::ExclusiveAccessView | |
| 149 : public views::View, | |
| 150 public views::LinkListener { | |
| 151 public: | |
| 152 ExclusiveAccessView(ExclusiveAccessBubbleViews* bubble, | |
| 153 const base::string16& accelerator, | |
| 154 ExclusiveAccessBubbleType bubble_type); | |
| 155 ~ExclusiveAccessView() override; | |
| 156 | |
| 157 // views::LinkListener | |
| 158 void LinkClicked(views::Link* source, int event_flags) override; | |
| 159 | |
| 160 void UpdateContent(ExclusiveAccessBubbleType bubble_type); | |
| 161 | |
| 162 private: | |
| 163 ExclusiveAccessBubbleViews* bubble_; | |
| 164 | |
| 165 // Clickable hint text for exiting fullscreen mode. (Non-simplified mode | |
| 166 // only.) | |
| 167 views::Link* link_; | |
| 168 // Instruction for exiting fullscreen / mouse lock. Only present if there is | |
| 169 // no link (always present in simplified mode). | |
| 170 InstructionView* exit_instruction_; | |
| 171 const base::string16 browser_fullscreen_exit_accelerator_; | |
| 172 | |
| 173 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessView); | |
| 174 }; | |
| 175 | |
| 176 ExclusiveAccessBubbleViews::ExclusiveAccessView::ExclusiveAccessView( | |
| 177 ExclusiveAccessBubbleViews* bubble, | |
| 178 const base::string16& accelerator, | |
| 179 ExclusiveAccessBubbleType bubble_type) | |
| 180 : bubble_(bubble), | |
| 181 link_(nullptr), | |
| 182 exit_instruction_(nullptr), | |
| 183 browser_fullscreen_exit_accelerator_(accelerator) { | |
| 184 const SkColor kForegroundColor = SK_ColorWHITE; | |
| 185 | |
| 186 std::unique_ptr<views::BubbleBorder> bubble_border(new views::BubbleBorder( | |
| 187 views::BubbleBorder::NONE, views::BubbleBorder::NO_ASSETS, | |
| 188 kBackgroundColor)); | |
| 189 set_background(new views::BubbleBackground(bubble_border.get())); | |
| 190 SetBorder(std::move(bubble_border)); | |
| 191 | |
| 192 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 193 const gfx::FontList& font_list = | |
| 194 rb.GetFontList(ui::ResourceBundle::MediumFont); | |
| 195 | |
| 196 exit_instruction_ = new InstructionView(base::string16(), font_list, | |
| 197 kForegroundColor, kBackgroundColor); | |
| 198 | |
| 199 link_ = new views::Link(); | |
| 200 link_->SetFocusBehavior(FocusBehavior::NEVER); | |
| 201 #if defined(OS_CHROMEOS) | |
| 202 // On CrOS, the link text doesn't change, since it doesn't show the shortcut. | |
| 203 link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE)); | |
| 204 #endif | |
| 205 link_->set_listener(this); | |
| 206 link_->SetFontList(font_list); | |
| 207 link_->SetPressedColor(kForegroundColor); | |
| 208 link_->SetEnabledColor(kForegroundColor); | |
| 209 link_->SetBackgroundColor(kBackgroundColor); | |
| 210 link_->SetVisible(false); | |
| 211 | |
| 212 int outer_padding_horiz = kOuterPaddingHorizPx; | |
| 213 int outer_padding_vert = kOuterPaddingVertPx; | |
| 214 AddChildView(exit_instruction_); | |
| 215 AddChildView(link_); | |
| 216 | |
| 217 views::BoxLayout* layout = | |
| 218 new views::BoxLayout(views::BoxLayout::kHorizontal, outer_padding_horiz, | |
| 219 outer_padding_vert, kMiddlePaddingPx); | |
| 220 SetLayoutManager(layout); | |
| 221 | |
| 222 UpdateContent(bubble_type); | |
| 223 } | |
| 224 | |
| 225 ExclusiveAccessBubbleViews::ExclusiveAccessView::~ExclusiveAccessView() { | |
| 226 } | |
| 227 | |
| 228 void ExclusiveAccessBubbleViews::ExclusiveAccessView::LinkClicked( | |
| 229 views::Link* link, | |
| 230 int event_flags) { | |
| 231 bubble_->ExitExclusiveAccess(); | |
| 232 } | |
| 233 | |
| 234 void ExclusiveAccessBubbleViews::ExclusiveAccessView::UpdateContent( | |
| 235 ExclusiveAccessBubbleType bubble_type) { | |
| 236 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type); | |
| 237 | |
| 238 bool link_visible = | |
| 239 !ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled(); | |
| 240 base::string16 accelerator; | |
| 241 if (bubble_type == | |
| 242 EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION || | |
| 243 bubble_type == | |
| 244 EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION) { | |
| 245 accelerator = browser_fullscreen_exit_accelerator_; | |
| 246 } else { | |
| 247 accelerator = l10n_util::GetStringUTF16(IDS_APP_ESC_KEY); | |
| 248 if (bubble_type != | |
| 249 EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION) { | |
| 250 link_visible = false; | |
| 251 } | |
| 252 } | |
| 253 #if !defined(OS_CHROMEOS) | |
| 254 if (link_visible) { | |
| 255 link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE) + | |
| 256 base::UTF8ToUTF16(" ") + | |
| 257 l10n_util::GetStringFUTF16( | |
| 258 IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR, accelerator)); | |
| 259 } | |
| 260 #endif | |
| 261 link_->SetVisible(link_visible); | |
| 262 exit_instruction_->SetText(bubble_->GetInstructionText(accelerator)); | |
| 263 exit_instruction_->SetVisible(!link_visible); | |
| 264 } | |
| 265 | |
| 266 // ExclusiveAccessBubbleViews -------------------------------------------------- | |
| 267 | |
| 268 ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews( | 38 ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews( |
| 269 ExclusiveAccessBubbleViewsContext* context, | 39 ExclusiveAccessBubbleViewsContext* context, |
| 270 const GURL& url, | 40 const GURL& url, |
| 271 ExclusiveAccessBubbleType bubble_type) | 41 ExclusiveAccessBubbleType bubble_type) |
| 272 : ExclusiveAccessBubble(context->GetExclusiveAccessManager(), | 42 : ExclusiveAccessBubble(context->GetExclusiveAccessManager(), |
| 273 url, | 43 url, |
| 274 bubble_type), | 44 bubble_type), |
| 275 bubble_view_context_(context), | 45 bubble_view_context_(context), |
| 276 popup_(nullptr), | 46 popup_(nullptr), |
| 277 animation_(new gfx::SlideAnimation(this)) { | 47 animation_(new gfx::SlideAnimation(this)) { |
| 278 // With the simplified fullscreen UI flag, initially hide the bubble; | 48 // With the simplified fullscreen UI flag, initially hide the bubble; |
| 279 // otherwise, initially show it. | 49 // otherwise, initially show it. |
| 280 double initial_value = | 50 double initial_value = |
| 281 ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 0 : 1; | 51 ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 0 : 1; |
| 282 animation_->Reset(initial_value); | 52 animation_->Reset(initial_value); |
| 283 | 53 |
| 284 // Create the contents view. | 54 // Create the contents view. |
| 285 ui::Accelerator accelerator(ui::VKEY_UNKNOWN, ui::EF_NONE); | 55 ui::Accelerator accelerator(ui::VKEY_UNKNOWN, ui::EF_NONE); |
| 286 bool got_accelerator = | 56 bool got_accelerator = |
| 287 bubble_view_context_->GetAcceleratorProvider() | 57 bubble_view_context_->GetAcceleratorProvider() |
| 288 ->GetAcceleratorForCommandId(IDC_FULLSCREEN, &accelerator); | 58 ->GetAcceleratorForCommandId(IDC_FULLSCREEN, &accelerator); |
| 289 DCHECK(got_accelerator); | 59 DCHECK(got_accelerator); |
| 290 view_ = new ExclusiveAccessView(this, accelerator.GetShortcutText(), | 60 view_ = new SubtleNotificationView(base::string16(), base::string16(), this); |
|
msw
2016/05/18 18:38:31
nit: maybe remove the string args for the ctor?
Matt Giuca
2016/05/19 01:50:31
Done.
| |
| 291 bubble_type_); | 61 browser_fullscreen_exit_accelerator_ = accelerator.GetShortcutText(); |
| 62 UpdateViewContent(bubble_type_); | |
| 292 | 63 |
| 293 // TODO(yzshen): Change to use the new views bubble, BubbleDelegateView. | |
| 294 // TODO(pkotwicz): When this becomes a views bubble, make sure that this | |
| 295 // bubble is ignored by ImmersiveModeControllerAsh::BubbleManager. | |
| 296 // Initialize the popup. | |
| 297 popup_ = new views::Widget; | |
| 298 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | |
| 299 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | |
| 300 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
| 301 params.parent = bubble_view_context_->GetBubbleParentView(); | |
| 302 // The simplified UI just shows a notice; clicks should go through to the | 64 // The simplified UI just shows a notice; clicks should go through to the |
| 303 // underlying window. | 65 // underlying window. |
| 304 params.accept_events = | 66 bool accept_events = |
| 305 !ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled(); | 67 !ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled(); |
| 306 popup_->Init(params); | 68 // Initialize the popup. |
| 307 popup_->SetContentsView(view_); | 69 popup_ = SubtleNotificationView::CreatePopupWidget( |
| 70 bubble_view_context_->GetBubbleParentView(), view_, accept_events); | |
| 308 gfx::Size size = GetPopupRect(true).size(); | 71 gfx::Size size = GetPopupRect(true).size(); |
| 309 // Bounds are in screen coordinates. | 72 // Bounds are in screen coordinates. |
| 310 popup_->SetBounds(GetPopupRect(false)); | 73 popup_->SetBounds(GetPopupRect(false)); |
| 311 // We set layout manager to nullptr to prevent the widget from sizing its | |
| 312 // contents to the same size as itself. This prevents the widget contents from | |
| 313 // shrinking while we animate the height of the popup to give the impression | |
| 314 // that it is sliding off the top of the screen. | |
| 315 popup_->GetRootView()->SetLayoutManager(nullptr); | |
| 316 view_->SetBounds(0, 0, size.width(), size.height()); | 74 view_->SetBounds(0, 0, size.width(), size.height()); |
| 317 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) | 75 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) |
| 318 popup_->ShowInactive(); // This does not activate the popup. | 76 popup_->ShowInactive(); // This does not activate the popup. |
| 319 | 77 |
| 320 popup_->AddObserver(this); | 78 popup_->AddObserver(this); |
| 321 | 79 |
| 322 registrar_.Add(this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, | 80 registrar_.Add(this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
| 323 content::Source<FullscreenController>( | 81 content::Source<FullscreenController>( |
| 324 bubble_view_context_->GetExclusiveAccessManager() | 82 bubble_view_context_->GetExclusiveAccessManager() |
| 325 ->fullscreen_controller())); | 83 ->fullscreen_controller())); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 345 | 103 |
| 346 void ExclusiveAccessBubbleViews::UpdateContent( | 104 void ExclusiveAccessBubbleViews::UpdateContent( |
| 347 const GURL& url, | 105 const GURL& url, |
| 348 ExclusiveAccessBubbleType bubble_type) { | 106 ExclusiveAccessBubbleType bubble_type) { |
| 349 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type); | 107 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type); |
| 350 if (bubble_type_ == bubble_type && url_ == url) | 108 if (bubble_type_ == bubble_type && url_ == url) |
| 351 return; | 109 return; |
| 352 | 110 |
| 353 url_ = url; | 111 url_ = url; |
| 354 bubble_type_ = bubble_type; | 112 bubble_type_ = bubble_type; |
| 355 view_->UpdateContent(bubble_type_); | 113 UpdateViewContent(bubble_type_); |
| 356 | 114 |
| 357 gfx::Size size = GetPopupRect(true).size(); | 115 gfx::Size size = GetPopupRect(true).size(); |
| 358 view_->SetSize(size); | 116 view_->SetSize(size); |
| 359 popup_->SetBounds(GetPopupRect(false)); | 117 popup_->SetBounds(GetPopupRect(false)); |
| 360 Show(); | 118 Show(); |
| 361 | 119 |
| 362 // Stop watching the mouse even if UpdateMouseWatcher() will start watching | 120 // Stop watching the mouse even if UpdateMouseWatcher() will start watching |
| 363 // it again so that the popup with the new content is visible for at least | 121 // it again so that the popup with the new content is visible for at least |
| 364 // |kInitialDelayMs|. | 122 // |kInitialDelayMs|. |
| 365 StopWatchingMouse(); | 123 StopWatchingMouse(); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 389 } | 147 } |
| 390 | 148 |
| 391 void ExclusiveAccessBubbleViews::UpdateBounds() { | 149 void ExclusiveAccessBubbleViews::UpdateBounds() { |
| 392 gfx::Rect popup_rect(GetPopupRect(false)); | 150 gfx::Rect popup_rect(GetPopupRect(false)); |
| 393 if (!popup_rect.IsEmpty()) { | 151 if (!popup_rect.IsEmpty()) { |
| 394 popup_->SetBounds(popup_rect); | 152 popup_->SetBounds(popup_rect); |
| 395 view_->SetY(popup_rect.height() - view_->height()); | 153 view_->SetY(popup_rect.height() - view_->height()); |
| 396 } | 154 } |
| 397 } | 155 } |
| 398 | 156 |
| 157 void ExclusiveAccessBubbleViews::UpdateViewContent( | |
| 158 ExclusiveAccessBubbleType bubble_type) { | |
| 159 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type); | |
| 160 | |
| 161 bool link_visible = | |
| 162 !ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled(); | |
| 163 base::string16 accelerator; | |
| 164 if (bubble_type == | |
| 165 EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION || | |
| 166 bubble_type == | |
| 167 EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION) { | |
| 168 accelerator = browser_fullscreen_exit_accelerator_; | |
| 169 } else { | |
| 170 accelerator = l10n_util::GetStringUTF16(IDS_APP_ESC_KEY); | |
| 171 if (bubble_type != | |
| 172 EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION) { | |
| 173 link_visible = false; | |
| 174 } | |
| 175 } | |
| 176 base::string16 link_text; | |
| 177 base::string16 exit_instruction_text; | |
| 178 if (link_visible) { | |
| 179 link_text = l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE); | |
| 180 #if !defined(OS_CHROMEOS) | |
| 181 link_text += base::UTF8ToUTF16(" ") + | |
| 182 l10n_util::GetStringFUTF16( | |
| 183 IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR, accelerator); | |
| 184 #endif | |
| 185 } else { | |
| 186 exit_instruction_text = GetInstructionText(accelerator); | |
| 187 } | |
| 188 view_->UpdateContent(exit_instruction_text, link_text); | |
| 189 } | |
| 190 | |
| 399 views::View* ExclusiveAccessBubbleViews::GetBrowserRootView() const { | 191 views::View* ExclusiveAccessBubbleViews::GetBrowserRootView() const { |
| 400 return bubble_view_context_->GetBubbleAssociatedWidget()->GetRootView(); | 192 return bubble_view_context_->GetBubbleAssociatedWidget()->GetRootView(); |
| 401 } | 193 } |
| 402 | 194 |
| 403 void ExclusiveAccessBubbleViews::AnimationProgressed( | 195 void ExclusiveAccessBubbleViews::AnimationProgressed( |
| 404 const gfx::Animation* animation) { | 196 const gfx::Animation* animation) { |
| 405 int opacity = animation_->CurrentValueBetween(0, 255); | 197 int opacity = animation_->CurrentValueBetween(0, 255); |
| 406 if (opacity == 0) { | 198 if (opacity == 0) { |
| 407 popup_->Hide(); | 199 popup_->Hide(); |
| 408 } else { | 200 } else { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 const content::NotificationDetails& details) { | 271 const content::NotificationDetails& details) { |
| 480 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); | 272 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); |
| 481 UpdateMouseWatcher(); | 273 UpdateMouseWatcher(); |
| 482 } | 274 } |
| 483 | 275 |
| 484 void ExclusiveAccessBubbleViews::OnWidgetVisibilityChanged( | 276 void ExclusiveAccessBubbleViews::OnWidgetVisibilityChanged( |
| 485 views::Widget* widget, | 277 views::Widget* widget, |
| 486 bool visible) { | 278 bool visible) { |
| 487 UpdateMouseWatcher(); | 279 UpdateMouseWatcher(); |
| 488 } | 280 } |
| 281 | |
| 282 void ExclusiveAccessBubbleViews::LinkClicked(views::Link* link, | |
| 283 int event_flags) { | |
| 284 ExitExclusiveAccess(); | |
| 285 } | |
| OLD | NEW |