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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 106 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
107 | 107 |
108 // views::LinkListener | 108 // views::LinkListener |
109 void LinkClicked(views::Link* source, int event_flags) override; | 109 void LinkClicked(views::Link* source, int event_flags) override; |
110 | 110 |
111 void UpdateContent(const GURL& url, ExclusiveAccessBubbleType bubble_type); | 111 void UpdateContent(const GURL& url, ExclusiveAccessBubbleType bubble_type); |
112 | 112 |
113 private: | 113 private: |
114 ExclusiveAccessBubbleViews* bubble_; | 114 ExclusiveAccessBubbleViews* bubble_; |
115 | 115 |
116 // Clickable hint text for exiting fullscreen mode. | 116 // Clickable hint text for exiting fullscreen mode. (Non-simplified mode |
| 117 // only.) |
117 views::Link* link_; | 118 views::Link* link_; |
118 // Instruction for exiting mouse lock. | 119 // Informational label: 'www.foo.com has gone fullscreen'. (Non-simplified |
119 views::Label* mouse_lock_exit_instruction_; | 120 // mode only.) |
120 // Informational label: 'www.foo.com has gone fullscreen'. | |
121 views::Label* message_label_; | 121 views::Label* message_label_; |
| 122 // Clickable buttons to exit fullscreen. (Non-simplified mode only.) |
122 ButtonView* button_view_; | 123 ButtonView* button_view_; |
| 124 // Instruction for exiting fullscreen / mouse lock. Only present if there is |
| 125 // no link or button (always present in simplified mode). |
| 126 views::Label* exit_instruction_; |
123 const base::string16 browser_fullscreen_exit_accelerator_; | 127 const base::string16 browser_fullscreen_exit_accelerator_; |
124 | 128 |
125 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessView); | 129 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessView); |
126 }; | 130 }; |
127 | 131 |
128 ExclusiveAccessBubbleViews::ExclusiveAccessView::ExclusiveAccessView( | 132 ExclusiveAccessBubbleViews::ExclusiveAccessView::ExclusiveAccessView( |
129 ExclusiveAccessBubbleViews* bubble, | 133 ExclusiveAccessBubbleViews* bubble, |
130 const base::string16& accelerator, | 134 const base::string16& accelerator, |
131 const GURL& url, | 135 const GURL& url, |
132 ExclusiveAccessBubbleType bubble_type) | 136 ExclusiveAccessBubbleType bubble_type) |
133 : bubble_(bubble), | 137 : bubble_(bubble), |
134 link_(nullptr), | 138 link_(nullptr), |
135 mouse_lock_exit_instruction_(nullptr), | |
136 message_label_(nullptr), | 139 message_label_(nullptr), |
137 button_view_(nullptr), | 140 button_view_(nullptr), |
| 141 exit_instruction_(nullptr), |
138 browser_fullscreen_exit_accelerator_(accelerator) { | 142 browser_fullscreen_exit_accelerator_(accelerator) { |
139 views::BubbleBorder::Shadow shadow_type = views::BubbleBorder::BIG_SHADOW; | 143 views::BubbleBorder::Shadow shadow_type = views::BubbleBorder::BIG_SHADOW; |
140 #if defined(OS_LINUX) | 144 #if defined(OS_LINUX) |
141 // Use a smaller shadow on Linux (including ChromeOS) as the shadow assets can | 145 // Use a smaller shadow on Linux (including ChromeOS) as the shadow assets can |
142 // overlap each other in a fullscreen notification bubble. | 146 // overlap each other in a fullscreen notification bubble. |
143 // See http://crbug.com/462983. | 147 // See http://crbug.com/462983. |
144 shadow_type = views::BubbleBorder::SMALL_SHADOW; | 148 shadow_type = views::BubbleBorder::SMALL_SHADOW; |
145 #endif | 149 #endif |
146 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) | 150 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) |
147 shadow_type = views::BubbleBorder::NO_ASSETS; | 151 shadow_type = views::BubbleBorder::NO_ASSETS; |
(...skipping 17 matching lines...) Expand all Loading... |
165 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 169 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
166 const gfx::FontList& medium_font_list = | 170 const gfx::FontList& medium_font_list = |
167 rb.GetFontList(ui::ResourceBundle::MediumFont); | 171 rb.GetFontList(ui::ResourceBundle::MediumFont); |
168 | 172 |
169 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { | 173 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { |
170 message_label_ = new views::Label(base::string16(), medium_font_list); | 174 message_label_ = new views::Label(base::string16(), medium_font_list); |
171 message_label_->SetEnabledColor(foreground_color); | 175 message_label_->SetEnabledColor(foreground_color); |
172 message_label_->SetBackgroundColor(background_color); | 176 message_label_->SetBackgroundColor(background_color); |
173 } | 177 } |
174 | 178 |
175 mouse_lock_exit_instruction_ = | 179 exit_instruction_ = |
176 new views::Label(bubble_->GetInstructionText(), medium_font_list); | 180 new views::Label(bubble_->GetInstructionText(), medium_font_list); |
177 mouse_lock_exit_instruction_->set_collapse_when_hidden(true); | 181 exit_instruction_->set_collapse_when_hidden(true); |
178 | 182 |
179 mouse_lock_exit_instruction_->SetEnabledColor(foreground_color); | 183 exit_instruction_->SetEnabledColor(foreground_color); |
180 mouse_lock_exit_instruction_->SetBackgroundColor(background_color); | 184 exit_instruction_->SetBackgroundColor(background_color); |
181 | 185 |
182 link_ = new views::Link(); | 186 link_ = new views::Link(); |
183 link_->set_collapse_when_hidden(true); | 187 link_->set_collapse_when_hidden(true); |
184 link_->SetFocusable(false); | 188 link_->SetFocusable(false); |
185 #if defined(OS_CHROMEOS) | 189 #if defined(OS_CHROMEOS) |
186 // On CrOS, the link text doesn't change, since it doesn't show the shortcut. | 190 // On CrOS, the link text doesn't change, since it doesn't show the shortcut. |
187 link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE)); | 191 link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE)); |
188 #endif | 192 #endif |
189 link_->set_listener(this); | 193 link_->set_listener(this); |
190 link_->SetFontList(medium_font_list); | 194 link_->SetFontList(medium_font_list); |
(...skipping 19 matching lines...) Expand all Loading... |
210 views::GridLayout::USE_PREF, 0, 0); | 214 views::GridLayout::USE_PREF, 0, 0); |
211 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0, | 215 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 0, |
212 views::GridLayout::USE_PREF, 0, 0); | 216 views::GridLayout::USE_PREF, 0, 0); |
213 | 217 |
214 layout->StartRow(0, 0); | 218 layout->StartRow(0, 0); |
215 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { | 219 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { |
216 DCHECK(message_label_); | 220 DCHECK(message_label_); |
217 layout->AddView(message_label_); | 221 layout->AddView(message_label_); |
218 } | 222 } |
219 layout->AddView(button_view_); | 223 layout->AddView(button_view_); |
220 layout->AddView(mouse_lock_exit_instruction_); | 224 layout->AddView(exit_instruction_); |
221 layout->AddView(link_); | 225 layout->AddView(link_); |
222 | 226 |
223 gfx::Insets padding(kPaddingPx, kPaddingPx, kPaddingPx, kPaddingPx); | 227 gfx::Insets padding(kPaddingPx, kPaddingPx, kPaddingPx, kPaddingPx); |
224 padding += GetInsets(); | 228 padding += GetInsets(); |
225 layout->SetInsets(padding); | 229 layout->SetInsets(padding); |
226 SetLayoutManager(layout); | 230 SetLayoutManager(layout); |
227 | 231 |
228 UpdateContent(url, bubble_type); | 232 UpdateContent(url, bubble_type); |
229 } | 233 } |
230 | 234 |
(...skipping 20 matching lines...) Expand all Loading... |
251 ExclusiveAccessBubbleType bubble_type) { | 255 ExclusiveAccessBubbleType bubble_type) { |
252 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type); | 256 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type); |
253 | 257 |
254 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { | 258 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { |
255 DCHECK(message_label_); | 259 DCHECK(message_label_); |
256 message_label_->SetText(bubble_->GetCurrentMessageText()); | 260 message_label_->SetText(bubble_->GetCurrentMessageText()); |
257 } | 261 } |
258 | 262 |
259 if (exclusive_access_bubble::ShowButtonsForType(bubble_type)) { | 263 if (exclusive_access_bubble::ShowButtonsForType(bubble_type)) { |
260 link_->SetVisible(false); | 264 link_->SetVisible(false); |
261 mouse_lock_exit_instruction_->SetVisible(false); | 265 exit_instruction_->SetVisible(false); |
262 button_view_->SetVisible(true); | 266 button_view_->SetVisible(true); |
263 button_view_->deny_button()->SetText(bubble_->GetCurrentDenyButtonText()); | 267 button_view_->deny_button()->SetText(bubble_->GetCurrentDenyButtonText()); |
264 button_view_->deny_button()->SetMinSize(gfx::Size()); | 268 button_view_->deny_button()->SetMinSize(gfx::Size()); |
265 button_view_->accept_button()->SetText( | 269 button_view_->accept_button()->SetText( |
266 bubble_->GetCurrentAllowButtonText()); | 270 bubble_->GetCurrentAllowButtonText()); |
267 button_view_->accept_button()->SetMinSize(gfx::Size()); | 271 button_view_->accept_button()->SetMinSize(gfx::Size()); |
268 } else { | 272 } else { |
269 bool link_visible = | 273 bool link_visible = |
270 !ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled(); | 274 !ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled(); |
271 base::string16 accelerator; | 275 base::string16 accelerator; |
(...skipping 10 matching lines...) Expand all Loading... |
282 } | 286 } |
283 #if !defined(OS_CHROMEOS) | 287 #if !defined(OS_CHROMEOS) |
284 if (link_visible) { | 288 if (link_visible) { |
285 link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE) + | 289 link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE) + |
286 base::UTF8ToUTF16(" ") + | 290 base::UTF8ToUTF16(" ") + |
287 l10n_util::GetStringFUTF16( | 291 l10n_util::GetStringFUTF16( |
288 IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR, accelerator)); | 292 IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR, accelerator)); |
289 } | 293 } |
290 #endif | 294 #endif |
291 link_->SetVisible(link_visible); | 295 link_->SetVisible(link_visible); |
292 mouse_lock_exit_instruction_->SetVisible(!link_visible); | 296 exit_instruction_->SetVisible(!link_visible); |
293 button_view_->SetVisible(false); | 297 button_view_->SetVisible(false); |
294 } | 298 } |
295 } | 299 } |
296 | 300 |
297 // ExclusiveAccessBubbleViews -------------------------------------------------- | 301 // ExclusiveAccessBubbleViews -------------------------------------------------- |
298 | 302 |
299 ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews( | 303 ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews( |
300 ExclusiveAccessBubbleViewsContext* context, | 304 ExclusiveAccessBubbleViewsContext* context, |
301 const GURL& url, | 305 const GURL& url, |
302 ExclusiveAccessBubbleType bubble_type) | 306 ExclusiveAccessBubbleType bubble_type) |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 const content::NotificationDetails& details) { | 575 const content::NotificationDetails& details) { |
572 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); | 576 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); |
573 UpdateForImmersiveState(); | 577 UpdateForImmersiveState(); |
574 } | 578 } |
575 | 579 |
576 void ExclusiveAccessBubbleViews::OnWidgetVisibilityChanged( | 580 void ExclusiveAccessBubbleViews::OnWidgetVisibilityChanged( |
577 views::Widget* widget, | 581 views::Widget* widget, |
578 bool visible) { | 582 bool visible) { |
579 UpdateMouseWatcher(); | 583 UpdateMouseWatcher(); |
580 } | 584 } |
OLD | NEW |