| 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" |
| 9 #include "base/macros.h" | 10 #include "base/macros.h" |
| 10 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 11 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 11 #include "chrome/browser/chromeos/accessibility/chromevox_panel.h" | 12 #include "chrome/browser/chromeos/accessibility/chromevox_panel.h" |
| 12 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 13 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
| 13 #include "chrome/common/extensions/extension_constants.h" | 14 #include "chrome/common/extensions/extension_constants.h" |
| 14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 panel_->ExitFullscreen(); | 58 panel_->ExitFullscreen(); |
| 58 } | 59 } |
| 59 | 60 |
| 60 private: | 61 private: |
| 61 ChromeVoxPanel* panel_; | 62 ChromeVoxPanel* panel_; |
| 62 | 63 |
| 63 DISALLOW_COPY_AND_ASSIGN(ChromeVoxPanelWebContentsObserver); | 64 DISALLOW_COPY_AND_ASSIGN(ChromeVoxPanelWebContentsObserver); |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 ChromeVoxPanel::ChromeVoxPanel(content::BrowserContext* browser_context) | 67 ChromeVoxPanel::ChromeVoxPanel(content::BrowserContext* browser_context) |
| 67 : widget_(nullptr), web_view_(nullptr), fullscreen_(false) { | 68 : widget_(nullptr), web_view_(nullptr), panel_fullscreen_(false) { |
| 68 std::string url("chrome-extension://"); | 69 std::string url("chrome-extension://"); |
| 69 url += extension_misc::kChromeVoxExtensionId; | 70 url += extension_misc::kChromeVoxExtensionId; |
| 70 url += kChromeVoxPanelRelativeUrl; | 71 url += kChromeVoxPanelRelativeUrl; |
| 71 | 72 |
| 72 views::WebView* web_view = new views::WebView(browser_context); | 73 views::WebView* web_view = new views::WebView(browser_context); |
| 73 content::WebContents* contents = web_view->GetWebContents(); | 74 content::WebContents* contents = web_view->GetWebContents(); |
| 74 web_contents_observer_.reset( | 75 web_contents_observer_.reset( |
| 75 new ChromeVoxPanelWebContentsObserver(contents, this)); | 76 new ChromeVoxPanelWebContentsObserver(contents, this)); |
| 76 extensions::SetViewType(contents, extensions::VIEW_TYPE_COMPONENT); | 77 extensions::SetViewType(contents, extensions::VIEW_TYPE_COMPONENT); |
| 77 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( | 78 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 if (!shelf) | 118 if (!shelf) |
| 118 return; | 119 return; |
| 119 | 120 |
| 120 ash::ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); | 121 ash::ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); |
| 121 if (shelf_layout_manager) | 122 if (shelf_layout_manager) |
| 122 shelf_layout_manager->SetChromeVoxPanelHeight(kPanelHeight); | 123 shelf_layout_manager->SetChromeVoxPanelHeight(kPanelHeight); |
| 123 } | 124 } |
| 124 | 125 |
| 125 void ChromeVoxPanel::EnterFullscreen() { | 126 void ChromeVoxPanel::EnterFullscreen() { |
| 126 Focus(); | 127 Focus(); |
| 127 fullscreen_ = true; | 128 panel_fullscreen_ = true; |
| 128 UpdateWidgetBounds(); | 129 UpdateWidgetBounds(); |
| 129 } | 130 } |
| 130 | 131 |
| 131 void ChromeVoxPanel::ExitFullscreen() { | 132 void ChromeVoxPanel::ExitFullscreen() { |
| 133 widget_->Deactivate(); |
| 132 widget_->widget_delegate()->set_can_activate(false); | 134 widget_->widget_delegate()->set_can_activate(false); |
| 133 fullscreen_ = false; | 135 panel_fullscreen_ = false; |
| 134 UpdateWidgetBounds(); | 136 UpdateWidgetBounds(); |
| 135 } | 137 } |
| 136 | 138 |
| 137 void ChromeVoxPanel::DisableSpokenFeedback() { | 139 void ChromeVoxPanel::DisableSpokenFeedback() { |
| 138 chromeos::AccessibilityManager::Get()->EnableSpokenFeedback( | 140 chromeos::AccessibilityManager::Get()->EnableSpokenFeedback( |
| 139 false, ui::A11Y_NOTIFICATION_NONE); | 141 false, ui::A11Y_NOTIFICATION_NONE); |
| 140 } | 142 } |
| 141 | 143 |
| 142 void ChromeVoxPanel::Focus() { | 144 void ChromeVoxPanel::Focus() { |
| 143 widget_->widget_delegate()->set_can_activate(true); | 145 widget_->widget_delegate()->set_can_activate(true); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 161 return web_view_; | 163 return web_view_; |
| 162 } | 164 } |
| 163 | 165 |
| 164 void ChromeVoxPanel::OnDisplayMetricsChanged(const gfx::Display& display, | 166 void ChromeVoxPanel::OnDisplayMetricsChanged(const gfx::Display& display, |
| 165 uint32_t changed_metrics) { | 167 uint32_t changed_metrics) { |
| 166 UpdateWidgetBounds(); | 168 UpdateWidgetBounds(); |
| 167 } | 169 } |
| 168 | 170 |
| 169 void ChromeVoxPanel::UpdateWidgetBounds() { | 171 void ChromeVoxPanel::UpdateWidgetBounds() { |
| 170 gfx::Rect bounds(GetRootWindow()->bounds().size()); | 172 gfx::Rect bounds(GetRootWindow()->bounds().size()); |
| 171 if (!fullscreen_) | 173 if (!panel_fullscreen_) |
| 172 bounds.set_height(kPanelHeight); | 174 bounds.set_height(kPanelHeight); |
| 175 |
| 176 // If we're in full-screen mode, give the panel a height of 0 unless |
| 177 // it's active. |
| 178 if (ash::GetRootWindowController(GetRootWindow()) |
| 179 ->GetWindowForFullscreenMode() && |
| 180 !widget_->IsActive()) { |
| 181 bounds.set_height(0); |
| 182 } |
| 183 |
| 173 widget_->SetBounds(bounds); | 184 widget_->SetBounds(bounds); |
| 174 } | 185 } |
| OLD | NEW |