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

Side by Side Diff: chrome/browser/ui/views/extensions/shell_window_views.cc

Issue 11028125: Remove legacy draggable region code and refactor to share common draggable region code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Created 8 years, 2 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) 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/browser/favicon/favicon_tab_helper.h" 9 #include "chrome/browser/favicon/favicon_tab_helper.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents.h"
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 void ShellWindowViews::UpdateWindowTitle() { 621 void ShellWindowViews::UpdateWindowTitle() {
622 window_->UpdateWindowTitle(); 622 window_->UpdateWindowTitle();
623 } 623 }
624 624
625 void ShellWindowViews::UpdateDraggableRegions( 625 void ShellWindowViews::UpdateDraggableRegions(
626 const std::vector<extensions::DraggableRegion>& regions) { 626 const std::vector<extensions::DraggableRegion>& regions) {
627 // Draggable region is not supported for non-frameless window. 627 // Draggable region is not supported for non-frameless window.
628 if (!frameless_) 628 if (!frameless_)
629 return; 629 return;
630 630
631 SkRegion* draggable_region = new SkRegion; 631 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions));
632
633 // By default, the whole window is non-draggable. We need to explicitly
634 // include those draggable regions.
635 for (std::vector<extensions::DraggableRegion>::const_iterator iter =
636 regions.begin();
637 iter != regions.end(); ++iter) {
638 const extensions::DraggableRegion& region = *iter;
639 draggable_region->op(
640 region.bounds.x(),
641 region.bounds.y(),
642 region.bounds.right(),
643 region.bounds.bottom(),
644 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
645 }
646
647 draggable_region_.reset(draggable_region);
648 OnViewWasResized(); 632 OnViewWasResized();
649 } 633 }
650 634
651 void ShellWindowViews::UpdateLegacyDraggableRegions(
652 const std::vector<extensions::DraggableRegion>& regions) {
653 // Draggable region is not supported for non-frameless window.
654 if (!frameless_)
655 return;
656
657 SkRegion* draggable_region = new SkRegion;
658
659 // By default, the whole window is draggable.
660 gfx::Rect bounds = GetBounds();
661 draggable_region->op(0, 0, bounds.right(), bounds.bottom(),
662 SkRegion::kUnion_Op);
663
664 // Exclude those desinated as non-draggable.
665 for (std::vector<extensions::DraggableRegion>::const_iterator iter =
666 regions.begin();
667 iter != regions.end(); ++iter) {
668 const extensions::DraggableRegion& region = *iter;
669 draggable_region->op(region.bounds.x(),
670 region.bounds.y(),
671 region.bounds.right(),
672 region.bounds.bottom(),
673 SkRegion::kDifference_Op);
674 }
675
676 draggable_region_.reset(draggable_region);
677 OnViewWasResized();
678 }
679
680 void ShellWindowViews::HandleKeyboardEvent( 635 void ShellWindowViews::HandleKeyboardEvent(
681 const content::NativeWebKeyboardEvent& event) { 636 const content::NativeWebKeyboardEvent& event) {
682 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, 637 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event,
683 GetFocusManager()); 638 GetFocusManager());
684 } 639 }
685 640
686 void ShellWindowViews::SaveWindowPlacement(const gfx::Rect& bounds, 641 void ShellWindowViews::SaveWindowPlacement(const gfx::Rect& bounds,
687 ui::WindowShowState show_state) { 642 ui::WindowShowState show_state) {
688 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state); 643 views::WidgetDelegate::SaveWindowPlacement(bounds, show_state);
689 shell_window_->SaveWindowPosition(); 644 shell_window_->SaveWindowPosition();
690 } 645 }
691 646
692 // static 647 // static
693 NativeShellWindow* NativeShellWindow::Create( 648 NativeShellWindow* NativeShellWindow::Create(
694 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { 649 ShellWindow* shell_window, const ShellWindow::CreateParams& params) {
695 return new ShellWindowViews(shell_window, params); 650 return new ShellWindowViews(shell_window, params);
696 } 651 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/shell_window_views.h ('k') | chrome/common/extensions/draggable_region.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698