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

Side by Side Diff: ash/keyboard_overlay/keyboard_overlay_view.cc

Issue 461093003: Fix the bug of multiple overlays. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win fix Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ash/first_run/first_run_helper_impl.cc ('k') | ash/test/test_overlay_delegate.h » ('j') | 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 "ash/keyboard_overlay/keyboard_overlay_view.h" 5 #include "ash/keyboard_overlay/keyboard_overlay_view.h"
6 6
7 #include "ash/keyboard_overlay/keyboard_overlay_delegate.h" 7 #include "ash/keyboard_overlay/keyboard_overlay_delegate.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 25 matching lines...) Expand all
36 content::BrowserContext* context, 36 content::BrowserContext* context,
37 WebDialogDelegate* delegate, 37 WebDialogDelegate* delegate,
38 WebContentsHandler* handler) 38 WebContentsHandler* handler)
39 : views::WebDialogView(context, delegate, handler) { 39 : views::WebDialogView(context, delegate, handler) {
40 } 40 }
41 41
42 KeyboardOverlayView::~KeyboardOverlayView() { 42 KeyboardOverlayView::~KeyboardOverlayView() {
43 } 43 }
44 44
45 void KeyboardOverlayView::Cancel() { 45 void KeyboardOverlayView::Cancel() {
46 Shell::GetInstance()->overlay_filter()->Deactivate(); 46 Shell::GetInstance()->overlay_filter()->Deactivate(this);
47 views::Widget* widget = GetWidget(); 47 views::Widget* widget = GetWidget();
48 if (widget) 48 if (widget)
49 widget->Close(); 49 widget->Close();
50 } 50 }
51 51
52 bool KeyboardOverlayView::IsCancelingKeyEvent(ui::KeyEvent* event) { 52 bool KeyboardOverlayView::IsCancelingKeyEvent(ui::KeyEvent* event) {
53 if (event->type() != ui::ET_KEY_PRESSED) 53 if (event->type() != ui::ET_KEY_PRESSED)
54 return false; 54 return false;
55 // Ignore the caps lock state. 55 // Ignore the caps lock state.
56 const int flags = (event->flags() & ~ui::EF_CAPS_LOCK_DOWN); 56 const int flags = (event->flags() & ~ui::EF_CAPS_LOCK_DOWN);
57 for (size_t i = 0; i < arraysize(kCancelKeys); ++i) { 57 for (size_t i = 0; i < arraysize(kCancelKeys); ++i) {
58 if ((kCancelKeys[i].key_code == event->key_code()) && 58 if ((kCancelKeys[i].key_code == event->key_code()) &&
59 (kCancelKeys[i].flags == flags)) 59 (kCancelKeys[i].flags == flags))
60 return true; 60 return true;
61 } 61 }
62 return false; 62 return false;
63 } 63 }
64 64
65 aura::Window* KeyboardOverlayView::GetWindow() { 65 aura::Window* KeyboardOverlayView::GetWindow() {
66 return GetWidget()->GetNativeWindow(); 66 return GetWidget()->GetNativeWindow();
67 } 67 }
68 68
69 // static
69 void KeyboardOverlayView::ShowDialog( 70 void KeyboardOverlayView::ShowDialog(
70 content::BrowserContext* context, 71 content::BrowserContext* context,
71 WebContentsHandler* handler, 72 WebContentsHandler* handler,
72 const GURL& url) { 73 const GURL& url) {
74 if (Shell::GetInstance()->overlay_filter()->IsActive())
75 return;
76
73 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( 77 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate(
74 l10n_util::GetStringUTF16(IDS_ASH_KEYBOARD_OVERLAY_TITLE), url); 78 l10n_util::GetStringUTF16(IDS_ASH_KEYBOARD_OVERLAY_TITLE), url);
75 KeyboardOverlayView* view = 79 KeyboardOverlayView* view =
76 new KeyboardOverlayView(context, delegate, handler); 80 new KeyboardOverlayView(context, delegate, handler);
77 delegate->Show(view); 81 delegate->Show(view);
78 82
79 Shell::GetInstance()->overlay_filter()->Activate(view); 83 Shell::GetInstance()->overlay_filter()->Activate(view);
80 } 84 }
81 85
82 void KeyboardOverlayView::WindowClosing() { 86 void KeyboardOverlayView::WindowClosing() {
83 Cancel(); 87 Cancel();
84 } 88 }
85 89
86 // static 90 // static
87 void KeyboardOverlayView::GetCancelingKeysForTesting( 91 void KeyboardOverlayView::GetCancelingKeysForTesting(
88 std::vector<KeyboardOverlayView::KeyEventData>* canceling_keys) { 92 std::vector<KeyboardOverlayView::KeyEventData>* canceling_keys) {
89 CHECK(canceling_keys); 93 CHECK(canceling_keys);
90 canceling_keys->clear(); 94 canceling_keys->clear();
91 for (size_t i = 0; i < arraysize(kCancelKeys); ++i) 95 for (size_t i = 0; i < arraysize(kCancelKeys); ++i)
92 canceling_keys->push_back(kCancelKeys[i]); 96 canceling_keys->push_back(kCancelKeys[i]);
93 } 97 }
94 98
95 } // namespace ash 99 } // namespace ash
OLDNEW
« no previous file with comments | « ash/first_run/first_run_helper_impl.cc ('k') | ash/test/test_overlay_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698