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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 11734015: Fix clipboard operations through the wrench menu not working in the find bar or other controls. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: make work with devtools Created 7 years, 11 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/ui/views/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 #include "ui/base/accessibility/accessible_view_state.h" 105 #include "ui/base/accessibility/accessible_view_state.h"
106 #include "ui/base/events/event_utils.h" 106 #include "ui/base/events/event_utils.h"
107 #include "ui/base/hit_test.h" 107 #include "ui/base/hit_test.h"
108 #include "ui/base/l10n/l10n_util.h" 108 #include "ui/base/l10n/l10n_util.h"
109 #include "ui/base/resource/resource_bundle.h" 109 #include "ui/base/resource/resource_bundle.h"
110 #include "ui/gfx/canvas.h" 110 #include "ui/gfx/canvas.h"
111 #include "ui/gfx/color_utils.h" 111 #include "ui/gfx/color_utils.h"
112 #include "ui/gfx/safe_integer_conversions.h" 112 #include "ui/gfx/safe_integer_conversions.h"
113 #include "ui/gfx/sys_color_change_listener.h" 113 #include "ui/gfx/sys_color_change_listener.h"
114 #include "ui/views/controls/single_split_view.h" 114 #include "ui/views/controls/single_split_view.h"
115 #include "ui/views/controls/textfield/textfield.h"
115 #include "ui/views/controls/webview/webview.h" 116 #include "ui/views/controls/webview/webview.h"
116 #include "ui/views/focus/external_focus_tracker.h" 117 #include "ui/views/focus/external_focus_tracker.h"
117 #include "ui/views/focus/view_storage.h" 118 #include "ui/views/focus/view_storage.h"
118 #include "ui/views/layout/grid_layout.h" 119 #include "ui/views/layout/grid_layout.h"
119 #include "ui/views/widget/native_widget.h" 120 #include "ui/views/widget/native_widget.h"
120 #include "ui/views/widget/root_view.h" 121 #include "ui/views/widget/root_view.h"
121 #include "ui/views/widget/widget.h" 122 #include "ui/views/widget/widget.h"
122 #include "ui/views/window/dialog_delegate.h" 123 #include "ui/views/window/dialog_delegate.h"
123 124
124 #if defined(USE_ASH) 125 #if defined(USE_ASH)
(...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 // anything. When someone selects the menu item, we just act as if they hit 1501 // anything. When someone selects the menu item, we just act as if they hit
1501 // the keyboard shortcut for the command by sending the associated key press 1502 // the keyboard shortcut for the command by sending the associated key press
1502 // to windows. The real fix to this bug is to disable the commands when they 1503 // to windows. The real fix to this bug is to disable the commands when they
1503 // won't do anything. We'll need something like an overall clipboard command 1504 // won't do anything. We'll need something like an overall clipboard command
1504 // manager to do that. 1505 // manager to do that.
1505 void BrowserView::Cut() { 1506 void BrowserView::Cut() {
1506 // If a WebContent is focused, call RenderWidgetHost::Cut. Otherwise, e.g. if 1507 // If a WebContent is focused, call RenderWidgetHost::Cut. Otherwise, e.g. if
1507 // Omnibox is focused, send a Ctrl+x key event to Chrome. Using RWH interface 1508 // Omnibox is focused, send a Ctrl+x key event to Chrome. Using RWH interface
1508 // rather than the fake key event for a WebContent is important since the fake 1509 // rather than the fake key event for a WebContent is important since the fake
1509 // event might be consumed by the web content (crbug.com/137908). 1510 // event might be consumed by the web content (crbug.com/137908).
1510 if (DoCutCopyPaste(&content::RenderWidgetHost::Cut)) 1511 DoCutCopyPaste(&content::RenderWidgetHost::Cut,
1511 return; 1512 #if defined(OS_WIN)
1512 1513 WM_CUT,
1513 OmniboxView* omnibox_view = GetLocationBarView()->GetLocationEntry();
1514 if (!omnibox_view->model()->has_focus())
1515 return;
1516
1517 #if defined(OS_WIN) && !defined(USE_AURA)
1518 OmniboxViewWin* omnibox_win = GetOmniboxViewWin(omnibox_view);
1519 if (omnibox_win) {
1520 ::SendMessage(omnibox_win->GetNativeView(), WM_CUT, 0, 0);
1521 return;
1522 }
1523 #endif 1514 #endif
1524 1515 IDS_APP_CUT);
1525 OmniboxViewViews* omnibox_views = GetOmniboxViewViews(omnibox_view);
1526 omnibox_views->ExecuteCommandOnTextField(IDS_APP_CUT);
1527 } 1516 }
1528 1517
1529 void BrowserView::Copy() { 1518 void BrowserView::Copy() {
1530 if (DoCutCopyPaste(&content::RenderWidgetHost::Copy)) 1519 DoCutCopyPaste(&content::RenderWidgetHost::Copy,
1531 return; 1520 #if defined(OS_WIN)
1532 1521 WM_COPY,
1533 OmniboxView* omnibox_view = GetLocationBarView()->GetLocationEntry();
1534 if (!omnibox_view->model()->has_focus())
1535 return;
1536
1537 #if defined(OS_WIN) && !defined(USE_AURA)
1538 OmniboxViewWin* omnibox_win = GetOmniboxViewWin(omnibox_view);
1539 if (omnibox_win) {
1540 ::SendMessage(omnibox_win->GetNativeView(), WM_COPY, 0, 0);
1541 return;
1542 }
1543 #endif 1522 #endif
1544 1523 IDS_APP_COPY);
1545 OmniboxViewViews* omnibox_views = GetOmniboxViewViews(omnibox_view);
1546 omnibox_views->ExecuteCommandOnTextField(IDS_APP_COPY);
1547 } 1524 }
1548 1525
1549 void BrowserView::Paste() { 1526 void BrowserView::Paste() {
1550 if (DoCutCopyPaste(&content::RenderWidgetHost::Paste)) 1527 DoCutCopyPaste(&content::RenderWidgetHost::Paste,
1551 return; 1528 #if defined(OS_WIN)
1552 1529 WM_PASTE,
1553 OmniboxView* omnibox_view = GetLocationBarView()->GetLocationEntry();
1554 if (!omnibox_view->model()->has_focus())
1555 return;
1556
1557 #if defined(OS_WIN) && !defined(USE_AURA)
1558 OmniboxViewWin* omnibox_win = GetOmniboxViewWin(omnibox_view);
1559 if (omnibox_win) {
1560 ::SendMessage(omnibox_win->GetNativeView(), WM_PASTE, 0, 0);
1561 return;
1562 }
1563 #endif 1530 #endif
1564 1531 IDS_APP_PASTE);
1565 OmniboxViewViews* omnibox_views = GetOmniboxViewViews(omnibox_view);
1566 omnibox_views->ExecuteCommandOnTextField(IDS_APP_PASTE);
1567 } 1532 }
1568 1533
1569 gfx::Rect BrowserView::GetInstantBounds() { 1534 gfx::Rect BrowserView::GetInstantBounds() {
1570 return contents_->GetPreviewBounds(); 1535 return contents_->GetPreviewBounds();
1571 } 1536 }
1572 1537
1573 bool BrowserView::IsInstantTabShowing() { 1538 bool BrowserView::IsInstantTabShowing() {
1574 return preview_controller_->preview() != NULL; 1539 return preview_controller_->preview() != NULL;
1575 } 1540 }
1576 1541
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2774 PasswordManager::FromWebContents(web_contents), 2739 PasswordManager::FromWebContents(web_contents),
2775 password_generator, 2740 password_generator,
2776 browser_.get(), 2741 browser_.get(),
2777 GetWidget()->GetThemeProvider()); 2742 GetWidget()->GetThemeProvider());
2778 2743
2779 views::BubbleDelegateView::CreateBubble(bubble); 2744 views::BubbleDelegateView::CreateBubble(bubble);
2780 bubble->SetAlignment(views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR); 2745 bubble->SetAlignment(views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR);
2781 bubble->Show(); 2746 bubble->Show();
2782 } 2747 }
2783 2748
2784 bool BrowserView::DoCutCopyPaste(void (content::RenderWidgetHost::*method)()) { 2749 void BrowserView::DoCutCopyPaste(void (content::RenderWidgetHost::*method)(),
2750 #if defined(OS_WIN)
2751 int windows_msg_id,
2752 #endif
2753 int command_id) {
2785 WebContents* contents = chrome::GetActiveWebContents(browser_.get()); 2754 WebContents* contents = chrome::GetActiveWebContents(browser_.get());
2786 if (!contents) 2755 if (!contents)
2787 return false; 2756 return;
2757 if (DoCutCopyPasteForWebContents(contents, method))
2758 return;
2759
2760 DevToolsWindow* devtools_window =
2761 DevToolsWindow::GetDockedInstanceForInspectedTab(contents);
2762 if (devtools_window &&
2763 DoCutCopyPasteForWebContents(devtools_window->web_contents(), method)) {
2764 return;
2765 }
2766
2767 views::FocusManager* focus_manager = GetFocusManager();
2768 views::View* focused = focus_manager->GetFocusedView();
2769 if (focused->GetClassName() == views::Textfield::kViewClassName) {
2770 views::Textfield* textfield = static_cast<views::Textfield*>(focused);
2771 textfield->ExecuteCommand(command_id);
2772 return;
2773 }
2774
2775 #if defined(OS_WIN) && !defined(USE_AURA)
2776 OmniboxView* omnibox_view = GetLocationBarView()->GetLocationEntry();
2777 if (omnibox_view->model()->has_focus()) {
2778 OmniboxViewWin* omnibox_win = GetOmniboxViewWin(omnibox_view);
2779 ::SendMessage(omnibox_win->GetNativeView(), windows_msg_id, 0, 0);
2780 }
2781 #endif
2782 }
2783
2784 bool BrowserView::DoCutCopyPasteForWebContents(
2785 WebContents* contents,
2786 void (content::RenderWidgetHost::*method)()) {
2788 gfx::NativeView native_view = contents->GetContentNativeView(); 2787 gfx::NativeView native_view = contents->GetContentNativeView();
2789 if (!native_view) 2788 if (!native_view)
2790 return false; 2789 return false;
2791 #if defined(USE_AURA) 2790 #if defined(USE_AURA)
2792 if (native_view->HasFocus()) { 2791 if (native_view->HasFocus()) {
2793 #elif defined(OS_WIN) 2792 #elif defined(OS_WIN)
2794 if (native_view == ::GetFocus()) { 2793 if (native_view == ::GetFocus()) {
2795 #endif 2794 #endif
2796 (contents->GetRenderViewHost()->*method)(); 2795 (contents->GetRenderViewHost()->*method)();
2797 return true; 2796 return true;
(...skipping 16 matching lines...) Expand all
2814 modal_browser->window()->Activate(); 2813 modal_browser->window()->Activate();
2815 } 2814 }
2816 2815
2817 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); 2816 AppModalDialogQueue::GetInstance()->ActivateModalDialog();
2818 } 2817 }
2819 2818
2820 void BrowserView::MaybeStackBookmarkBarAtTop() { 2819 void BrowserView::MaybeStackBookmarkBarAtTop() {
2821 if (bookmark_bar_view_.get()) 2820 if (bookmark_bar_view_.get())
2822 bookmark_bar_view_->MaybeStackAtTop(); 2821 bookmark_bar_view_->MaybeStackAtTop();
2823 } 2822 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/browser/ui/views/omnibox/omnibox_view_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698