diff options
author | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-01 21:42:14 +0000 |
---|---|---|
committer | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-01 21:42:14 +0000 |
commit | 0c4c3884b89e0c5fb3adbbb0f3cdf092cda84a10 (patch) | |
tree | e942cc54be97b815ae60fdd7bbd65a2aa624d843 /chrome/browser/browser.cc | |
parent | 2ef2712ec860306a843c0e18afbdc339da4917cd (diff) | |
download | chromium_src-0c4c3884b89e0c5fb3adbbb0f3cdf092cda84a10.zip chromium_src-0c4c3884b89e0c5fb3adbbb0f3cdf092cda84a10.tar.gz chromium_src-0c4c3884b89e0c5fb3adbbb0f3cdf092cda84a10.tar.bz2 |
The "Copy URL" link is always greyed out in the Chrome menu on popups [crbug.com/13488].
This turns out to be because it was never implemented.
Tested manually on Windows; I'll test on Linux before submitting.
BUG=13488
TEST=Tested manually on Windows and added a unit test for the new Clipboard function.
Review URL: http://codereview.chromium.org/210042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27772 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser.cc')
-rw-r--r-- | chrome/browser/browser.cc | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 3df24ae..ae1b5538 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -9,6 +9,7 @@ #include "base/command_line.h" #include "base/keyboard_codes.h" #include "base/logging.h" +#include "base/scoped_clipboard_writer.h" #include "base/string_util.h" #include "base/thread.h" #include "chrome/app/chrome_dll_resource.h" @@ -856,6 +857,22 @@ void Browser::RestoreTab() { service->RestoreMostRecentEntry(this); } +void Browser::WriteCurrentURLToClipboard() { + // TODO(ericu): There isn't currently a metric for this. Should there be? + // We don't appear to track the action when it comes from the + // RenderContextViewMenu. + // UserMetrics::RecordAction(L"$Metric_Name_Goes_Here$", profile_); + + TabContents* contents = GetSelectedTabContents(); + if (!contents->ShouldDisplayURL()) + return; + + net::WriteURLToClipboard( + contents->GetURL(), + profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), + g_browser_process->clipboard()); +} + void Browser::ConvertPopupToTabbedBrowser() { UserMetrics::RecordAction(L"ShowAsTab", profile_); int tab_strip_index = tabstrip_model_.selected_index(); @@ -1347,6 +1364,7 @@ void Browser::ExecuteCommandWithDisposition( case IDC_SELECT_LAST_TAB: SelectLastTab(); break; case IDC_DUPLICATE_TAB: DuplicateTab(); break; case IDC_RESTORE_TAB: RestoreTab(); break; + case IDC_COPY_URL: WriteCurrentURLToClipboard(); break; case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; case IDC_FULLSCREEN: ToggleFullscreenMode(); break; case IDC_EXIT: Exit(); break; @@ -2300,6 +2318,7 @@ void Browser::InitCommandState() { command_updater_.UpdateCommandEnabled(IDC_CUT, true); command_updater_.UpdateCommandEnabled(IDC_COPY, true); command_updater_.UpdateCommandEnabled(IDC_PASTE, true); + command_updater_.UpdateCommandEnabled(IDC_COPY_URL, true); // Find-in-page command_updater_.UpdateCommandEnabled(IDC_FIND, true); @@ -2367,9 +2386,6 @@ void Browser::InitCommandState() { // Page-related commands command_updater_.UpdateCommandEnabled(IDC_STAR, normal_window); - // Clipboard commands - command_updater_.UpdateCommandEnabled(IDC_COPY_URL, normal_window); - // Show various bits of UI command_updater_.UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, normal_window); |