OLD | NEW |
---|---|
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 "chrome/browser/ui/views/extensions/shell_window_views.h" | 5 #include "chrome/browser/ui/views/extensions/shell_window_views.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
9 #include "chrome/common/extensions/draggable_region.h" | 9 #include "chrome/common/extensions/draggable_region.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 #endif | 329 #endif |
330 OnViewWasResized(); | 330 OnViewWasResized(); |
331 | 331 |
332 window_->Show(); | 332 window_->Show(); |
333 } | 333 } |
334 | 334 |
335 views::View* ShellWindowViews::GetInitiallyFocusedView() { | 335 views::View* ShellWindowViews::GetInitiallyFocusedView() { |
336 return web_view_; | 336 return web_view_; |
337 } | 337 } |
338 | 338 |
339 bool ShellWindowViews::ShouldDescendIntoChildForEventHandling( | |
340 aura::Window* child, | |
341 const gfx::Point& event_location, | |
342 ui::EventType event_type) { | |
343 DCHECK_EQ(child, web_view_->web_contents()->GetView()->GetNativeView()); | |
Ben Goodger (Google)
2012/08/21 02:17:40
the body of this function needs to be #ifdef USE_A
jianli
2012/08/21 17:22:00
Done.
| |
344 // Shell window should claim mouse click/drag events that fall within the | |
345 // draggable region. | |
346 return !draggable_region_.get() || | |
347 !draggable_region_->contains(event_location.x(), event_location.y()) || | |
348 (event_type != ui::ET_MOUSE_PRESSED && | |
Ben Goodger (Google)
2012/08/21 02:17:40
I don't understand why the need to filter on event
| |
349 event_type != ui::ET_MOUSE_DRAGGED && | |
350 event_type != ui::ET_MOUSE_RELEASED); | |
351 } | |
352 | |
339 void ShellWindowViews::OnFocus() { | 353 void ShellWindowViews::OnFocus() { |
340 web_view_->RequestFocus(); | 354 web_view_->RequestFocus(); |
341 } | 355 } |
342 | 356 |
343 void ShellWindowViews::ViewHierarchyChanged( | 357 void ShellWindowViews::ViewHierarchyChanged( |
344 bool is_add, views::View *parent, views::View *child) { | 358 bool is_add, views::View *parent, views::View *child) { |
345 if (is_add && child == this) { | 359 if (is_add && child == this) { |
346 web_view_ = new views::WebView(NULL); | 360 web_view_ = new views::WebView(NULL); |
347 AddChildView(web_view_); | 361 AddChildView(web_view_); |
348 web_view_->SetWebContents(web_contents()); | 362 web_view_->SetWebContents(web_contents()); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 return window_; | 497 return window_; |
484 } | 498 } |
485 | 499 |
486 const views::Widget* ShellWindowViews::GetWidget() const { | 500 const views::Widget* ShellWindowViews::GetWidget() const { |
487 return window_; | 501 return window_; |
488 } | 502 } |
489 | 503 |
490 void ShellWindowViews::OnViewWasResized() { | 504 void ShellWindowViews::OnViewWasResized() { |
491 // TODO(jeremya): this doesn't seem like a terribly elegant way to keep the | 505 // TODO(jeremya): this doesn't seem like a terribly elegant way to keep the |
492 // window shape in sync. | 506 // window shape in sync. |
493 #if defined(OS_WIN) && !defined(USE_AURA) | 507 #if defined(OS_WIN) && !defined(USE_ASH) |
494 // Set the window shape of the RWHV. | 508 // Set the window shape of the RWHV. |
495 DCHECK(window_); | 509 DCHECK(window_); |
496 DCHECK(web_view_); | 510 DCHECK(web_view_); |
497 gfx::Size sz = web_view_->size(); | 511 gfx::Size sz = web_view_->size(); |
498 int height = sz.height(), width = sz.width(); | 512 int height = sz.height(), width = sz.width(); |
499 int radius = 1; | 513 int radius = 1; |
500 gfx::Path path; | 514 gfx::Path path; |
501 if (window_->IsMaximized() || window_->IsFullscreen()) { | 515 if (window_->IsMaximized() || window_->IsFullscreen()) { |
502 // Don't round the corners when the window is maximized or fullscreen. | 516 // Don't round the corners when the window is maximized or fullscreen. |
503 path.addRect(0, 0, width, height); | 517 path.addRect(0, 0, width, height); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 | 590 |
577 draggable_region_.reset(draggable_region); | 591 draggable_region_.reset(draggable_region); |
578 OnViewWasResized(); | 592 OnViewWasResized(); |
579 } | 593 } |
580 | 594 |
581 // static | 595 // static |
582 NativeShellWindow* NativeShellWindow::Create( | 596 NativeShellWindow* NativeShellWindow::Create( |
583 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { | 597 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { |
584 return new ShellWindowViews(shell_window, params); | 598 return new ShellWindowViews(shell_window, params); |
585 } | 599 } |
OLD | NEW |