Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: chrome/browser/ui/views/exclusive_access_bubble_views.cc

Issue 1971033003: ExclusiveAccessBubbleViews: Remove unused code for old style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fullscreen-remove-old-theming
Patch Set: Remove unused include. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/exclusive_access_bubble_views.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 11 #include "base/strings/string_split.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" 16 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
17 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 17 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
18 #include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h" 18 #include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h"
19 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 19 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
20 #include "chrome/browser/ui/views/frame/top_container_view.h" 20 #include "chrome/browser/ui/views/frame/top_container_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" 24 #include "ui/base/resource/resource_bundle.h"
25 #include "ui/events/keycodes/keyboard_codes.h" 25 #include "ui/events/keycodes/keyboard_codes.h"
26 #include "ui/gfx/animation/slide_animation.h" 26 #include "ui/gfx/animation/slide_animation.h"
27 #include "ui/gfx/canvas.h" 27 #include "ui/gfx/canvas.h"
28 #include "ui/native_theme/native_theme.h"
29 #include "ui/strings/grit/ui_strings.h" 28 #include "ui/strings/grit/ui_strings.h"
30 #include "ui/views/bubble/bubble_border.h" 29 #include "ui/views/bubble/bubble_border.h"
31 #include "ui/views/controls/button/label_button.h"
32 #include "ui/views/controls/link.h" 30 #include "ui/views/controls/link.h"
33 #include "ui/views/controls/link_listener.h" 31 #include "ui/views/controls/link_listener.h"
34 #include "ui/views/layout/box_layout.h" 32 #include "ui/views/layout/box_layout.h"
35 #include "ui/views/view.h" 33 #include "ui/views/view.h"
36 #include "ui/views/widget/widget.h" 34 #include "ui/views/widget/widget.h"
37 #include "url/gurl.h" 35 #include "url/gurl.h"
38 36
39 #if defined(OS_WIN) 37 #if defined(OS_WIN)
40 #include "ui/base/l10n/l10n_util_win.h" 38 #include "ui/base/l10n/l10n_util_win.h"
41 #endif 39 #endif
42 40
43 // ExclusiveAccessView --------------------------------------------------------- 41 // ExclusiveAccessView ---------------------------------------------------------
44 42
45 namespace { 43 namespace {
46 44
47 // Space between the site info label and the buttons / link. 45 // Space between the site info label and the link.
48 const int kMiddlePaddingPx = 30; 46 const int kMiddlePaddingPx = 30;
49 47
50 const int kOuterPaddingHorizPx = 40; 48 const int kOuterPaddingHorizPx = 40;
51 const int kOuterPaddingVertPx = 8; 49 const int kOuterPaddingVertPx = 8;
52 50
53 // Partially-transparent background color. 51 // Partially-transparent background color.
54 const SkColor kBackgroundColor = SkColorSetARGB(0xcc, 0x28, 0x2c, 0x32); 52 const SkColor kBackgroundColor = SkColorSetARGB(0xcc, 0x28, 0x2c, 0x32);
55 53
56 class ButtonView : public views::View {
57 public:
58 ButtonView(views::ButtonListener* listener, int between_button_spacing);
59 ~ButtonView() override;
60
61 views::LabelButton* accept_button() const { return accept_button_; }
62 views::LabelButton* deny_button() const { return deny_button_; }
63
64 private:
65 views::LabelButton* accept_button_;
66 views::LabelButton* deny_button_;
67 DISALLOW_COPY_AND_ASSIGN(ButtonView);
68 };
69
70 ButtonView::ButtonView(views::ButtonListener* listener,
71 int between_button_spacing)
72 : accept_button_(nullptr), deny_button_(nullptr) {
73 accept_button_ = new views::LabelButton(listener, base::string16());
74 accept_button_->SetStyle(views::Button::STYLE_BUTTON);
75 accept_button_->SetFocusBehavior(FocusBehavior::NEVER);
76 AddChildView(accept_button_);
77
78 deny_button_ = new views::LabelButton(listener, base::string16());
79 deny_button_->SetStyle(views::Button::STYLE_BUTTON);
80 deny_button_->SetFocusBehavior(FocusBehavior::NEVER);
81 AddChildView(deny_button_);
82
83 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
84 between_button_spacing));
85 }
86
87 ButtonView::~ButtonView() {
88 }
89
90 // Class containing the exit instruction text. Contains fancy styling on the 54 // Class containing the exit instruction text. Contains fancy styling on the
91 // keyboard key (not just a simple label). 55 // keyboard key (not just a simple label).
92 class InstructionView : public views::View { 56 class InstructionView : public views::View {
93 public: 57 public:
94 // Creates an InstructionView with specific text. |text| may contain a single 58 // Creates an InstructionView with specific text. |text| may contain a single
95 // segment delimited by a pair of pipes ('|'); this segment will be displayed 59 // segment delimited by a pair of pipes ('|'); this segment will be displayed
96 // as a keyboard key. e.g., "Press |Esc| to exit" will have "Esc" rendered as 60 // as a keyboard key. e.g., "Press |Esc| to exit" will have "Esc" rendered as
97 // a key. 61 // a key.
98 InstructionView(const base::string16& text, 62 InstructionView(const base::string16& text,
99 const gfx::FontList& font_list, 63 const gfx::FontList& font_list,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 key_name_label_->SetText(segments[1]); 140 key_name_label_->SetText(segments[1]);
177 key_name_->SetVisible(true); 141 key_name_->SetVisible(true);
178 after_key_->SetVisible(true); 142 after_key_->SetVisible(true);
179 after_key_->SetText(segments[2]); 143 after_key_->SetText(segments[2]);
180 } 144 }
181 145
182 } // namespace 146 } // namespace
183 147
184 class ExclusiveAccessBubbleViews::ExclusiveAccessView 148 class ExclusiveAccessBubbleViews::ExclusiveAccessView
185 : public views::View, 149 : public views::View,
186 public views::ButtonListener,
187 public views::LinkListener { 150 public views::LinkListener {
188 public: 151 public:
189 ExclusiveAccessView(ExclusiveAccessBubbleViews* bubble, 152 ExclusiveAccessView(ExclusiveAccessBubbleViews* bubble,
190 const base::string16& accelerator, 153 const base::string16& accelerator,
191 const GURL& url,
192 ExclusiveAccessBubbleType bubble_type); 154 ExclusiveAccessBubbleType bubble_type);
193 ~ExclusiveAccessView() override; 155 ~ExclusiveAccessView() override;
194 156
195 // views::ButtonListener
196 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
197
198 // views::LinkListener 157 // views::LinkListener
199 void LinkClicked(views::Link* source, int event_flags) override; 158 void LinkClicked(views::Link* source, int event_flags) override;
200 159
201 void UpdateContent(const GURL& url, ExclusiveAccessBubbleType bubble_type); 160 void UpdateContent(ExclusiveAccessBubbleType bubble_type);
202 161
203 private: 162 private:
204 ExclusiveAccessBubbleViews* bubble_; 163 ExclusiveAccessBubbleViews* bubble_;
205 164
206 // Clickable hint text for exiting fullscreen mode. (Non-simplified mode 165 // Clickable hint text for exiting fullscreen mode. (Non-simplified mode
207 // only.) 166 // only.)
208 views::Link* link_; 167 views::Link* link_;
209 // Informational label: 'www.foo.com has gone fullscreen'. (Non-simplified
210 // mode only.)
211 views::Label* message_label_;
212 // Clickable buttons to exit fullscreen. (Non-simplified mode only.)
213 // TODO(mgiuca): Delete this; it is no longer used on any code path.
214 ButtonView* button_view_;
215 // Instruction for exiting fullscreen / mouse lock. Only present if there is 168 // Instruction for exiting fullscreen / mouse lock. Only present if there is
216 // no link or button (always present in simplified mode). 169 // no link (always present in simplified mode).
217 InstructionView* exit_instruction_; 170 InstructionView* exit_instruction_;
218 const base::string16 browser_fullscreen_exit_accelerator_; 171 const base::string16 browser_fullscreen_exit_accelerator_;
219 172
220 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessView); 173 DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessView);
221 }; 174 };
222 175
223 ExclusiveAccessBubbleViews::ExclusiveAccessView::ExclusiveAccessView( 176 ExclusiveAccessBubbleViews::ExclusiveAccessView::ExclusiveAccessView(
224 ExclusiveAccessBubbleViews* bubble, 177 ExclusiveAccessBubbleViews* bubble,
225 const base::string16& accelerator, 178 const base::string16& accelerator,
226 const GURL& url,
227 ExclusiveAccessBubbleType bubble_type) 179 ExclusiveAccessBubbleType bubble_type)
228 : bubble_(bubble), 180 : bubble_(bubble),
229 link_(nullptr), 181 link_(nullptr),
230 message_label_(nullptr),
231 button_view_(nullptr),
232 exit_instruction_(nullptr), 182 exit_instruction_(nullptr),
233 browser_fullscreen_exit_accelerator_(accelerator) { 183 browser_fullscreen_exit_accelerator_(accelerator) {
234 const SkColor kForegroundColor = SK_ColorWHITE; 184 const SkColor kForegroundColor = SK_ColorWHITE;
235 185
236 std::unique_ptr<views::BubbleBorder> bubble_border(new views::BubbleBorder( 186 std::unique_ptr<views::BubbleBorder> bubble_border(new views::BubbleBorder(
237 views::BubbleBorder::NONE, views::BubbleBorder::NO_ASSETS, 187 views::BubbleBorder::NONE, views::BubbleBorder::NO_ASSETS,
238 kBackgroundColor)); 188 kBackgroundColor));
239 set_background(new views::BubbleBackground(bubble_border.get())); 189 set_background(new views::BubbleBackground(bubble_border.get()));
240 SetBorder(std::move(bubble_border)); 190 SetBorder(std::move(bubble_border));
241 191
242 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 192 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
243 const gfx::FontList& font_list = 193 const gfx::FontList& font_list =
244 rb.GetFontList(ui::ResourceBundle::MediumFont); 194 rb.GetFontList(ui::ResourceBundle::MediumFont);
245 195
246 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) {
247 message_label_ = new views::Label(base::string16(), font_list);
248 message_label_->SetEnabledColor(kForegroundColor);
249 message_label_->SetBackgroundColor(kBackgroundColor);
250 }
251
252 exit_instruction_ = new InstructionView(base::string16(), font_list, 196 exit_instruction_ = new InstructionView(base::string16(), font_list,
253 kForegroundColor, kBackgroundColor); 197 kForegroundColor, kBackgroundColor);
254 198
255 link_ = new views::Link(); 199 link_ = new views::Link();
256 link_->SetFocusBehavior(FocusBehavior::NEVER); 200 link_->SetFocusBehavior(FocusBehavior::NEVER);
257 #if defined(OS_CHROMEOS) 201 #if defined(OS_CHROMEOS)
258 // On CrOS, the link text doesn't change, since it doesn't show the shortcut. 202 // On CrOS, the link text doesn't change, since it doesn't show the shortcut.
259 link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE)); 203 link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE));
260 #endif 204 #endif
261 link_->set_listener(this); 205 link_->set_listener(this);
262 link_->SetFontList(font_list); 206 link_->SetFontList(font_list);
263 link_->SetPressedColor(kForegroundColor); 207 link_->SetPressedColor(kForegroundColor);
264 link_->SetEnabledColor(kForegroundColor); 208 link_->SetEnabledColor(kForegroundColor);
265 link_->SetBackgroundColor(kBackgroundColor); 209 link_->SetBackgroundColor(kBackgroundColor);
266 link_->SetVisible(false); 210 link_->SetVisible(false);
267 211
268 button_view_ = new ButtonView(this, kPaddingPx);
269
270 int outer_padding_horiz = kOuterPaddingHorizPx; 212 int outer_padding_horiz = kOuterPaddingHorizPx;
271 int outer_padding_vert = kOuterPaddingVertPx; 213 int outer_padding_vert = kOuterPaddingVertPx;
272 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) {
273 DCHECK(message_label_);
274 AddChildView(message_label_);
275 }
276 AddChildView(button_view_);
277 AddChildView(exit_instruction_); 214 AddChildView(exit_instruction_);
278 AddChildView(link_); 215 AddChildView(link_);
279 216
280 views::BoxLayout* layout = 217 views::BoxLayout* layout =
281 new views::BoxLayout(views::BoxLayout::kHorizontal, outer_padding_horiz, 218 new views::BoxLayout(views::BoxLayout::kHorizontal, outer_padding_horiz,
282 outer_padding_vert, kMiddlePaddingPx); 219 outer_padding_vert, kMiddlePaddingPx);
283 SetLayoutManager(layout); 220 SetLayoutManager(layout);
284 221
285 UpdateContent(url, bubble_type); 222 UpdateContent(bubble_type);
286 } 223 }
287 224
288 ExclusiveAccessBubbleViews::ExclusiveAccessView::~ExclusiveAccessView() { 225 ExclusiveAccessBubbleViews::ExclusiveAccessView::~ExclusiveAccessView() {
289 } 226 }
290 227
291 void ExclusiveAccessBubbleViews::ExclusiveAccessView::ButtonPressed(
292 views::Button* sender,
293 const ui::Event& event) {
294 if (sender == button_view_->accept_button())
295 bubble_->Accept();
296 else
297 bubble_->Cancel();
298 }
299
300 void ExclusiveAccessBubbleViews::ExclusiveAccessView::LinkClicked( 228 void ExclusiveAccessBubbleViews::ExclusiveAccessView::LinkClicked(
301 views::Link* link, 229 views::Link* link,
302 int event_flags) { 230 int event_flags) {
303 bubble_->ExitExclusiveAccess(); 231 bubble_->ExitExclusiveAccess();
304 } 232 }
305 233
306 void ExclusiveAccessBubbleViews::ExclusiveAccessView::UpdateContent( 234 void ExclusiveAccessBubbleViews::ExclusiveAccessView::UpdateContent(
307 const GURL& url,
308 ExclusiveAccessBubbleType bubble_type) { 235 ExclusiveAccessBubbleType bubble_type) {
309 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type); 236 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type);
310 237
311 bool link_visible = 238 bool link_visible =
312 !ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled(); 239 !ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled();
313 base::string16 accelerator; 240 base::string16 accelerator;
314 if (bubble_type == 241 if (bubble_type ==
315 EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION || 242 EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION ||
316 bubble_type == 243 bubble_type ==
317 EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION) { 244 EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION) {
318 accelerator = browser_fullscreen_exit_accelerator_; 245 accelerator = browser_fullscreen_exit_accelerator_;
319 } else { 246 } else {
320 accelerator = l10n_util::GetStringUTF16(IDS_APP_ESC_KEY); 247 accelerator = l10n_util::GetStringUTF16(IDS_APP_ESC_KEY);
321 if (bubble_type != 248 if (bubble_type !=
322 EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION) { 249 EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION) {
323 link_visible = false; 250 link_visible = false;
324 } 251 }
325 } 252 }
326 #if !defined(OS_CHROMEOS) 253 #if !defined(OS_CHROMEOS)
327 if (link_visible) { 254 if (link_visible) {
328 link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE) + 255 link_->SetText(l10n_util::GetStringUTF16(IDS_EXIT_FULLSCREEN_MODE) +
329 base::UTF8ToUTF16(" ") + 256 base::UTF8ToUTF16(" ") +
330 l10n_util::GetStringFUTF16( 257 l10n_util::GetStringFUTF16(
331 IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR, accelerator)); 258 IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR, accelerator));
332 } 259 }
333 #endif 260 #endif
334 link_->SetVisible(link_visible); 261 link_->SetVisible(link_visible);
335 exit_instruction_->SetText(bubble_->GetInstructionText(accelerator)); 262 exit_instruction_->SetText(bubble_->GetInstructionText(accelerator));
336 exit_instruction_->SetVisible(!link_visible); 263 exit_instruction_->SetVisible(!link_visible);
337 button_view_->SetVisible(false);
338 } 264 }
339 265
340 // ExclusiveAccessBubbleViews -------------------------------------------------- 266 // ExclusiveAccessBubbleViews --------------------------------------------------
341 267
342 ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews( 268 ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews(
343 ExclusiveAccessBubbleViewsContext* context, 269 ExclusiveAccessBubbleViewsContext* context,
344 const GURL& url, 270 const GURL& url,
345 ExclusiveAccessBubbleType bubble_type) 271 ExclusiveAccessBubbleType bubble_type)
346 : ExclusiveAccessBubble(context->GetExclusiveAccessManager(), 272 : ExclusiveAccessBubble(context->GetExclusiveAccessManager(),
347 url, 273 url,
348 bubble_type), 274 bubble_type),
349 bubble_view_context_(context), 275 bubble_view_context_(context),
350 popup_(nullptr), 276 popup_(nullptr),
351 animation_(new gfx::SlideAnimation(this)), 277 animation_(new gfx::SlideAnimation(this)) {
352 animated_attribute_(ExpectedAnimationAttribute()) {
353 // With the simplified fullscreen UI flag, initially hide the bubble; 278 // With the simplified fullscreen UI flag, initially hide the bubble;
354 // otherwise, initially show it. 279 // otherwise, initially show it.
355 double initial_value = 280 double initial_value =
356 ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 0 : 1; 281 ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 0 : 1;
357 animation_->Reset(initial_value); 282 animation_->Reset(initial_value);
358 283
359 // Create the contents view. 284 // Create the contents view.
360 ui::Accelerator accelerator(ui::VKEY_UNKNOWN, ui::EF_NONE); 285 ui::Accelerator accelerator(ui::VKEY_UNKNOWN, ui::EF_NONE);
361 bool got_accelerator = 286 bool got_accelerator =
362 bubble_view_context_->GetAcceleratorProvider() 287 bubble_view_context_->GetAcceleratorProvider()
363 ->GetAcceleratorForCommandId(IDC_FULLSCREEN, &accelerator); 288 ->GetAcceleratorForCommandId(IDC_FULLSCREEN, &accelerator);
364 DCHECK(got_accelerator); 289 DCHECK(got_accelerator);
365 view_ = new ExclusiveAccessView(this, accelerator.GetShortcutText(), url, 290 view_ = new ExclusiveAccessView(this, accelerator.GetShortcutText(),
366 bubble_type_); 291 bubble_type_);
367 292
368 // TODO(yzshen): Change to use the new views bubble, BubbleDelegateView. 293 // TODO(yzshen): Change to use the new views bubble, BubbleDelegateView.
369 // TODO(pkotwicz): When this becomes a views bubble, make sure that this 294 // TODO(pkotwicz): When this becomes a views bubble, make sure that this
370 // bubble is ignored by ImmersiveModeControllerAsh::BubbleManager. 295 // bubble is ignored by ImmersiveModeControllerAsh::BubbleManager.
371 // Initialize the popup. 296 // Initialize the popup.
372 popup_ = new views::Widget; 297 popup_ = new views::Widget;
373 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); 298 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
374 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 299 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
375 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 300 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 345
421 void ExclusiveAccessBubbleViews::UpdateContent( 346 void ExclusiveAccessBubbleViews::UpdateContent(
422 const GURL& url, 347 const GURL& url,
423 ExclusiveAccessBubbleType bubble_type) { 348 ExclusiveAccessBubbleType bubble_type) {
424 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type); 349 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type);
425 if (bubble_type_ == bubble_type && url_ == url) 350 if (bubble_type_ == bubble_type && url_ == url)
426 return; 351 return;
427 352
428 url_ = url; 353 url_ = url;
429 bubble_type_ = bubble_type; 354 bubble_type_ = bubble_type;
430 view_->UpdateContent(url_, bubble_type_); 355 view_->UpdateContent(bubble_type_);
431 356
432 gfx::Size size = GetPopupRect(true).size(); 357 gfx::Size size = GetPopupRect(true).size();
433 view_->SetSize(size); 358 view_->SetSize(size);
434 popup_->SetBounds(GetPopupRect(false)); 359 popup_->SetBounds(GetPopupRect(false));
435 Show(); 360 Show();
436 361
437 // Stop watching the mouse even if UpdateMouseWatcher() will start watching 362 // Stop watching the mouse even if UpdateMouseWatcher() will start watching
438 // it again so that the popup with the new content is visible for at least 363 // it again so that the popup with the new content is visible for at least
439 // |kInitialDelayMs|. 364 // |kInitialDelayMs|.
440 StopWatchingMouse(); 365 StopWatchingMouse();
441 366
442 UpdateMouseWatcher(); 367 UpdateMouseWatcher();
443 } 368 }
444 369
445 void ExclusiveAccessBubbleViews::RepositionIfVisible() { 370 void ExclusiveAccessBubbleViews::RepositionIfVisible() {
446 if (popup_->IsVisible()) 371 if (popup_->IsVisible())
447 UpdateBounds(); 372 UpdateBounds();
448 } 373 }
449 374
450 views::View* ExclusiveAccessBubbleViews::GetView() { 375 views::View* ExclusiveAccessBubbleViews::GetView() {
451 return view_; 376 return view_;
452 } 377 }
453 378
454 ExclusiveAccessBubbleViews::AnimatedAttribute
455 ExclusiveAccessBubbleViews::ExpectedAnimationAttribute() {
456 // TODO(mgiuca): Delete this function.
457 return ANIMATED_ATTRIBUTE_OPACITY;
458 }
459
460 void ExclusiveAccessBubbleViews::UpdateMouseWatcher() { 379 void ExclusiveAccessBubbleViews::UpdateMouseWatcher() {
461 bool should_watch_mouse = false; 380 bool should_watch_mouse = popup_->IsVisible() || CanMouseTriggerSlideIn();
462 if (popup_->IsVisible())
463 should_watch_mouse =
464 !exclusive_access_bubble::ShowButtonsForType(bubble_type_);
465 else
466 should_watch_mouse = CanMouseTriggerSlideIn();
467 381
468 if (should_watch_mouse == IsWatchingMouse()) 382 if (should_watch_mouse == IsWatchingMouse())
469 return; 383 return;
470 384
471 if (should_watch_mouse) 385 if (should_watch_mouse)
472 StartWatchingMouse(); 386 StartWatchingMouse();
473 else 387 else
474 StopWatchingMouse(); 388 StopWatchingMouse();
475 } 389 }
476 390
477 void ExclusiveAccessBubbleViews::UpdateForImmersiveState() { 391 void ExclusiveAccessBubbleViews::UpdateForImmersiveState() {
msw 2016/05/16 17:17:13 optional nit: remove this, inline the UpdateMouseW
Matt Giuca 2016/05/17 00:52:34 Done.
478 AnimatedAttribute expected_animated_attribute = ExpectedAnimationAttribute();
479 if (animated_attribute_ != expected_animated_attribute) {
480 // If an animation is currently in progress, skip to the end because
481 // switching the animated attribute midway through the animation looks
482 // weird.
483 animation_->End();
484
485 animated_attribute_ = expected_animated_attribute;
486
487 // We may have finished hiding |popup_|. However, the bounds animation
488 // assumes |popup_| has the opacity when it is fully shown and the opacity
489 // animation assumes |popup_| has the bounds when |popup_| is fully shown.
490 if (animated_attribute_ == ANIMATED_ATTRIBUTE_BOUNDS)
491 popup_->SetOpacity(255);
492 else
493 UpdateBounds();
494 }
495
496 UpdateMouseWatcher(); 392 UpdateMouseWatcher();
497 } 393 }
498 394
499 void ExclusiveAccessBubbleViews::UpdateBounds() { 395 void ExclusiveAccessBubbleViews::UpdateBounds() {
500 gfx::Rect popup_rect(GetPopupRect(false)); 396 gfx::Rect popup_rect(GetPopupRect(false));
501 if (!popup_rect.IsEmpty()) { 397 if (!popup_rect.IsEmpty()) {
502 popup_->SetBounds(popup_rect); 398 popup_->SetBounds(popup_rect);
503 view_->SetY(popup_rect.height() - view_->height()); 399 view_->SetY(popup_rect.height() - view_->height());
504 } 400 }
505 } 401 }
506 402
507 views::View* ExclusiveAccessBubbleViews::GetBrowserRootView() const { 403 views::View* ExclusiveAccessBubbleViews::GetBrowserRootView() const {
508 return bubble_view_context_->GetBubbleAssociatedWidget()->GetRootView(); 404 return bubble_view_context_->GetBubbleAssociatedWidget()->GetRootView();
509 } 405 }
510 406
511 void ExclusiveAccessBubbleViews::AnimationProgressed( 407 void ExclusiveAccessBubbleViews::AnimationProgressed(
512 const gfx::Animation* animation) { 408 const gfx::Animation* animation) {
513 if (animated_attribute_ == ANIMATED_ATTRIBUTE_OPACITY) { 409 int opacity = animation_->CurrentValueBetween(0, 255);
514 int opacity = animation_->CurrentValueBetween(0, 255); 410 if (opacity == 0) {
515 if (opacity == 0) { 411 popup_->Hide();
516 popup_->Hide();
517 } else {
518 popup_->Show();
519 popup_->SetOpacity(opacity);
520 }
521 } else { 412 } else {
522 if (GetPopupRect(false).IsEmpty()) { 413 popup_->Show();
523 popup_->Hide(); 414 popup_->SetOpacity(opacity);
524 } else {
525 UpdateBounds();
526 popup_->Show();
527 }
528 } 415 }
529 } 416 }
530 417
531 void ExclusiveAccessBubbleViews::AnimationEnded( 418 void ExclusiveAccessBubbleViews::AnimationEnded(
532 const gfx::Animation* animation) { 419 const gfx::Animation* animation) {
533 AnimationProgressed(animation); 420 AnimationProgressed(animation);
534 } 421 }
535 422
536 gfx::Rect ExclusiveAccessBubbleViews::GetPopupRect( 423 gfx::Rect ExclusiveAccessBubbleViews::GetPopupRect(
537 bool ignore_animation_state) const { 424 bool ignore_animation_state) const {
(...skipping 12 matching lines...) Expand all
550 // fullscreen because entering fullscreen starts with the top container 437 // fullscreen because entering fullscreen starts with the top container
551 // revealed. When revealed, the top container has the same height as before 438 // revealed. When revealed, the top container has the same height as before
552 // entering fullscreen. 439 // entering fullscreen.
553 top_container_bottom = 440 top_container_bottom =
554 bubble_view_context_->GetTopContainerBoundsInScreen().bottom(); 441 bubble_view_context_->GetTopContainerBoundsInScreen().bottom();
555 } 442 }
556 // |desired_top| is the top of the bubble area including the shadow. 443 // |desired_top| is the top of the bubble area including the shadow.
557 int desired_top = kSimplifiedPopupTopPx - view_->border()->GetInsets().top(); 444 int desired_top = kSimplifiedPopupTopPx - view_->border()->GetInsets().top();
558 int y = top_container_bottom + desired_top; 445 int y = top_container_bottom + desired_top;
559 446
560 if (!ignore_animation_state &&
561 animated_attribute_ == ANIMATED_ATTRIBUTE_BOUNDS) {
562 int total_height = size.height() + desired_top;
563 int popup_bottom = animation_->CurrentValueBetween(total_height, 0);
564 int y_offset = std::min(popup_bottom, desired_top);
565 size.set_height(size.height() - popup_bottom + y_offset);
566 y -= y_offset;
567 }
568 return gfx::Rect(gfx::Point(x, y), size); 447 return gfx::Rect(gfx::Point(x, y), size);
569 } 448 }
570 449
571 gfx::Point ExclusiveAccessBubbleViews::GetCursorScreenPoint() { 450 gfx::Point ExclusiveAccessBubbleViews::GetCursorScreenPoint() {
572 return bubble_view_context_->GetCursorPointInParent(); 451 return bubble_view_context_->GetCursorPointInParent();
573 } 452 }
574 453
575 bool ExclusiveAccessBubbleViews::WindowContainsPoint(gfx::Point pos) { 454 bool ExclusiveAccessBubbleViews::WindowContainsPoint(gfx::Point pos) {
576 return GetBrowserRootView()->HitTestPoint(pos); 455 return GetBrowserRootView()->HitTestPoint(pos);
577 } 456 }
(...skipping 26 matching lines...) Expand all
604 const content::NotificationDetails& details) { 483 const content::NotificationDetails& details) {
605 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); 484 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type);
606 UpdateForImmersiveState(); 485 UpdateForImmersiveState();
607 } 486 }
608 487
609 void ExclusiveAccessBubbleViews::OnWidgetVisibilityChanged( 488 void ExclusiveAccessBubbleViews::OnWidgetVisibilityChanged(
610 views::Widget* widget, 489 views::Widget* widget,
611 bool visible) { 490 bool visible) {
612 UpdateMouseWatcher(); 491 UpdateMouseWatcher();
613 } 492 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/exclusive_access_bubble_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698