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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc

Issue 2074913002: Enable the translate bubble to be dismissed when user ignores it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/location_bar/location_bar_bubble_delegate_view .h" 5 #include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view .h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_finder.h" 9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
11 #include "chrome/browser/ui/layout_constants.h" 11 #include "chrome/browser/ui/layout_constants.h"
12 #include "content/public/browser/notification_source.h" 12 #include "content/public/browser/notification_source.h"
13 #include "content/public/browser/render_view_host.h"
13 #include "ui/base/material_design/material_design_controller.h" 14 #include "ui/base/material_design/material_design_controller.h"
14 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
15 16
17 LocationBarBubbleDelegateView::WebContentMouseHandler::WebContentMouseHandler(
18 LocationBarBubbleDelegateView* bubble,
19 content::WebContents* web_contents)
20 : bubble_(bubble), web_contents_(web_contents) {
21 DCHECK(bubble_);
22 DCHECK(web_contents_);
23 event_monitor_ = views::EventMonitor::CreateWindowMonitor(
24 this, web_contents_->GetTopLevelNativeWindow());
25 }
26
27 LocationBarBubbleDelegateView::WebContentMouseHandler::
28 ~WebContentMouseHandler() {}
29
30 void LocationBarBubbleDelegateView::WebContentMouseHandler::OnKeyEvent(
31 ui::KeyEvent* event) {
32 if ((event->key_code() == ui::VKEY_ESCAPE ||
33 web_contents_->GetRenderViewHost()->IsFocusedElementEditable()) &&
34 event->type() == ui::ET_KEY_PRESSED)
35 bubble_->CloseBubble();
36 }
37
38 void LocationBarBubbleDelegateView::WebContentMouseHandler::OnMouseEvent(
39 ui::MouseEvent* event) {
40 if (event->type() == ui::ET_MOUSE_PRESSED)
41 bubble_->CloseBubble();
42 }
43
44 void LocationBarBubbleDelegateView::WebContentMouseHandler::OnTouchEvent(
45 ui::TouchEvent* event) {
46 if (event->type() == ui::ET_TOUCH_PRESSED)
47 bubble_->CloseBubble();
48 }
49
16 LocationBarBubbleDelegateView::LocationBarBubbleDelegateView( 50 LocationBarBubbleDelegateView::LocationBarBubbleDelegateView(
17 views::View* anchor_view, 51 views::View* anchor_view,
18 content::WebContents* web_contents) 52 content::WebContents* web_contents)
19 : BubbleDialogDelegateView(anchor_view, 53 : BubbleDialogDelegateView(anchor_view,
20 anchor_view ? views::BubbleBorder::TOP_RIGHT 54 anchor_view ? views::BubbleBorder::TOP_RIGHT
21 : views::BubbleBorder::NONE) { 55 : views::BubbleBorder::NONE) {
22 // Add observer to close the bubble if the fullscreen state changes. 56 // Add observer to close the bubble if the fullscreen state changes.
23 if (web_contents) { 57 if (web_contents) {
24 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); 58 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
25 registrar_.Add( 59 registrar_.Add(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (GetAnchorView()) 102 if (GetAnchorView())
69 return; 103 return;
70 104
71 const int kBubblePaddingFromScreenEdge = 20; 105 const int kBubblePaddingFromScreenEdge = 20;
72 int horizontal_offset = width() / 2 + kBubblePaddingFromScreenEdge; 106 int horizontal_offset = width() / 2 + kBubblePaddingFromScreenEdge;
73 const int x_pos = base::i18n::IsRTL() 107 const int x_pos = base::i18n::IsRTL()
74 ? (screen_bounds.x() + horizontal_offset) 108 ? (screen_bounds.x() + horizontal_offset)
75 : (screen_bounds.right() - horizontal_offset); 109 : (screen_bounds.right() - horizontal_offset);
76 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); 110 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0));
77 } 111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698