#include "chrome/browser/ui/views/extensions/extensions_toolbar_container.h"
#include "chrome/browser/ui/views/frame/tab_strip_region_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
+#include "chrome/browser/ui/views/omnibox/omnibox_popup_view_views.h"
#include "chrome/browser/ui/views/tabs/tab_container_impl.h"
#include "chrome/browser/ui/views/toolbar/browser_app_menu_button.h"
#include "chrome/browser/ui/views/toolbar/toolbar_button.h"
constexpr int tabStripEndY = 35;
constexpr int toolbarMidY = 53;
constexpr int webViewStartY = 73;
+constexpr int mvPopupStartX = 151;
+constexpr int mvPopupStartY = 72;
constexpr int closeButtonX = 1898;
samsung_browser_main::NativePopupType nativePopupType = GetNativePopupType();
LOG(INFO) << "IsAnyNativePopupOpen: " << (int)nativePopupType;
+
+ if (isDirection && !is_popup_exists_ &&
+ keyType == samsung_browser_main::KeyEventType::Pressed &&
+ HandleMVPopupNavigation(key, x, y)) {
+ LOG(INFO) << "MVNavigation done";
+ return true;
+ }
BrowserAppMenuButton* menu_tree = browser_view_->toolbar()->app_menu_button();
ExtensionsToolbarContainer* extensions_container =
browser_view_->toolbar()->extensions_container();
}
}
+bool HybridNavigationController::HandleMVPopupNavigation(std::string key,
+ int x,
+ int y) {
+ LOG(INFO) << "";
+ auto cursor_controller =
+ samsung_browser_main::SamsungBrowserCore::instance()->CursorController();
+ OmniboxPopupView* popup =
+ browser_view_->GetLocationBarView()->GetOmniboxPopupView();
+ if (popup && popup->isMVOpen()) {
+ LOG(INFO) << "MV popup is open";
+ OmniboxPopupViewViews* opvv = static_cast<OmniboxPopupViewViews*>(popup);
+
+ views::View::Views popup_container = opvv->children();
+ views::View* first_child = popup_container[0];
+ views::View::Views rows = first_child->children();
+ LOG(INFO) << "OmniboxPopupViewViews rows size: " << rows.size();
+ if (!keynameArrowDown.compare(key)) {
+ LOG(INFO) << "On KeyEvent, KEY: UP";
+ views::View* nextFocusChild = nullptr;
+ int i = 1, x_min = 1000000, y_min = 1000000, x_final = 0, y_final = 0;
+ for (views::View* row : rows) {
+ views::View::Views row_childs = row->children();
+ int j = 1;
+ for (views::View* col : row_childs) {
+ j++;
+ int child_xcord = mvPopupStartX + col->x() + (col->width()) / 2;
+ int child_ycord =
+ mvPopupStartY + row->y() + col->y() + (col->height()) / 2;
+ if (x == child_xcord && y == child_ycord) {
+ continue;
+ }
+ int x_diff = x - child_xcord;
+ int y_diff = child_ycord - y;
+ if (y_diff <= 0) {
+ continue;
+ }
+ if (x_diff < 0) {
+ x_diff = -1 * x_diff;
+ }
+ if (x_diff <= x_min && y_diff <= y_min) {
+ LOG(INFO) << "Found better element";
+ x_min = x_diff;
+ y_min = y_diff;
+ x_final = child_xcord;
+ y_final = child_ycord;
+ nextFocusChild = col;
+ }
+ }
+ i++;
+ }
+ if (nextFocusChild) {
+ LOG(INFO) << "Moving focus to -> X: " << nextFocusChild->x()
+ << " Y: " << nextFocusChild->y()
+ << " Width: " << nextFocusChild->width()
+ << " height: " << nextFocusChild->height();
+ cursor_controller->MovePointerTo(x_final, y_final, true);
+ return true;
+ } else {
+ LOG(INFO) << "No element found, exiting from MV";
+ cursor_controller->MovePointerTo(
+ x, y + 70, true); // 70 is offset to exit from last entry
+ return true;
+ }
+ return false;
+ }
+
+ else if (!keynameArrowUp.compare(key)) {
+ LOG(INFO) << "On KeyEvent, KEY: UP";
+ if (y == toolbarMidY) {
+ LOG(INFO) << "Not inside MV popup, return to outside nav.";
+ return false;
+ }
+ views::View* nextFocusChild = nullptr;
+ int i = 1, x_min = 1000000, y_min = 1000000, x_final = 0, y_final = 0;
+ for (views::View* row : rows) {
+ LOG(INFO) << "Row: " << i;
+ views::View::Views row_childs = row->children();
+ int j = 1;
+ for (views::View* col : row_childs) {
+ j++;
+ int child_xcord = mvPopupStartX + col->x() + (col->width()) / 2;
+ int child_ycord =
+ mvPopupStartY + row->y() + col->y() + (col->height()) / 2;
+ if (x == child_xcord && y == child_ycord) {
+ continue;
+ }
+ int x_diff = x - child_xcord;
+ int y_diff = y - child_ycord;
+ if (y_diff <= 0) {
+ continue;
+ }
+ if (x_diff < 0) {
+ x_diff = -1 * x_diff;
+ }
+ if (x_diff <= x_min && y_diff <= y_min) {
+ LOG(INFO) << "Found better element";
+ x_min = x_diff;
+ y_min = y_diff;
+ x_final = child_xcord;
+ y_final = child_ycord;
+ nextFocusChild = col;
+ }
+ }
+ i++;
+ }
+ if (nextFocusChild) {
+ LOG(INFO) << "Moving focus to -> X: " << nextFocusChild->x()
+ << " Y: " << nextFocusChild->y()
+ << " Width: " << nextFocusChild->width()
+ << " height: " << nextFocusChild->height();
+ cursor_controller->MovePointerTo(x_final, y_final, true);
+ return true;
+ } else {
+ LOG(INFO) << "No element found, exiting from MV";
+ cursor_controller->MovePointerTo(923, 53,
+ true); // moving to center of url bar
+ return true;
+ }
+ return false;
+ }
+
+ else if (!keynameArrowLeft.compare(key)) {
+ LOG(INFO) << "On KeyEvent, KEY: UP";
+ if (y <= toolbarMidY) {
+ LOG(INFO) << "Not inside MV popup, return to outside nav.";
+ return false;
+ }
+ views::View* nextFocusChild = nullptr;
+ int i = 1, x_min = 1000000, y_min = 1000000, x_final = 0, y_final = 0;
+ for (views::View* row : rows) {
+ views::View::Views row_childs = row->children();
+ int j = 1;
+ for (views::View* col : row_childs) {
+ j++;
+ int child_xcord = mvPopupStartX + col->x() + (col->width()) / 2;
+ int child_ycord =
+ mvPopupStartY + row->y() + col->y() + (col->height()) / 2;
+ if (x == child_xcord && y == child_ycord) {
+ continue;
+ }
+ int x_diff = x - child_xcord;
+ int y_diff = y - child_ycord;
+ if (x_diff <= 0) {
+ continue;
+ }
+ if (y_diff < 0) {
+ y_diff = -1 * y_diff;
+ }
+ if (x_diff <= x_min && y_diff <= y_min) {
+ LOG(INFO) << "Found better element";
+ x_min = x_diff;
+ y_min = y_diff;
+ x_final = child_xcord;
+ y_final = child_ycord;
+ nextFocusChild = col;
+ }
+ }
+ i++;
+ }
+ if (nextFocusChild) {
+ LOG(INFO) << "Moving focus to -> X: " << nextFocusChild->x()
+ << " Y: " << nextFocusChild->y()
+ << " Width: " << nextFocusChild->width()
+ << " height: " << nextFocusChild->height();
+ cursor_controller->MovePointerTo(x_final, y_final, true);
+ return true;
+ } else {
+ LOG(INFO) << "No element found, exiting from MV";
+ cursor_controller->MovePointerTo(
+ x - 260, y, true); // 260 is offset to exit from left side of MV
+ return true;
+ }
+ return false;
+ }
+
+ else if (!keynameArrowRight.compare(key)) {
+ LOG(INFO) << "On KeyEvent, KEY: UP";
+ if (y <= toolbarMidY) {
+ LOG(INFO) << "Not inside MV popup, return to outside nav.";
+ return false;
+ }
+ views::View* nextFocusChild = nullptr;
+ int i = 1, x_min = 1000000, y_min = 1000000, x_final = 0, y_final = 0;
+ for (views::View* row : rows) {
+ views::View::Views row_childs = row->children();
+ int j = 1;
+ for (views::View* col : row_childs) {
+ j++;
+ int child_xcord = mvPopupStartX + col->x() + (col->width()) / 2;
+ int child_ycord =
+ mvPopupStartY + row->y() + col->y() + (col->height()) / 2;
+ if (x == child_xcord && y == child_ycord) {
+ continue;
+ }
+ int x_diff = child_xcord - x;
+ int y_diff = y - child_ycord;
+ if (x_diff <= 0) {
+ continue;
+ }
+ if (y_diff != 0) {
+ continue;
+ }
+ if (x_diff <= x_min && y_diff <= y_min) {
+ LOG(INFO) << "Found better element";
+ x_min = x_diff;
+ y_min = y_diff;
+ x_final = child_xcord;
+ y_final = child_ycord;
+ nextFocusChild = col;
+ }
+ }
+ i++;
+ }
+ if (nextFocusChild) {
+ LOG(INFO) << "Moving focus to -> X: " << nextFocusChild->x()
+ << " Y: " << nextFocusChild->y()
+ << " Width: " << nextFocusChild->width()
+ << " height: " << nextFocusChild->height();
+ cursor_controller->MovePointerTo(x_final, y_final, true);
+ return true;
+ } else {
+ LOG(INFO) << "No element found, exiting from MV";
+ cursor_controller->MovePointerTo(
+ 1730, y, true); // 1730 is offset to exit from right side of MV
+ return true;
+ }
+ return false;
+ }
+ }
+ return false;
+}
+
void HybridNavigationController::handleWebViewArea(std::string key,
int x,
int y) {