OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/root_window_controller.h" | |
5 #include "ash/shelf/shelf.h" | 6 #include "ash/shelf/shelf.h" |
6 #include "ash/shelf/shelf_layout_manager.h" | 7 #include "ash/shelf/shelf_layout_manager.h" |
7 #include "ash/shell.h" | 8 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/wm/window_state.h" | |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 12 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
11 #include "chrome/browser/chromeos/accessibility/chromevox_panel.h" | 13 #include "chrome/browser/chromeos/accessibility/chromevox_panel.h" |
12 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 14 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
13 #include "chrome/common/extensions/extension_constants.h" | 15 #include "chrome/common/extensions/extension_constants.h" |
14 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
15 #include "extensions/browser/view_type_utils.h" | 17 #include "extensions/browser/view_type_utils.h" |
16 #include "ui/chromeos/accessibility_types.h" | 18 #include "ui/chromeos/accessibility_types.h" |
17 #include "ui/views/controls/webview/webview.h" | 19 #include "ui/views/controls/webview/webview.h" |
18 #include "ui/views/layout/fill_layout.h" | 20 #include "ui/views/layout/fill_layout.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 panel_->ExitFullscreen(); | 59 panel_->ExitFullscreen(); |
58 } | 60 } |
59 | 61 |
60 private: | 62 private: |
61 ChromeVoxPanel* panel_; | 63 ChromeVoxPanel* panel_; |
62 | 64 |
63 DISALLOW_COPY_AND_ASSIGN(ChromeVoxPanelWebContentsObserver); | 65 DISALLOW_COPY_AND_ASSIGN(ChromeVoxPanelWebContentsObserver); |
64 }; | 66 }; |
65 | 67 |
66 ChromeVoxPanel::ChromeVoxPanel(content::BrowserContext* browser_context) | 68 ChromeVoxPanel::ChromeVoxPanel(content::BrowserContext* browser_context) |
67 : widget_(nullptr), web_view_(nullptr), fullscreen_(false) { | 69 : widget_(nullptr), web_view_(nullptr), panel_fullscreen_(false) { |
68 std::string url("chrome-extension://"); | 70 std::string url("chrome-extension://"); |
69 url += extension_misc::kChromeVoxExtensionId; | 71 url += extension_misc::kChromeVoxExtensionId; |
70 url += kChromeVoxPanelRelativeUrl; | 72 url += kChromeVoxPanelRelativeUrl; |
71 | 73 |
72 views::WebView* web_view = new views::WebView(browser_context); | 74 views::WebView* web_view = new views::WebView(browser_context); |
73 content::WebContents* contents = web_view->GetWebContents(); | 75 content::WebContents* contents = web_view->GetWebContents(); |
74 web_contents_observer_.reset( | 76 web_contents_observer_.reset( |
75 new ChromeVoxPanelWebContentsObserver(contents, this)); | 77 new ChromeVoxPanelWebContentsObserver(contents, this)); |
76 extensions::SetViewType(contents, extensions::VIEW_TYPE_COMPONENT); | 78 extensions::SetViewType(contents, extensions::VIEW_TYPE_COMPONENT); |
77 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( | 79 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 if (!shelf) | 119 if (!shelf) |
118 return; | 120 return; |
119 | 121 |
120 ash::ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); | 122 ash::ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); |
121 if (shelf_layout_manager) | 123 if (shelf_layout_manager) |
122 shelf_layout_manager->SetChromeVoxPanelHeight(kPanelHeight); | 124 shelf_layout_manager->SetChromeVoxPanelHeight(kPanelHeight); |
123 } | 125 } |
124 | 126 |
125 void ChromeVoxPanel::EnterFullscreen() { | 127 void ChromeVoxPanel::EnterFullscreen() { |
126 Focus(); | 128 Focus(); |
127 fullscreen_ = true; | 129 panel_fullscreen_ = true; |
128 UpdateWidgetBounds(); | 130 UpdateWidgetBounds(); |
129 } | 131 } |
130 | 132 |
131 void ChromeVoxPanel::ExitFullscreen() { | 133 void ChromeVoxPanel::ExitFullscreen() { |
134 widget_->Deactivate(); | |
132 widget_->widget_delegate()->set_can_activate(false); | 135 widget_->widget_delegate()->set_can_activate(false); |
133 fullscreen_ = false; | 136 panel_fullscreen_ = false; |
134 UpdateWidgetBounds(); | 137 UpdateWidgetBounds(); |
135 } | 138 } |
136 | 139 |
137 void ChromeVoxPanel::DisableSpokenFeedback() { | 140 void ChromeVoxPanel::DisableSpokenFeedback() { |
138 chromeos::AccessibilityManager::Get()->EnableSpokenFeedback( | 141 chromeos::AccessibilityManager::Get()->EnableSpokenFeedback( |
139 false, ui::A11Y_NOTIFICATION_NONE); | 142 false, ui::A11Y_NOTIFICATION_NONE); |
140 } | 143 } |
141 | 144 |
142 void ChromeVoxPanel::Focus() { | 145 void ChromeVoxPanel::Focus() { |
143 widget_->widget_delegate()->set_can_activate(true); | 146 widget_->widget_delegate()->set_can_activate(true); |
(...skipping 17 matching lines...) Expand all Loading... | |
161 return web_view_; | 164 return web_view_; |
162 } | 165 } |
163 | 166 |
164 void ChromeVoxPanel::OnDisplayMetricsChanged(const gfx::Display& display, | 167 void ChromeVoxPanel::OnDisplayMetricsChanged(const gfx::Display& display, |
165 uint32_t changed_metrics) { | 168 uint32_t changed_metrics) { |
166 UpdateWidgetBounds(); | 169 UpdateWidgetBounds(); |
167 } | 170 } |
168 | 171 |
169 void ChromeVoxPanel::UpdateWidgetBounds() { | 172 void ChromeVoxPanel::UpdateWidgetBounds() { |
170 gfx::Rect bounds(GetRootWindow()->bounds().size()); | 173 gfx::Rect bounds(GetRootWindow()->bounds().size()); |
171 if (!fullscreen_) | 174 if (!panel_fullscreen_) |
172 bounds.set_height(kPanelHeight); | 175 bounds.set_height(kPanelHeight); |
176 | |
177 // If we're in full-screen mode, give the panel a height of 0 unless | |
178 // it's active. | |
179 const aura::Window* fullscreen_window = | |
180 ash::GetRootWindowController(GetRootWindow()) | |
181 ->GetWindowForFullscreenMode(); | |
182 if (fullscreen_window && | |
183 ash::wm::GetWindowState(fullscreen_window)->IsFullscreen() && | |
xiyuan
2016/03/30 16:08:02
nit: Is checking IsFullscreen() necessary? |fullsc
dmazzoni
2016/03/31 15:25:56
Ah, thanks. I misinterpreted and thought it return
| |
184 !widget_->IsActive()) { | |
185 bounds.set_height(0); | |
186 } | |
187 | |
173 widget_->SetBounds(bounds); | 188 widget_->SetBounds(bounds); |
174 } | 189 } |
OLD | NEW |