Skip to content

Commit

Permalink
expose screenshot options to brave commander
Browse files Browse the repository at this point in the history
Enables the user to activate one of the screenshot methods via Brave Commander.
  • Loading branch information
jonathansampson committed Dec 24, 2024
1 parent d04a91b commit 2c374da
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions browser/ui/brave_browser_command_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "brave/browser/ai_chat/ai_chat_utils.h"
#include "brave/browser/profiles/profile_util.h"
#include "brave/browser/ui/brave_pages.h"
#include "brave/browser/ui/brave_screenshots_utils.h"
#include "brave/browser/ui/brave_ui_features.h"
#include "brave/browser/ui/browser_commands.h"
#include "brave/browser/ui/sidebar/sidebar_utils.h"
#include "brave/browser/ui/tabs/features.h"
Expand Down Expand Up @@ -322,6 +324,8 @@ void BraveBrowserCommandController::InitBraveCommandState() {
browser_->is_type_normal()) {
UpdateCommandForSplitView();
}

UpdateCommandsForBraveScreenshots();
}

void BraveBrowserCommandController::UpdateCommandForBraveRewards() {
Expand Down Expand Up @@ -478,6 +482,17 @@ void BraveBrowserCommandController::UpdateCommandForSplitView() {
}
}

void BraveBrowserCommandController::UpdateCommandsForBraveScreenshots() {
const bool enabled =
base::FeatureList::IsEnabled(features::kBraveScreenshots);
UpdateCommandEnabled(IDC_BRAVE_UTILS_START_SCREENSHOT_SELECTION_TO_CLIPBOARD,
enabled);
UpdateCommandEnabled(IDC_BRAVE_UTILS_SCREENSHOT_VIEWPORT_TO_CLIPBOARD,
enabled);
UpdateCommandEnabled(IDC_BRAVE_UTILS_SCREENSHOT_FULLPAGE_TO_CLIPBOARD,
enabled);
}

void BraveBrowserCommandController::UpdateCommandForBraveSync() {
UpdateCommandEnabled(IDC_SHOW_BRAVE_SYNC, true);
}
Expand Down Expand Up @@ -711,6 +726,17 @@ bool BraveBrowserCommandController::ExecuteBraveCommandWithDisposition(
case IDC_SWAP_SPLIT_VIEW:
brave::SwapTabsInTile(&*browser_);
break;
case IDC_BRAVE_UTILS_START_SCREENSHOT_SELECTION_TO_CLIPBOARD:
brave_utils::ScreenshotSelectionToClipboard(browser_->AsWeakPtr());
break;
case IDC_BRAVE_UTILS_SCREENSHOT_VIEWPORT_TO_CLIPBOARD:
brave_utils::ScreenshotViewportToClipboard(
browser_->tab_strip_model()->GetActiveWebContents()->GetWeakPtr());
break;
case IDC_BRAVE_UTILS_SCREENSHOT_FULLPAGE_TO_CLIPBOARD:
brave_utils::ScreenshotFullPageToClipboard(
browser_->tab_strip_model()->GetActiveWebContents()->GetWeakPtr());
break;
default:
LOG(WARNING) << "Received Unimplemented Command: " << id;
break;
Expand Down
1 change: 1 addition & 0 deletions browser/ui/brave_browser_command_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class BraveBrowserCommandController : public chrome::BrowserCommandController,
void UpdateCommandsForSend();
void UpdateCommandsForPin();
void UpdateCommandForSplitView();
void UpdateCommandsForBraveScreenshots();

bool ExecuteBraveCommandWithDisposition(int id,
WindowOpenDisposition disposition,
Expand Down

0 comments on commit 2c374da

Please sign in to comment.