| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/go_button.h" | 5 #include "chrome/browser/views/go_button.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/compiler_specific.h" |
| 8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 9 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
| 10 #include "chrome/browser/browser.h" | 11 #include "chrome/browser/browser.h" |
| 11 #include "chrome/browser/views/event_utils.h" | 12 #include "chrome/browser/views/event_utils.h" |
| 12 #include "chrome/browser/views/location_bar_view.h" | 13 #include "chrome/browser/views/location_bar_view.h" |
| 13 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 14 | 15 |
| 15 //////////////////////////////////////////////////////////////////////////////// | 16 //////////////////////////////////////////////////////////////////////////////// |
| 16 // GoButton, public: | 17 // GoButton, public: |
| 17 | 18 |
| 18 GoButton::GoButton(LocationBarView* location_bar, Browser* browser) | 19 GoButton::GoButton(LocationBarView* location_bar, Browser* browser) |
| 19 : ToggleImageButton(this), | 20 : ToggleImageButton(this), |
| 21 button_delay_(0), |
| 22 ALLOW_THIS_IN_INITIALIZER_LIST(stop_timer_(this)), |
| 20 location_bar_(location_bar), | 23 location_bar_(location_bar), |
| 21 browser_(browser), | 24 browser_(browser), |
| 22 intended_mode_(MODE_GO), | 25 intended_mode_(MODE_GO), |
| 23 visible_mode_(MODE_GO), | 26 visible_mode_(MODE_GO) { |
| 24 button_delay_(NULL), | |
| 25 stop_timer_(this) { | |
| 26 DCHECK(location_bar_); | 27 DCHECK(location_bar_); |
| 27 set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | | 28 set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | |
| 28 views::Event::EF_MIDDLE_BUTTON_DOWN); | 29 views::Event::EF_MIDDLE_BUTTON_DOWN); |
| 29 } | 30 } |
| 30 | 31 |
| 31 GoButton::~GoButton() { | 32 GoButton::~GoButton() { |
| 32 stop_timer_.RevokeAll(); | 33 stop_timer_.RevokeAll(); |
| 33 } | 34 } |
| 34 | 35 |
| 35 void GoButton::ChangeMode(Mode mode, bool force) { | 36 void GoButton::ChangeMode(Mode mode, bool force) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 54 browser_->Stop(); | 55 browser_->Stop(); |
| 55 | 56 |
| 56 // The user has clicked, so we can feel free to update the button, | 57 // The user has clicked, so we can feel free to update the button, |
| 57 // even if the mouse is still hovering. | 58 // even if the mouse is still hovering. |
| 58 ChangeMode(MODE_GO, true); | 59 ChangeMode(MODE_GO, true); |
| 59 } else if (visible_mode_ == MODE_GO && stop_timer_.empty()) { | 60 } else if (visible_mode_ == MODE_GO && stop_timer_.empty()) { |
| 60 // If the go button is visible and not within the double click timer, go. | 61 // If the go button is visible and not within the double click timer, go. |
| 61 browser_->Go(event_utils::DispositionFromEventFlags(mouse_event_flags())); | 62 browser_->Go(event_utils::DispositionFromEventFlags(mouse_event_flags())); |
| 62 | 63 |
| 63 // Figure out the system double-click time. | 64 // Figure out the system double-click time. |
| 64 if (button_delay_ == NULL) | 65 if (button_delay_ == 0) { |
| 66 #if defined(OS_WIN) |
| 65 button_delay_ = GetDoubleClickTime(); | 67 button_delay_ = GetDoubleClickTime(); |
| 68 #else |
| 69 NOTIMPLEMENTED(); |
| 70 button_delay_ = 500; |
| 71 #endif |
| 72 } |
| 66 | 73 |
| 67 // Stop any existing timers. | 74 // Stop any existing timers. |
| 68 stop_timer_.RevokeAll(); | 75 stop_timer_.RevokeAll(); |
| 69 | 76 |
| 70 // Start a timer - while this timer is running, the go button | 77 // Start a timer - while this timer is running, the go button |
| 71 // cannot be changed to a stop button. We do not set intended_mode_ | 78 // cannot be changed to a stop button. We do not set intended_mode_ |
| 72 // to MODE_STOP here as we want to wait for the browser to tell | 79 // to MODE_STOP here as we want to wait for the browser to tell |
| 73 // us that it has started loading (and this may occur only after | 80 // us that it has started loading (and this may occur only after |
| 74 // some delay). | 81 // some delay). |
| 75 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 82 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 return true; | 125 return true; |
| 119 } | 126 } |
| 120 | 127 |
| 121 //////////////////////////////////////////////////////////////////////////////// | 128 //////////////////////////////////////////////////////////////////////////////// |
| 122 // GoButton, private: | 129 // GoButton, private: |
| 123 | 130 |
| 124 void GoButton::OnButtonTimer() { | 131 void GoButton::OnButtonTimer() { |
| 125 stop_timer_.RevokeAll(); | 132 stop_timer_.RevokeAll(); |
| 126 ChangeMode(intended_mode_, true); | 133 ChangeMode(intended_mode_, true); |
| 127 } | 134 } |
| OLD | NEW |