| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/views/find_bar_win.h" | 5 #include "chrome/browser/views/find_bar_win.h" |
| 6 | 6 |
| 7 #include "app/slide_animation.h" | 7 #include "app/slide_animation.h" |
| 8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/find_bar_controller.h" | 10 #include "chrome/browser/find_bar_controller.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // The minimum space between the FindInPage window and the search result. | 28 // The minimum space between the FindInPage window and the search result. |
| 29 static const int kMinFindWndDistanceFromSelection = 5; | 29 static const int kMinFindWndDistanceFromSelection = 5; |
| 30 | 30 |
| 31 // static | 31 // static |
| 32 bool FindBarWin::disable_animations_during_testing_ = false; | 32 bool FindBarWin::disable_animations_during_testing_ = false; |
| 33 | 33 |
| 34 // Host is the actual widget containing FindBarView. | 34 // Host is the actual widget containing FindBarView. |
| 35 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
| 36 class FindBarWin::Host : public views::WidgetWin { | 36 class FindBarWin::Host : public views::WidgetWin { |
| 37 public: | 37 public: |
| 38 Host(FindBarWin* find_bar) : find_bar_(find_bar) { | 38 explicit Host(FindBarWin* find_bar) : find_bar_(find_bar) { |
| 39 // Don't let WidgetWin manage our lifetime. We want our lifetime to | 39 // Don't let WidgetWin manage our lifetime. We want our lifetime to |
| 40 // coincide with TabContents. | 40 // coincide with TabContents. |
| 41 set_delete_on_destroy(false); | 41 set_delete_on_destroy(false); |
| 42 set_window_style(WS_CHILD | WS_CLIPCHILDREN); | 42 set_window_style(WS_CHILD | WS_CLIPCHILDREN); |
| 43 set_window_ex_style(WS_EX_TOPMOST); | 43 set_window_ex_style(WS_EX_TOPMOST); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void OnFinalMessage(HWND window) { | 46 void OnFinalMessage(HWND window) { |
| 47 find_bar_->OnFinalMessage(); | 47 find_bar_->OnFinalMessage(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 FindBarWin* find_bar_; | 51 FindBarWin* find_bar_; |
| 52 | 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(Host); | 53 DISALLOW_COPY_AND_ASSIGN(Host); |
| 54 }; | 54 }; |
| 55 #else | 55 #else |
| 56 class FindBarWin::Host : public views::WidgetGtk { | 56 class FindBarWin::Host : public views::WidgetGtk { |
| 57 public: | 57 public: |
| 58 Host(FindBarWin* find_bar) : WidgetGtk(TYPE_CHILD), find_bar_(find_bar) { | 58 explicit Host(FindBarWin* find_bar) |
| 59 : WidgetGtk(TYPE_CHILD), |
| 60 find_bar_(find_bar) { |
| 59 // Don't let WidgetWin manage our lifetime. We want our lifetime to | 61 // Don't let WidgetWin manage our lifetime. We want our lifetime to |
| 60 // coincide with TabContents. | 62 // coincide with TabContents. |
| 61 set_delete_on_destroy(false); | 63 set_delete_on_destroy(false); |
| 62 } | 64 } |
| 63 | 65 |
| 64 void OnDestroy(GtkWidget* widget) { | 66 void OnDestroy(GtkWidget* widget) { |
| 65 find_bar_->OnFinalMessage(); | 67 find_bar_->OnFinalMessage(); |
| 66 } | 68 } |
| 67 | 69 |
| 68 private: | 70 private: |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 //////////////////////////////////////////////////////////////////////////////// | 434 //////////////////////////////////////////////////////////////////////////////// |
| 433 // FindBarTesting implementation: | 435 // FindBarTesting implementation: |
| 434 | 436 |
| 435 bool FindBarWin::GetFindBarWindowInfo(gfx::Point* position, | 437 bool FindBarWin::GetFindBarWindowInfo(gfx::Point* position, |
| 436 bool* fully_visible) { | 438 bool* fully_visible) { |
| 437 if (!find_bar_controller_ || | 439 if (!find_bar_controller_ || |
| 438 #if defined(OS_WIN) | 440 #if defined(OS_WIN) |
| 439 !::IsWindow(host_->GetNativeView())) { | 441 !::IsWindow(host_->GetNativeView())) { |
| 440 #else | 442 #else |
| 441 false) { | 443 false) { |
| 442 // TODO: figure out linux side. | 444 // TODO(sky): figure out linux side. |
| 443 #endif | 445 #endif |
| 444 *position = gfx::Point(); | 446 *position = gfx::Point(); |
| 445 *fully_visible = false; | 447 *fully_visible = false; |
| 446 return false; | 448 return false; |
| 447 } | 449 } |
| 448 | 450 |
| 449 gfx::Rect window_rect; | 451 gfx::Rect window_rect; |
| 450 host_->GetBounds(&window_rect, true); | 452 host_->GetBounds(&window_rect, true); |
| 451 *position = window_rect.origin(); | 453 *position = window_rect.origin(); |
| 452 *fully_visible = host_->IsVisible() && !IsAnimating(); | 454 *fully_visible = host_->IsVisible() && !IsAnimating(); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 } | 618 } |
| 617 | 619 |
| 618 void FindBarWin::UnregisterEscAccelerator() { | 620 void FindBarWin::UnregisterEscAccelerator() { |
| 619 #if defined(OS_WIN) | 621 #if defined(OS_WIN) |
| 620 // TODO(finnur): Once we fix issue 1307173 we should not remember any old | 622 // TODO(finnur): Once we fix issue 1307173 we should not remember any old |
| 621 // accelerator targets and just Register and Unregister when needed. | 623 // accelerator targets and just Register and Unregister when needed. |
| 622 DCHECK(old_accel_target_for_esc_ != NULL); | 624 DCHECK(old_accel_target_for_esc_ != NULL); |
| 623 views::Accelerator escape(VK_ESCAPE, false, false, false); | 625 views::Accelerator escape(VK_ESCAPE, false, false, false); |
| 624 views::AcceleratorTarget* current_target = | 626 views::AcceleratorTarget* current_target = |
| 625 focus_manager_->GetTargetForAccelerator(escape); | 627 focus_manager_->GetTargetForAccelerator(escape); |
| 626 if (current_target == host_.get()) | 628 if (current_target == this) |
| 627 focus_manager_->RegisterAccelerator(escape, old_accel_target_for_esc_); | 629 focus_manager_->RegisterAccelerator(escape, old_accel_target_for_esc_); |
| 628 #else | 630 #else |
| 629 NOTIMPLEMENTED(); | 631 NOTIMPLEMENTED(); |
| 630 #endif | 632 #endif |
| 631 } | 633 } |
| 632 | 634 |
| 633 void FindBarWin::UpdateUIForFindResult(const FindNotificationDetails& result, | 635 void FindBarWin::UpdateUIForFindResult(const FindNotificationDetails& result, |
| 634 const string16& find_text) { | 636 const string16& find_text) { |
| 635 view_->UpdateForResult(result, find_text); | 637 view_->UpdateForResult(result, find_text); |
| 636 | 638 |
| 637 // We now need to check if the window is obscuring the search results. | 639 // We now need to check if the window is obscuring the search results. |
| 638 if (!result.selection_rect().IsEmpty()) | 640 if (!result.selection_rect().IsEmpty()) |
| 639 MoveWindowIfNecessary(result.selection_rect(), false); | 641 MoveWindowIfNecessary(result.selection_rect(), false); |
| 640 | 642 |
| 641 // Once we find a match we no longer want to keep track of what had | 643 // Once we find a match we no longer want to keep track of what had |
| 642 // focus. EndFindSession will then set the focus to the page content. | 644 // focus. EndFindSession will then set the focus to the page content. |
| 643 if (result.number_of_matches() > 0) | 645 if (result.number_of_matches() > 0) |
| 644 focus_tracker_.reset(NULL); | 646 focus_tracker_.reset(NULL); |
| 645 } | 647 } |
| 646 | 648 |
| 647 void FindBarWin::AudibleAlert() { | 649 void FindBarWin::AudibleAlert() { |
| 648 #if defined(OS_WIN) | 650 #if defined(OS_WIN) |
| 649 MessageBeep(MB_OK); | 651 MessageBeep(MB_OK); |
| 650 #else | 652 #else |
| 651 NOTIMPLEMENTED(); | 653 NOTIMPLEMENTED(); |
| 652 #endif | 654 #endif |
| 653 } | 655 } |
| OLD | NEW |