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

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

Issue 795053003: [Password Manager] Close the bubble when fullscreen state gets change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/managed_full_screen_bubble_delegate_view.h"
6
7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
11 #include "content/public/browser/notification_source.h"
12 #include "content/public/browser/web_contents.h"
vasilii 2014/12/17 13:40:12 Is it needed?
Pritam Nikam 2014/12/17 16:06:26 Done.
13 #include "ui/gfx/geometry/rect.h"
14
15 ManagedFullScreenBubbleDelegateView::ManagedFullScreenBubbleDelegateView(
16 views::View* anchor_view,
17 content::WebContents* web_contents)
18 : BubbleDelegateView(anchor_view,
19 anchor_view ? views::BubbleBorder::TOP_RIGHT
20 : views::BubbleBorder::NONE) {
21 // Register accelerator key F11.
22 AddAccelerator(ui::Accelerator(ui::VKEY_F11, ui::EF_NONE));
vasilii 2014/12/17 13:40:11 Why do we need it?
Pritam Nikam 2014/12/17 16:06:26 Cases where bubble view is having focus, F11 wont
vasilii 2014/12/18 16:16:22 Indeed, but closing the bubble on F11 isn't what u
23
24 // Add observers to close the bubble if the fullscreen state changes.
25 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
26 registrar_.Add(
27 this, chrome::NOTIFICATION_FULLSCREEN_CHANGED,
28 content::Source<FullscreenController>(browser->fullscreen_controller()));
29 }
30
31 ManagedFullScreenBubbleDelegateView::~ManagedFullScreenBubbleDelegateView() {
32 }
33
34 void ManagedFullScreenBubbleDelegateView::AdjustForFullscreen(
vasilii 2014/12/17 13:40:11 Order of definitions should match the order of dec
Pritam Nikam 2014/12/17 16:06:26 Done.
35 const gfx::Rect& screen_bounds) {
36 if (GetAnchorView())
37 return;
38
39 // The bubble's padding from the screen edge, used in fullscreen.
40 const int kFullscreenPaddingEnd = 20;
vasilii 2014/12/17 13:40:12 the constant should go to the beginning of the fil
Pritam Nikam 2014/12/17 16:06:26 Done.
41 const size_t bubble_half_width = width() / 2;
vasilii 2014/12/17 13:40:11 should be int.
Pritam Nikam 2014/12/17 16:06:26 Done.
42 const int x_pos =
43 base::i18n::IsRTL()
44 ? screen_bounds.x() + bubble_half_width + kFullscreenPaddingEnd
45 : screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd;
46 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0));
47 }
48
49 void ManagedFullScreenBubbleDelegateView::Observe(
50 int type,
51 const content::NotificationSource& source,
52 const content::NotificationDetails& details) {
53 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED);
54 GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE);
55 Close();
56 }
57
58 void ManagedFullScreenBubbleDelegateView::Close() {
59 GetWidget()->Close();
60 }
61
62 bool ManagedFullScreenBubbleDelegateView::AcceleratorPressed(
63 const ui::Accelerator& accelerator) {
64 if (accelerator.key_code() == ui::VKEY_F11) {
65 Close();
vasilii 2014/12/17 13:40:11 Why would F11 close the bubble?
Pritam Nikam 2014/12/17 16:06:26 I'm not sure whether we should close the bubble or
66 return true;
67 }
68
69 return BubbleDelegateView::AcceleratorPressed(accelerator);
70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698