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

Side by Side Diff: chrome/browser/renderer_host/render_widget_host_view_win.cc

Issue 2720003: Relanding 49339 ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/renderer_host/render_widget_host_view_win.h" 5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/l10n_util_win.h" 8 #include "app/l10n_util_win.h"
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 backing_store_dc, 245 backing_store_dc,
246 paint_rect.x(), 246 paint_rect.x(),
247 paint_rect.y(), 247 paint_rect.y(),
248 SRCCOPY); 248 SRCCOPY);
249 canvas.endPlatformPaint(); 249 canvas.endPlatformPaint();
250 // 178 is 70% grey. 250 // 178 is 70% grey.
251 canvas.FillRectInt(SkColorSetARGB(178, 0, 0, 0), 0, 0, 251 canvas.FillRectInt(SkColorSetARGB(178, 0, 0, 0), 0, 0,
252 paint_rect.width(), paint_rect.height()); 252 paint_rect.width(), paint_rect.height());
253 canvas.getTopPlatformDevice().drawToHDC(paint_dc, paint_rect.x(), 253 canvas.getTopPlatformDevice().drawToHDC(paint_dc, paint_rect.x(),
254 paint_rect.y(), NULL); 254 paint_rect.y(), NULL);
255
256 } 255 }
257 256
258 } // namespace 257 } // namespace
259 258
260 // RenderWidgetHostView -------------------------------------------------------- 259 // RenderWidgetHostView --------------------------------------------------------
261 260
262 // static 261 // static
263 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( 262 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
264 RenderWidgetHost* widget) { 263 RenderWidgetHost* widget) {
265 return new RenderWidgetHostViewWin(widget); 264 return new RenderWidgetHostViewWin(widget);
(...skipping 11 matching lines...) Expand all
277 about_to_validate_and_paint_(false), 276 about_to_validate_and_paint_(false),
278 close_on_deactivate_(false), 277 close_on_deactivate_(false),
279 being_destroyed_(false), 278 being_destroyed_(false),
280 tooltip_hwnd_(NULL), 279 tooltip_hwnd_(NULL),
281 tooltip_showing_(false), 280 tooltip_showing_(false),
282 shutdown_factory_(this), 281 shutdown_factory_(this),
283 parent_hwnd_(NULL), 282 parent_hwnd_(NULL),
284 is_loading_(false), 283 is_loading_(false),
285 visually_deemphasized_(false) { 284 visually_deemphasized_(false) {
286 render_widget_host_->set_view(this); 285 render_widget_host_->set_view(this);
287 renderer_accessible_ =
288 CommandLine::ForCurrentProcess()->HasSwitch(
289 switches::kEnableRendererAccessibility);
290 registrar_.Add(this, 286 registrar_.Add(this,
291 NotificationType::RENDERER_PROCESS_TERMINATED, 287 NotificationType::RENDERER_PROCESS_TERMINATED,
292 NotificationService::AllSources()); 288 NotificationService::AllSources());
289
290 BOOL screenreader_running = FALSE;
291 if (SystemParametersInfo(SPI_GETSCREENREADER, 0, &screenreader_running, 0) &&
292 screenreader_running) {
293 render_widget_host_->EnableRendererAccessibility();
294 }
293 } 295 }
294 296
295 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { 297 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() {
296 ResetTooltip(); 298 ResetTooltip();
297 } 299 }
298 300
299 void RenderWidgetHostViewWin::CreateWnd(HWND parent) { 301 void RenderWidgetHostViewWin::CreateWnd(HWND parent) {
300 Create(parent); // ATL function to create the window. 302 Create(parent); // ATL function to create the window.
301 303
302 // Add a property indicating that a particular renderer is associated with 304 // Add a property indicating that a particular renderer is associated with
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 } 1478 }
1477 } 1479 }
1478 handled = FALSE; 1480 handled = FALSE;
1479 return MA_ACTIVATE; 1481 return MA_ACTIVATE;
1480 } 1482 }
1481 1483
1482 void RenderWidgetHostViewWin::UpdateAccessibilityTree( 1484 void RenderWidgetHostViewWin::UpdateAccessibilityTree(
1483 const webkit_glue::WebAccessibility& tree) { 1485 const webkit_glue::WebAccessibility& tree) {
1484 browser_accessibility_manager_.reset( 1486 browser_accessibility_manager_.reset(
1485 new BrowserAccessibilityManager(m_hWnd, tree, this)); 1487 new BrowserAccessibilityManager(m_hWnd, tree, this));
1488
1489 ::NotifyWinEvent(
1490 IA2_EVENT_DOCUMENT_LOAD_COMPLETE, m_hWnd, OBJID_CLIENT, CHILDID_SELF);
1486 } 1491 }
1487 1492
1488 void RenderWidgetHostViewWin::OnAccessibilityFocusChange(int acc_obj_id) { 1493 void RenderWidgetHostViewWin::OnAccessibilityFocusChange(int acc_obj_id) {
1489 if (browser_accessibility_manager_.get()) { 1494 if (browser_accessibility_manager_.get()) {
1490 browser_accessibility_manager_->OnAccessibilityFocusChange(acc_obj_id); 1495 browser_accessibility_manager_->OnAccessibilityFocusChange(acc_obj_id);
1491 } 1496 }
1492 } 1497 }
1493 1498
1494 void RenderWidgetHostViewWin::OnAccessibilityObjectStateChange(int acc_obj_id) { 1499 void RenderWidgetHostViewWin::OnAccessibilityObjectStateChange(int acc_obj_id) {
1495 if (browser_accessibility_manager_.get()) { 1500 if (browser_accessibility_manager_.get()) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 !render_widget_host_->process() || 1540 !render_widget_host_->process() ||
1536 !render_widget_host_->process()->HasConnection()) { 1541 !render_widget_host_->process()->HasConnection()) {
1537 return; 1542 return;
1538 } 1543 }
1539 1544
1540 render_widget_host_->AccessibilityDoDefaultAction(acc_obj_id); 1545 render_widget_host_->AccessibilityDoDefaultAction(acc_obj_id);
1541 } 1546 }
1542 1547
1543 LRESULT RenderWidgetHostViewWin::OnGetObject(UINT message, WPARAM wparam, 1548 LRESULT RenderWidgetHostViewWin::OnGetObject(UINT message, WPARAM wparam,
1544 LPARAM lparam, BOOL& handled) { 1549 LPARAM lparam, BOOL& handled) {
1545 // TODO(dmazzoni): http://crbug.com/25564 Disabling accessibility in the 1550 if (lparam != OBJID_CLIENT) {
1546 // renderer is a temporary work-around until that bug is fixed.
1547 if (!renderer_accessible_) {
1548 handled = false; 1551 handled = false;
1549 return static_cast<LRESULT>(0L); 1552 return static_cast<LRESULT>(0L);
1550 } 1553 }
1551 1554
1552 if (lparam == OBJID_CLIENT && browser_accessibility_manager_.get()) { 1555 if (!browser_accessibility_manager_.get()) {
1556 render_widget_host_->EnableRendererAccessibility();
1557
1558 if (!loading_accessible_.get()) {
1559 // Create IAccessible to return while waiting for the accessibility tree
1560 // from the renderer.
1561 HRESULT hr = ::CreateStdAccessibleObject(
1562 m_hWnd, OBJID_CLIENT, IID_IAccessible,
1563 reinterpret_cast<void **>(&loading_accessible_));
1564
1565 // Annotate with STATE_SYSTEM_BUSY to indicate that the page is loading.
1566 // We annotate the HWND, not the loading_accessible IAccessible, but the
1567 // IAccessible will reflect the state annotation.
1568 ScopedComPtr<IAccPropServices> pAccPropServices;
1569 hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER,
1570 IID_IAccPropServices, reinterpret_cast<void**>(&pAccPropServices));
1571 if (SUCCEEDED(hr)) {
1572 VARIANT var;
1573 var.vt = VT_I4;
1574 var.lVal = STATE_SYSTEM_BUSY;
1575 pAccPropServices->SetHwndProp(m_hWnd, OBJID_CLIENT,
1576 CHILDID_SELF, PROPID_ACC_STATE, var);
1577 }
1578 }
1579
1580 if (loading_accessible_.get()) {
1581 return LresultFromObject(
1582 IID_IAccessible, wparam,
1583 static_cast<IAccessible*>(loading_accessible_));
1584 }
1585 } else {
1553 BrowserAccessibility* root = browser_accessibility_manager_->GetRoot(); 1586 BrowserAccessibility* root = browser_accessibility_manager_->GetRoot();
1554 if (root) { 1587 if (root) {
1555 return LresultFromObject(IID_IAccessible, wparam, 1588 return LresultFromObject(IID_IAccessible, wparam,
1556 static_cast<IAccessible*>(root->NewReference())); 1589 static_cast<IAccessible*>(root->NewReference()));
1557 } 1590 }
1558 } 1591 }
1559 1592
1560 handled = false; 1593 handled = false;
1561 return static_cast<LRESULT>(0L); 1594 return static_cast<LRESULT>(0L);
1562 } 1595 }
1563 1596
1564 void RenderWidgetHostViewWin::OnFinalMessage(HWND window) { 1597 void RenderWidgetHostViewWin::OnFinalMessage(HWND window) {
1565 // When the render widget host is being destroyed, it ends up calling 1598 // When the render widget host is being destroyed, it ends up calling
1566 // WillDestroyRenderWidget (through the RENDER_WIDGET_HOST_DESTROYED 1599 // WillDestroyRenderWidget (through the RENDER_WIDGET_HOST_DESTROYED
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( 1714 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView(
1682 gfx::NativeView native_view) { 1715 gfx::NativeView native_view) {
1683 if (::IsWindow(native_view)) { 1716 if (::IsWindow(native_view)) {
1684 HANDLE raw_render_host_view = ::GetProp(native_view, 1717 HANDLE raw_render_host_view = ::GetProp(native_view,
1685 kRenderWidgetHostViewKey); 1718 kRenderWidgetHostViewKey);
1686 if (raw_render_host_view) 1719 if (raw_render_host_view)
1687 return reinterpret_cast<RenderWidgetHostView*>(raw_render_host_view); 1720 return reinterpret_cast<RenderWidgetHostView*>(raw_render_host_view);
1688 } 1721 }
1689 return NULL; 1722 return NULL;
1690 } 1723 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_win.h ('k') | chrome/browser/tab_contents/tab_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698