| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar/reload_button.h" | 5 #include "chrome/browser/ui/views/toolbar/reload_button.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 command_updater_->ExecuteCommandWithDisposition(IDC_STOP, CURRENT_TAB); | 142 command_updater_->ExecuteCommandWithDisposition(IDC_STOP, CURRENT_TAB); |
| 143 // The user has clicked, so we can feel free to update the button, | 143 // The user has clicked, so we can feel free to update the button, |
| 144 // even if the mouse is still hovering. | 144 // even if the mouse is still hovering. |
| 145 ChangeMode(MODE_RELOAD, true); | 145 ChangeMode(MODE_RELOAD, true); |
| 146 } else if (!double_click_timer_.IsRunning()) { | 146 } else if (!double_click_timer_.IsRunning()) { |
| 147 // Shift-clicking or ctrl-clicking the reload button means we should ignore | 147 // Shift-clicking or ctrl-clicking the reload button means we should ignore |
| 148 // any cached content. | 148 // any cached content. |
| 149 int command; | 149 int command; |
| 150 int flags = event.flags(); | 150 int flags = event.flags(); |
| 151 if (event.IsShiftDown() || event.IsControlDown()) { | 151 if (event.IsShiftDown() || event.IsControlDown()) { |
| 152 command = IDC_RELOAD_IGNORING_CACHE; | 152 command = IDC_RELOAD_BYPASSING_CACHE; |
| 153 // Mask off Shift and Control so they don't affect the disposition below. | 153 // Mask off Shift and Control so they don't affect the disposition below. |
| 154 flags &= ~(ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); | 154 flags &= ~(ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); |
| 155 } else { | 155 } else { |
| 156 command = IDC_RELOAD; | 156 command = IDC_RELOAD; |
| 157 } | 157 } |
| 158 | 158 |
| 159 // Start a timer - while this timer is running, the reload button cannot be | 159 // Start a timer - while this timer is running, the reload button cannot be |
| 160 // changed to a stop button. We do not set |intended_mode_| to MODE_STOP | 160 // changed to a stop button. We do not set |intended_mode_| to MODE_STOP |
| 161 // here as the browser will do that when it actually starts loading (which | 161 // here as the browser will do that when it actually starts loading (which |
| 162 // may happen synchronously, thus the need to do this before telling the | 162 // may happen synchronously, thus the need to do this before telling the |
| (...skipping 18 matching lines...) Expand all Loading... |
| 181 return true; | 181 return true; |
| 182 } | 182 } |
| 183 | 183 |
| 184 bool ReloadButton::GetAcceleratorForCommandId(int command_id, | 184 bool ReloadButton::GetAcceleratorForCommandId(int command_id, |
| 185 ui::Accelerator* accelerator) { | 185 ui::Accelerator* accelerator) { |
| 186 switch (command_id) { | 186 switch (command_id) { |
| 187 case IDS_RELOAD_MENU_NORMAL_RELOAD_ITEM: | 187 case IDS_RELOAD_MENU_NORMAL_RELOAD_ITEM: |
| 188 GetWidget()->GetAccelerator(IDC_RELOAD, accelerator); | 188 GetWidget()->GetAccelerator(IDC_RELOAD, accelerator); |
| 189 return true; | 189 return true; |
| 190 case IDS_RELOAD_MENU_HARD_RELOAD_ITEM: | 190 case IDS_RELOAD_MENU_HARD_RELOAD_ITEM: |
| 191 GetWidget()->GetAccelerator(IDC_RELOAD_IGNORING_CACHE, accelerator); | 191 GetWidget()->GetAccelerator(IDC_RELOAD_BYPASSING_CACHE, accelerator); |
| 192 return true; | 192 return true; |
| 193 } | 193 } |
| 194 return GetWidget()->GetAccelerator(command_id, accelerator); | 194 return GetWidget()->GetAccelerator(command_id, accelerator); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void ReloadButton::ExecuteCommand(int command_id, int event_flags) { | 197 void ReloadButton::ExecuteCommand(int command_id, int event_flags) { |
| 198 int browser_command = 0; | 198 int browser_command = 0; |
| 199 switch (command_id) { | 199 switch (command_id) { |
| 200 case IDS_RELOAD_MENU_NORMAL_RELOAD_ITEM: | 200 case IDS_RELOAD_MENU_NORMAL_RELOAD_ITEM: |
| 201 browser_command = IDC_RELOAD; | 201 browser_command = IDC_RELOAD; |
| 202 break; | 202 break; |
| 203 case IDS_RELOAD_MENU_HARD_RELOAD_ITEM: | 203 case IDS_RELOAD_MENU_HARD_RELOAD_ITEM: |
| 204 browser_command = IDC_RELOAD_IGNORING_CACHE; | 204 browser_command = IDC_RELOAD_BYPASSING_CACHE; |
| 205 break; | 205 break; |
| 206 case IDS_RELOAD_MENU_EMPTY_AND_HARD_RELOAD_ITEM: | 206 case IDS_RELOAD_MENU_EMPTY_AND_HARD_RELOAD_ITEM: |
| 207 browser_command = IDC_RELOAD_CLEARING_CACHE; | 207 browser_command = IDC_RELOAD_CLEARING_CACHE; |
| 208 break; | 208 break; |
| 209 default: | 209 default: |
| 210 NOTREACHED(); | 210 NOTREACHED(); |
| 211 } | 211 } |
| 212 ExecuteBrowserCommand(browser_command, event_flags); | 212 ExecuteBrowserCommand(browser_command, event_flags); |
| 213 } | 213 } |
| 214 | 214 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 261 |
| 262 void ReloadButton::OnDoubleClickTimer() { | 262 void ReloadButton::OnDoubleClickTimer() { |
| 263 if (!IsMenuShowing()) | 263 if (!IsMenuShowing()) |
| 264 ChangeMode(intended_mode_, false); | 264 ChangeMode(intended_mode_, false); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void ReloadButton::OnStopToReloadTimer() { | 267 void ReloadButton::OnStopToReloadTimer() { |
| 268 DCHECK(!IsMenuShowing()); | 268 DCHECK(!IsMenuShowing()); |
| 269 ChangeMode(intended_mode_, true); | 269 ChangeMode(intended_mode_, true); |
| 270 } | 270 } |
| OLD | NEW |