Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: chrome/browser/browser.cc

Issue 164446: linux: More automation porting. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: automation ipc messages hack fix Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/browser.h" 5 #include "chrome/browser/browser.h"
6 6
7 #include "app/animation.h" 7 #include "app/animation.h"
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/idle_timer.h" 10 #include "base/idle_timer.h"
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always 1008 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always
1009 // enabled in the page menu regardless of whether the command will do 1009 // enabled in the page menu regardless of whether the command will do
1010 // anything. When someone selects the menu item, we just act as if they hit 1010 // anything. When someone selects the menu item, we just act as if they hit
1011 // the keyboard shortcut for the command by sending the associated key press 1011 // the keyboard shortcut for the command by sending the associated key press
1012 // to windows. The real fix to this bug is to disable the commands when they 1012 // to windows. The real fix to this bug is to disable the commands when they
1013 // won't do anything. We'll need something like an overall clipboard command 1013 // won't do anything. We'll need something like an overall clipboard command
1014 // manager to do that. 1014 // manager to do that.
1015 1015
1016 void Browser::Cut() { 1016 void Browser::Cut() {
1017 UserMetrics::RecordAction(L"Cut", profile_); 1017 UserMetrics::RecordAction(L"Cut", profile_);
1018 ui_controls::SendKeyPress(L'X', true, false, false); 1018 ui_controls::SendKeyPress(window()->GetNativeHandle(), L'X', true, false,
1019 false);
1019 } 1020 }
1020 1021
1021 void Browser::Copy() { 1022 void Browser::Copy() {
1022 UserMetrics::RecordAction(L"Copy", profile_); 1023 UserMetrics::RecordAction(L"Copy", profile_);
1023 ui_controls::SendKeyPress(L'C', true, false, false); 1024 ui_controls::SendKeyPress(window()->GetNativeHandle(), L'C', true, false,
1025 false);
1024 } 1026 }
1025 1027
1026 void Browser::CopyCurrentPageURL() { 1028 void Browser::CopyCurrentPageURL() {
1027 UserMetrics::RecordAction(L"CopyURLToClipBoard", profile_); 1029 UserMetrics::RecordAction(L"CopyURLToClipBoard", profile_);
1028 std::string url = GetSelectedTabContents()->GetURL().spec(); 1030 std::string url = GetSelectedTabContents()->GetURL().spec();
1029 1031
1030 if (!::OpenClipboard(NULL)) { 1032 if (!::OpenClipboard(NULL)) {
1031 NOTREACHED(); 1033 NOTREACHED();
1032 return; 1034 return;
1033 } 1035 }
1034 1036
1035 if (::EmptyClipboard()) { 1037 if (::EmptyClipboard()) {
1036 HGLOBAL text = ::GlobalAlloc(GMEM_MOVEABLE, url.size() + 1); 1038 HGLOBAL text = ::GlobalAlloc(GMEM_MOVEABLE, url.size() + 1);
1037 LPSTR ptr = static_cast<LPSTR>(::GlobalLock(text)); 1039 LPSTR ptr = static_cast<LPSTR>(::GlobalLock(text));
1038 memcpy(ptr, url.c_str(), url.size()); 1040 memcpy(ptr, url.c_str(), url.size());
1039 ptr[url.size()] = '\0'; 1041 ptr[url.size()] = '\0';
1040 ::GlobalUnlock(text); 1042 ::GlobalUnlock(text);
1041 1043
1042 ::SetClipboardData(CF_TEXT, text); 1044 ::SetClipboardData(CF_TEXT, text);
1043 } 1045 }
1044 1046
1045 if (!::CloseClipboard()) { 1047 if (!::CloseClipboard()) {
1046 NOTREACHED(); 1048 NOTREACHED();
1047 } 1049 }
1048 } 1050 }
1049 1051
1050 void Browser::Paste() { 1052 void Browser::Paste() {
1051 UserMetrics::RecordAction(L"Paste", profile_); 1053 UserMetrics::RecordAction(L"Paste", profile_);
1052 ui_controls::SendKeyPress(L'V', true, false, false); 1054 ui_controls::SendKeyPress(window()->GetNativeHandle(), L'V', true, false,
1055 false);
1053 } 1056 }
1054 #endif // #if defined(OS_WIN) 1057 #endif // #if defined(OS_WIN)
1055 1058
1056 void Browser::Find() { 1059 void Browser::Find() {
1057 UserMetrics::RecordAction(L"Find", profile_); 1060 UserMetrics::RecordAction(L"Find", profile_);
1058 FindInPage(false, false); 1061 FindInPage(false, false);
1059 } 1062 }
1060 1063
1061 void Browser::FindNext() { 1064 void Browser::FindNext() {
1062 UserMetrics::RecordAction(L"FindNext", profile_); 1065 UserMetrics::RecordAction(L"FindNext", profile_);
(...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after
2795 /////////////////////////////////////////////////////////////////////////////// 2798 ///////////////////////////////////////////////////////////////////////////////
2796 // BrowserToolbarModel (private): 2799 // BrowserToolbarModel (private):
2797 2800
2798 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { 2801 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() {
2799 // This |current_tab| can be NULL during the initialization of the 2802 // This |current_tab| can be NULL during the initialization of the
2800 // toolbar during window creation (i.e. before any tabs have been added 2803 // toolbar during window creation (i.e. before any tabs have been added
2801 // to the window). 2804 // to the window).
2802 TabContents* current_tab = browser_->GetSelectedTabContents(); 2805 TabContents* current_tab = browser_->GetSelectedTabContents();
2803 return current_tab ? &current_tab->controller() : NULL; 2806 return current_tab ? &current_tab->controller() : NULL;
2804 } 2807 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698