fix reload menu
This commit is contained in:
parent
b07a4bdcb4
commit
32ce9ac6b5
3 changed files with 241 additions and 1 deletions
|
@ -68,7 +68,7 @@ export NINJA_SUMMARIZE_BUILD=1 &&
|
|||
export NINJA_STATUS="[%r processes, %f/%t @ %o/s | %e sec. ] " &&
|
||||
|
||||
cd ${CR_SRC_DIR} &&
|
||||
autoninja -C out/thorium content_shell_apk chrome_public_apk -j$@ &&
|
||||
autoninja -C out/thorium chrome_public_apk content_shell_apk system_webview_apk -j$@ &&
|
||||
|
||||
cat ~/thorium/logos/thorium_logo_ascii_art.txt &&
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
<DT><A HREF="https://source.chromium.org/chromium/chromium/src/+/refs/tags/117.0.5938.157:chrome/browser/search/search.cc;bpv=1" ADD_DATE="1661054752" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADIUlEQVQ4jW1TXWwUZRQ955ufnZ3dlm4VpE2Q+lND1cSQYDBaKY2VEkUFa1d9K4laBROEIg+mDfvkg5Bu9MWoD/hkTJdqJBFCMRENEqONRkMbIiWGWn5SjWw7OzO7szPf9UFCCnrebu7JuTc55xA3QURYKkEtXw7+1gDm0mDWBtMm+GcAnb+P0VI+lw4fTIp7C6O7dU3nlKFyisxp0TmDRpMmmyDSCqLY96D1HUQIUsxrd9nfD3VrHDbDTi/ENi5V/TCdtmlQ0Y60dmwANNXT0HpodEx+2kNUb/4e45PSUhBR/1lcw6Gvf3fGf4gmJn6NBgGgUBBFAHj+vepdKSvp2r5m/pPu7juqA4fEOTcXvhaG2KAMVjOp5MjJ4eynBOTIz7Vnzs5Jcfoiej9+1TlHAHjyneArKrl/XcVtnQLcS/A/b23J9DzUBgQRcPo84JX90VOF7JCIGFsOBLMCTB/dl3lc9b+7uA1O+jHb4OuFAvVl+oOtLZmekc1JbUc36nt7pb6zK0mslL2n6+3wUZJJyuIuOm7Ps8Xyc8qP3Q+TMDj+2W73MABUatK5vg26vcVQf3navOqL+Ui7kay53dJeEG8AgPE33PEkDI6HSfZ9BRFAQJF/LSVYDSIQEBiKsE0lsRaGNSiTEl43X4SAQKWN8GUj427qG/XyAJB15IvTM+CJKW04FuoiEpd+1Grmj8BvzPIYAGwten2mm9mUsauDBIAnDvgnAHQMrHZX5/NMOguLBy07NXTPKhvVGnDhb0BH3pvfDjcelDExnpoNLormmS/3uT0KAFY0xDs2dhiLqXZsBoBThca9QK1z8mxlZPpCZZeq+2dMqi2AcGYtzOZG9dayrHoFACgiJCkTU9FAJZCtCxX7he3dvCFl60b8ta6lh2/T2Rdf2oam3gc4f2MXRLi7NOd0tq34iFS/aNFHIwBhJLGVSLRqZd3rWNYQfj+L5igOdb6YvoISNEC5LgBSDk9G6ynYScgVrbGgFMsQKSdiLIhIWSe6rGifzz/M8H/bCABjU2L781BeOCMrK5FcvfNeuexB8M1J7N+/MSEpS/n/AGH0clblBN69AAAAAElFTkSuQmCC">search.cc - Chromium Code Search</A>
|
||||
<DT><A HREF="https://source.chromium.org/chromium/chromium/src/+/refs/tags/117.0.5938.157:sandbox/linux/BUILD.gn;bpv=1" ADD_DATE="1661054752" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADIUlEQVQ4jW1TXWwUZRQ955ufnZ3dlm4VpE2Q+lND1cSQYDBaKY2VEkUFa1d9K4laBROEIg+mDfvkg5Bu9MWoD/hkTJdqJBFCMRENEqONRkMbIiWGWn5SjWw7OzO7szPf9UFCCnrebu7JuTc55xA3QURYKkEtXw7+1gDm0mDWBtMm+GcAnb+P0VI+lw4fTIp7C6O7dU3nlKFyisxp0TmDRpMmmyDSCqLY96D1HUQIUsxrd9nfD3VrHDbDTi/ENi5V/TCdtmlQ0Y60dmwANNXT0HpodEx+2kNUb/4e45PSUhBR/1lcw6Gvf3fGf4gmJn6NBgGgUBBFAHj+vepdKSvp2r5m/pPu7juqA4fEOTcXvhaG2KAMVjOp5MjJ4eynBOTIz7Vnzs5Jcfoiej9+1TlHAHjyneArKrl/XcVtnQLcS/A/b23J9DzUBgQRcPo84JX90VOF7JCIGFsOBLMCTB/dl3lc9b+7uA1O+jHb4OuFAvVl+oOtLZmekc1JbUc36nt7pb6zK0mslL2n6+3wUZJJyuIuOm7Ps8Xyc8qP3Q+TMDj+2W73MABUatK5vg26vcVQf3navOqL+Ui7kay53dJeEG8AgPE33PEkDI6HSfZ9BRFAQJF/LSVYDSIQEBiKsE0lsRaGNSiTEl43X4SAQKWN8GUj427qG/XyAJB15IvTM+CJKW04FuoiEpd+1Grmj8BvzPIYAGwten2mm9mUsauDBIAnDvgnAHQMrHZX5/NMOguLBy07NXTPKhvVGnDhb0BH3pvfDjcelDExnpoNLormmS/3uT0KAFY0xDs2dhiLqXZsBoBThca9QK1z8mxlZPpCZZeq+2dMqi2AcGYtzOZG9dayrHoFACgiJCkTU9FAJZCtCxX7he3dvCFl60b8ta6lh2/T2Rdf2oam3gc4f2MXRLi7NOd0tq34iFS/aNFHIwBhJLGVSLRqZd3rWNYQfj+L5igOdb6YvoISNEC5LgBSDk9G6ynYScgVrbGgFMsQKSdiLIhIWSe6rGifzz/M8H/bCABjU2L781BeOCMrK5FcvfNeuexB8M1J7N+/MSEpS/n/AGH0clblBN69AAAAAElFTkSuQmCC">BUILD.gn - Chromium Code Search</A>
|
||||
<DT><A HREF="https://source.chromium.org/chromium/chromium/src/+/refs/tags/117.0.5938.157:components/dom_distiller/core/css/distilledpage.css;bpv=1" ADD_DATE="1661054752" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADIUlEQVQ4jW1TXWwUZRQ955ufnZ3dlm4VpE2Q+lND1cSQYDBaKY2VEkUFa1d9K4laBROEIg+mDfvkg5Bu9MWoD/hkTJdqJBFCMRENEqONRkMbIiWGWn5SjWw7OzO7szPf9UFCCnrebu7JuTc55xA3QURYKkEtXw7+1gDm0mDWBtMm+GcAnb+P0VI+lw4fTIp7C6O7dU3nlKFyisxp0TmDRpMmmyDSCqLY96D1HUQIUsxrd9nfD3VrHDbDTi/ENi5V/TCdtmlQ0Y60dmwANNXT0HpodEx+2kNUb/4e45PSUhBR/1lcw6Gvf3fGf4gmJn6NBgGgUBBFAHj+vepdKSvp2r5m/pPu7juqA4fEOTcXvhaG2KAMVjOp5MjJ4eynBOTIz7Vnzs5Jcfoiej9+1TlHAHjyneArKrl/XcVtnQLcS/A/b23J9DzUBgQRcPo84JX90VOF7JCIGFsOBLMCTB/dl3lc9b+7uA1O+jHb4OuFAvVl+oOtLZmekc1JbUc36nt7pb6zK0mslL2n6+3wUZJJyuIuOm7Ps8Xyc8qP3Q+TMDj+2W73MABUatK5vg26vcVQf3navOqL+Ui7kay53dJeEG8AgPE33PEkDI6HSfZ9BRFAQJF/LSVYDSIQEBiKsE0lsRaGNSiTEl43X4SAQKWN8GUj427qG/XyAJB15IvTM+CJKW04FuoiEpd+1Grmj8BvzPIYAGwten2mm9mUsauDBIAnDvgnAHQMrHZX5/NMOguLBy07NXTPKhvVGnDhb0BH3pvfDjcelDExnpoNLormmS/3uT0KAFY0xDs2dhiLqXZsBoBThca9QK1z8mxlZPpCZZeq+2dMqi2AcGYtzOZG9dayrHoFACgiJCkTU9FAJZCtCxX7he3dvCFl60b8ta6lh2/T2Rdf2oam3gc4f2MXRLi7NOd0tq34iFS/aNFHIwBhJLGVSLRqZd3rWNYQfj+L5igOdb6YvoISNEC5LgBSDk9G6ynYScgVrbGgFMsQKSdiLIhIWSe6rGifzz/M8H/bCABjU2L781BeOCMrK5FcvfNeuexB8M1J7N+/MSEpS/n/AGH0clblBN69AAAAAElFTkSuQmCC">distilledpage.css - Chromium Code Search</A>
|
||||
<DT><A HREF="https://source.chromium.org/chromium/chromium/src/+/refs/tags/117.0.5938.157:chrome/browser/ui/views/toolbar/reload_button.cc;bpv=1" ADD_DATE="1661054752" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADIUlEQVQ4jW1TXWwUZRQ955ufnZ3dlm4VpE2Q+lND1cSQYDBaKY2VEkUFa1d9K4laBROEIg+mDfvkg5Bu9MWoD/hkTJdqJBFCMRENEqONRkMbIiWGWn5SjWw7OzO7szPf9UFCCnrebu7JuTc55xA3QURYKkEtXw7+1gDm0mDWBtMm+GcAnb+P0VI+lw4fTIp7C6O7dU3nlKFyisxp0TmDRpMmmyDSCqLY96D1HUQIUsxrd9nfD3VrHDbDTi/ENi5V/TCdtmlQ0Y60dmwANNXT0HpodEx+2kNUb/4e45PSUhBR/1lcw6Gvf3fGf4gmJn6NBgGgUBBFAHj+vepdKSvp2r5m/pPu7juqA4fEOTcXvhaG2KAMVjOp5MjJ4eynBOTIz7Vnzs5Jcfoiej9+1TlHAHjyneArKrl/XcVtnQLcS/A/b23J9DzUBgQRcPo84JX90VOF7JCIGFsOBLMCTB/dl3lc9b+7uA1O+jHb4OuFAvVl+oOtLZmekc1JbUc36nt7pb6zK0mslL2n6+3wUZJJyuIuOm7Ps8Xyc8qP3Q+TMDj+2W73MABUatK5vg26vcVQf3navOqL+Ui7kay53dJeEG8AgPE33PEkDI6HSfZ9BRFAQJF/LSVYDSIQEBiKsE0lsRaGNSiTEl43X4SAQKWN8GUj427qG/XyAJB15IvTM+CJKW04FuoiEpd+1Grmj8BvzPIYAGwten2mm9mUsauDBIAnDvgnAHQMrHZX5/NMOguLBy07NXTPKhvVGnDhb0BH3pvfDjcelDExnpoNLormmS/3uT0KAFY0xDs2dhiLqXZsBoBThca9QK1z8mxlZPpCZZeq+2dMqi2AcGYtzOZG9dayrHoFACgiJCkTU9FAJZCtCxX7he3dvCFl60b8ta6lh2/T2Rdf2oam3gc4f2MXRLi7NOd0tq34iFS/aNFHIwBhJLGVSLRqZd3rWNYQfj+L5igOdb6YvoISNEC5LgBSDk9G6ynYScgVrbGgFMsQKSdiLIhIWSe6rGifzz/M8H/bCABjU2L781BeOCMrK5FcvfNeuexB8M1J7N+/MSEpS/n/AGH0clblBN69AAAAAElFTkSuQmCC">reload_button.cc - Chromium Code Search</A>
|
||||
<DT><A HREF="https://source.chromium.org/chromium/chromium/src/+/refs/tags/117.0.5938.157:chrome/browser/ui/views/toolbar/reload_button.h;bpv=1" ADD_DATE="1661054752" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADIUlEQVQ4jW1TXWwUZRQ955ufnZ3dlm4VpE2Q+lND1cSQYDBaKY2VEkUFa1d9K4laBROEIg+mDfvkg5Bu9MWoD/hkTJdqJBFCMRENEqONRkMbIiWGWn5SjWw7OzO7szPf9UFCCnrebu7JuTc55xA3QURYKkEtXw7+1gDm0mDWBtMm+GcAnb+P0VI+lw4fTIp7C6O7dU3nlKFyisxp0TmDRpMmmyDSCqLY96D1HUQIUsxrd9nfD3VrHDbDTi/ENi5V/TCdtmlQ0Y60dmwANNXT0HpodEx+2kNUb/4e45PSUhBR/1lcw6Gvf3fGf4gmJn6NBgGgUBBFAHj+vepdKSvp2r5m/pPu7juqA4fEOTcXvhaG2KAMVjOp5MjJ4eynBOTIz7Vnzs5Jcfoiej9+1TlHAHjyneArKrl/XcVtnQLcS/A/b23J9DzUBgQRcPo84JX90VOF7JCIGFsOBLMCTB/dl3lc9b+7uA1O+jHb4OuFAvVl+oOtLZmekc1JbUc36nt7pb6zK0mslL2n6+3wUZJJyuIuOm7Ps8Xyc8qP3Q+TMDj+2W73MABUatK5vg26vcVQf3navOqL+Ui7kay53dJeEG8AgPE33PEkDI6HSfZ9BRFAQJF/LSVYDSIQEBiKsE0lsRaGNSiTEl43X4SAQKWN8GUj427qG/XyAJB15IvTM+CJKW04FuoiEpd+1Grmj8BvzPIYAGwten2mm9mUsauDBIAnDvgnAHQMrHZX5/NMOguLBy07NXTPKhvVGnDhb0BH3pvfDjcelDExnpoNLormmS/3uT0KAFY0xDs2dhiLqXZsBoBThca9QK1z8mxlZPpCZZeq+2dMqi2AcGYtzOZG9dayrHoFACgiJCkTU9FAJZCtCxX7he3dvCFl60b8ta6lh2/T2Rdf2oam3gc4f2MXRLi7NOd0tq34iFS/aNFHIwBhJLGVSLRqZd3rWNYQfj+L5igOdb6YvoISNEC5LgBSDk9G6ynYScgVrbGgFMsQKSdiLIhIWSe6rGifzz/M8H/bCABjU2L781BeOCMrK5FcvfNeuexB8M1J7N+/MSEpS/n/AGH0clblBN69AAAAAElFTkSuQmCC">reload_button.h - Chromium Code Search</A>
|
||||
<DT><A HREF="https://source.chromium.org/chromium/chromium/src/+/refs/tags/117.0.5938.157:third_party/blink/common/features.cc;bpv=1" ADD_DATE="1661054752" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADIUlEQVQ4jW1TXWwUZRQ955ufnZ3dlm4VpE2Q+lND1cSQYDBaKY2VEkUFa1d9K4laBROEIg+mDfvkg5Bu9MWoD/hkTJdqJBFCMRENEqONRkMbIiWGWn5SjWw7OzO7szPf9UFCCnrebu7JuTc55xA3QURYKkEtXw7+1gDm0mDWBtMm+GcAnb+P0VI+lw4fTIp7C6O7dU3nlKFyisxp0TmDRpMmmyDSCqLY96D1HUQIUsxrd9nfD3VrHDbDTi/ENi5V/TCdtmlQ0Y60dmwANNXT0HpodEx+2kNUb/4e45PSUhBR/1lcw6Gvf3fGf4gmJn6NBgGgUBBFAHj+vepdKSvp2r5m/pPu7juqA4fEOTcXvhaG2KAMVjOp5MjJ4eynBOTIz7Vnzs5Jcfoiej9+1TlHAHjyneArKrl/XcVtnQLcS/A/b23J9DzUBgQRcPo84JX90VOF7JCIGFsOBLMCTB/dl3lc9b+7uA1O+jHb4OuFAvVl+oOtLZmekc1JbUc36nt7pb6zK0mslL2n6+3wUZJJyuIuOm7Ps8Xyc8qP3Q+TMDj+2W73MABUatK5vg26vcVQf3navOqL+Ui7kay53dJeEG8AgPE33PEkDI6HSfZ9BRFAQJF/LSVYDSIQEBiKsE0lsRaGNSiTEl43X4SAQKWN8GUj427qG/XyAJB15IvTM+CJKW04FuoiEpd+1Grmj8BvzPIYAGwten2mm9mUsauDBIAnDvgnAHQMrHZX5/NMOguLBy07NXTPKhvVGnDhb0BH3pvfDjcelDExnpoNLormmS/3uT0KAFY0xDs2dhiLqXZsBoBThca9QK1z8mxlZPpCZZeq+2dMqi2AcGYtzOZG9dayrHoFACgiJCkTU9FAJZCtCxX7he3dvCFl60b8ta6lh2/T2Rdf2oam3gc4f2MXRLi7NOd0tq34iFS/aNFHIwBhJLGVSLRqZd3rWNYQfj+L5igOdb6YvoISNEC5LgBSDk9G6ynYScgVrbGgFMsQKSdiLIhIWSe6rGifzz/M8H/bCABjU2L781BeOCMrK5FcvfNeuexB8M1J7N+/MSEpS/n/AGH0clblBN69AAAAAElFTkSuQmCC">features.cc - Chromium Code Search</A>
|
||||
<DT><A HREF="https://source.chromium.org/chromium/chromium/src/+/refs/tags/117.0.5938.157:chrome/browser/profiles/profile_shortcut_manager_win.cc;bpv=1" ADD_DATE="1661054752" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADIUlEQVQ4jW1TXWwUZRQ955ufnZ3dlm4VpE2Q+lND1cSQYDBaKY2VEkUFa1d9K4laBROEIg+mDfvkg5Bu9MWoD/hkTJdqJBFCMRENEqONRkMbIiWGWn5SjWw7OzO7szPf9UFCCnrebu7JuTc55xA3QURYKkEtXw7+1gDm0mDWBtMm+GcAnb+P0VI+lw4fTIp7C6O7dU3nlKFyisxp0TmDRpMmmyDSCqLY96D1HUQIUsxrd9nfD3VrHDbDTi/ENi5V/TCdtmlQ0Y60dmwANNXT0HpodEx+2kNUb/4e45PSUhBR/1lcw6Gvf3fGf4gmJn6NBgGgUBBFAHj+vepdKSvp2r5m/pPu7juqA4fEOTcXvhaG2KAMVjOp5MjJ4eynBOTIz7Vnzs5Jcfoiej9+1TlHAHjyneArKrl/XcVtnQLcS/A/b23J9DzUBgQRcPo84JX90VOF7JCIGFsOBLMCTB/dl3lc9b+7uA1O+jHb4OuFAvVl+oOtLZmekc1JbUc36nt7pb6zK0mslL2n6+3wUZJJyuIuOm7Ps8Xyc8qP3Q+TMDj+2W73MABUatK5vg26vcVQf3navOqL+Ui7kay53dJeEG8AgPE33PEkDI6HSfZ9BRFAQJF/LSVYDSIQEBiKsE0lsRaGNSiTEl43X4SAQKWN8GUj427qG/XyAJB15IvTM+CJKW04FuoiEpd+1Grmj8BvzPIYAGwten2mm9mUsauDBIAnDvgnAHQMrHZX5/NMOguLBy07NXTPKhvVGnDhb0BH3pvfDjcelDExnpoNLormmS/3uT0KAFY0xDs2dhiLqXZsBoBThca9QK1z8mxlZPpCZZeq+2dMqi2AcGYtzOZG9dayrHoFACgiJCkTU9FAJZCtCxX7he3dvCFl60b8ta6lh2/T2Rdf2oam3gc4f2MXRLi7NOd0tq34iFS/aNFHIwBhJLGVSLRqZd3rWNYQfj+L5igOdb6YvoISNEC5LgBSDk9G6ynYScgVrbGgFMsQKSdiLIhIWSe6rGifzz/M8H/bCABjU2L781BeOCMrK5FcvfNeuexB8M1J7N+/MSEpS/n/AGH0clblBN69AAAAAElFTkSuQmCC">profile_shortcut_manager_win.cc - Chromium Code Search</A>
|
||||
|
|
239
src/chrome/browser/ui/views/toolbar/reload_button.cc
Normal file
239
src/chrome/browser/ui/views/toolbar/reload_button.cc
Normal file
|
@ -0,0 +1,239 @@
|
|||
// Copyright 2023 The Chromium Authors and Alex313031
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/browser/ui/views/toolbar/reload_button.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "build/build_config.h"
|
||||
#include "chrome/app/chrome_command_ids.h"
|
||||
#include "chrome/app/vector_icons/vector_icons.h"
|
||||
#include "chrome/browser/command_updater.h"
|
||||
#include "chrome/browser/external_protocol/external_protocol_handler.h"
|
||||
#include "chrome/browser/themes/theme_properties.h"
|
||||
#include "chrome/browser/ui/view_ids.h"
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
#include "components/vector_icons/vector_icons.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/metadata/metadata_impl_macros.h"
|
||||
#include "ui/base/models/simple_menu_model.h"
|
||||
#include "ui/base/pointer/touch_ui_controller.h"
|
||||
#include "ui/base/theme_provider.h"
|
||||
#include "ui/base/ui_base_features.h"
|
||||
#include "ui/base/window_open_disposition.h"
|
||||
#include "ui/base/window_open_disposition_utils.h"
|
||||
#include "ui/gfx/color_palette.h"
|
||||
#include "ui/gfx/paint_vector_icon.h"
|
||||
#include "ui/views/metrics.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
|
||||
// ReloadButton ---------------------------------------------------------------
|
||||
|
||||
ReloadButton::ReloadButton(CommandUpdater* command_updater)
|
||||
: ToolbarButton(base::BindRepeating(&ReloadButton::ButtonPressed,
|
||||
base::Unretained(this)),
|
||||
CreateMenuModel(),
|
||||
nullptr),
|
||||
command_updater_(command_updater),
|
||||
double_click_timer_delay_(
|
||||
base::Milliseconds(views::GetDoubleClickInterval())),
|
||||
mode_switch_timer_delay_(base::Milliseconds(1350)) {
|
||||
SetVisibleMode(Mode::kReload);
|
||||
SetTriggerableEventFlags(ui::EF_LEFT_MOUSE_BUTTON |
|
||||
ui::EF_MIDDLE_MOUSE_BUTTON);
|
||||
SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_RELOAD));
|
||||
SetID(VIEW_ID_RELOAD_BUTTON);
|
||||
}
|
||||
|
||||
ReloadButton::~ReloadButton() {}
|
||||
|
||||
void ReloadButton::ChangeMode(Mode mode, bool force) {
|
||||
intended_mode_ = mode;
|
||||
|
||||
// If the change is forced, or the user isn't hovering the icon, or it's
|
||||
// safe to change it to the other image type, make the change immediately;
|
||||
// otherwise we'll let it happen later.
|
||||
if (force || (!IsMouseHovered() && !testing_mouse_hovered_) ||
|
||||
((mode == Mode::kStop) ? !double_click_timer_.IsRunning()
|
||||
: (visible_mode_ != Mode::kStop))) {
|
||||
double_click_timer_.Stop();
|
||||
mode_switch_timer_.Stop();
|
||||
SetVisibleMode(mode);
|
||||
SetEnabled(true);
|
||||
|
||||
// We want to disable the button if we're preventing a change from stop to
|
||||
// reload due to hovering, but not if we're preventing a change from
|
||||
// reload to stop due to the double-click timer running. (Disabled reload
|
||||
// state is only applicable when instant extended API is enabled and mode
|
||||
// is NTP, which is handled just above.)
|
||||
} else if (visible_mode_ != Mode::kReload) {
|
||||
SetEnabled(false);
|
||||
|
||||
// Go ahead and change to reload after a bit, which allows repeated
|
||||
// reloads without moving the mouse.
|
||||
if (!mode_switch_timer_.IsRunning()) {
|
||||
mode_switch_timer_.Start(FROM_HERE, mode_switch_timer_delay_, this,
|
||||
&ReloadButton::OnStopToReloadTimer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ReloadButton::GetMenuEnabled() const {
|
||||
return menu_enabled_;
|
||||
}
|
||||
|
||||
void ReloadButton::SetMenuEnabled(bool enable) {
|
||||
menu_enabled_ = true;
|
||||
}
|
||||
|
||||
void ReloadButton::OnMouseExited(const ui::MouseEvent& event) {
|
||||
ToolbarButton::OnMouseExited(event);
|
||||
if (!IsMenuShowing())
|
||||
ChangeMode(intended_mode_, true);
|
||||
}
|
||||
|
||||
std::u16string ReloadButton::GetTooltipText(const gfx::Point& p) const {
|
||||
int reload_tooltip = menu_enabled_ ?
|
||||
IDS_TOOLTIP_RELOAD_WITH_MENU : IDS_TOOLTIP_RELOAD;
|
||||
return l10n_util::GetStringUTF16(
|
||||
visible_mode_ == Mode::kReload ? reload_tooltip : IDS_TOOLTIP_STOP);
|
||||
}
|
||||
|
||||
void ReloadButton::GetAccessibleNodeData(ui::AXNodeData* node_data) {
|
||||
if (menu_enabled_)
|
||||
ToolbarButton::GetAccessibleNodeData(node_data);
|
||||
else
|
||||
Button::GetAccessibleNodeData(node_data);
|
||||
}
|
||||
|
||||
bool ReloadButton::ShouldShowMenu() {
|
||||
return menu_enabled_ && (visible_mode_ == Mode::kReload);
|
||||
}
|
||||
|
||||
void ReloadButton::ShowDropDownMenu(ui::MenuSourceType source_type) {
|
||||
ToolbarButton::ShowDropDownMenu(source_type); // Blocks.
|
||||
ChangeMode(intended_mode_, true);
|
||||
}
|
||||
|
||||
bool ReloadButton::IsCommandIdChecked(int command_id) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ReloadButton::IsCommandIdEnabled(int command_id) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReloadButton::IsCommandIdVisible(int command_id) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReloadButton::GetAcceleratorForCommandId(
|
||||
int command_id,
|
||||
ui::Accelerator* accelerator) const {
|
||||
return GetWidget()->GetAccelerator(command_id, accelerator);
|
||||
}
|
||||
|
||||
void ReloadButton::ExecuteCommand(int command_id, int event_flags) {
|
||||
ExecuteBrowserCommand(command_id, event_flags);
|
||||
}
|
||||
|
||||
std::unique_ptr<ui::SimpleMenuModel> ReloadButton::CreateMenuModel() {
|
||||
auto menu_model = std::make_unique<ui::SimpleMenuModel>(this);
|
||||
menu_model->AddItemWithStringId(IDC_RELOAD,
|
||||
IDS_RELOAD_MENU_NORMAL_RELOAD_ITEM);
|
||||
menu_model->AddItemWithStringId(IDC_RELOAD_BYPASSING_CACHE,
|
||||
IDS_RELOAD_MENU_HARD_RELOAD_ITEM);
|
||||
menu_model->AddItemWithStringId(IDC_RELOAD_CLEARING_CACHE,
|
||||
IDS_RELOAD_MENU_EMPTY_AND_HARD_RELOAD_ITEM);
|
||||
return menu_model;
|
||||
}
|
||||
|
||||
void ReloadButton::SetVisibleMode(Mode mode) {
|
||||
visible_mode_ = mode;
|
||||
switch (mode) {
|
||||
case Mode::kReload:
|
||||
SetVectorIcons(features::IsChromeRefresh2023()
|
||||
? vector_icons::kReloadChromeRefreshIcon
|
||||
: vector_icons::kReloadIcon,
|
||||
kReloadTouchIcon);
|
||||
break;
|
||||
case Mode::kStop:
|
||||
SetVectorIcons(features::IsChromeRefresh2023()
|
||||
? kNavigateStopChromeRefreshIcon
|
||||
: kNavigateStopIcon,
|
||||
kNavigateStopTouchIcon);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ReloadButton::ButtonPressed(const ui::Event& event) {
|
||||
// This is called in order to signal that external protocol dialogs are
|
||||
// allowed to show due to a user action, which are likely to happen on the
|
||||
// next page load after the reload button is clicked.
|
||||
// Ideally, the browser UI's event system would notify ExternalProtocolHandler
|
||||
// that a user action occurred and we are OK to open the dialog, but for some
|
||||
// reason that isn't happening every time the reload button is clicked. See
|
||||
// http://crbug.com/1206456
|
||||
ExternalProtocolHandler::PermitLaunchUrl();
|
||||
|
||||
ClearPendingMenu();
|
||||
|
||||
if (visible_mode_ == Mode::kStop) {
|
||||
if (command_updater_) {
|
||||
command_updater_->ExecuteCommandWithDisposition(
|
||||
IDC_STOP, WindowOpenDisposition::CURRENT_TAB);
|
||||
}
|
||||
// The user has clicked, so we can feel free to update the button, even if
|
||||
// the mouse is still hovering.
|
||||
ChangeMode(Mode::kReload, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!double_click_timer_.IsRunning()) {
|
||||
// Shift-clicking or ctrl-clicking the reload button means we should ignore
|
||||
// any cached content.
|
||||
int command;
|
||||
int flags = event.flags();
|
||||
if (event.IsShiftDown() || event.IsControlDown()) {
|
||||
command = IDC_RELOAD_BYPASSING_CACHE;
|
||||
// Mask off Shift and Control so they don't affect the disposition below.
|
||||
flags &= ~(ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN);
|
||||
} else {
|
||||
command = IDC_RELOAD;
|
||||
}
|
||||
|
||||
// Start a timer - while this timer is running, the reload button cannot be
|
||||
// changed to a stop button. We do not set |intended_mode_| to Mode::kStop
|
||||
// here as the browser will do that when it actually starts loading (which
|
||||
// may happen synchronously, thus the need to do this before telling the
|
||||
// browser to execute the reload command).
|
||||
double_click_timer_.Start(FROM_HERE, double_click_timer_delay_, this,
|
||||
&ReloadButton::OnDoubleClickTimer);
|
||||
|
||||
ExecuteBrowserCommand(command, flags);
|
||||
++testing_reload_count_;
|
||||
}
|
||||
}
|
||||
|
||||
void ReloadButton::ExecuteBrowserCommand(int command, int event_flags) {
|
||||
if (!command_updater_)
|
||||
return;
|
||||
command_updater_->ExecuteCommandWithDisposition(
|
||||
command, ui::DispositionFromEventFlags(event_flags));
|
||||
}
|
||||
|
||||
void ReloadButton::OnDoubleClickTimer() {
|
||||
if (!IsMenuShowing())
|
||||
ChangeMode(intended_mode_, false);
|
||||
}
|
||||
|
||||
void ReloadButton::OnStopToReloadTimer() {
|
||||
DCHECK(!IsMenuShowing());
|
||||
ChangeMode(intended_mode_, true);
|
||||
}
|
||||
|
||||
BEGIN_METADATA(ReloadButton, ToolbarButton)
|
||||
ADD_PROPERTY_METADATA(bool, MenuEnabled)
|
||||
END_METADATA
|
Loading…
Reference in a new issue