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

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

Issue 183923030: Almost finish moving context_menu_node_ from RenderViewImpl to RenderFrameImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 9 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 93 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
94 #include "chrome/browser/ui/window_sizer/window_sizer.h" 94 #include "chrome/browser/ui/window_sizer/window_sizer.h"
95 #include "chrome/common/chrome_switches.h" 95 #include "chrome/common/chrome_switches.h"
96 #include "chrome/common/pref_names.h" 96 #include "chrome/common/pref_names.h"
97 #include "chrome/common/profile_management_switches.h" 97 #include "chrome/common/profile_management_switches.h"
98 #include "chrome/common/url_constants.h" 98 #include "chrome/common/url_constants.h"
99 #include "components/password_manager/core/browser/password_manager.h" 99 #include "components/password_manager/core/browser/password_manager.h"
100 #include "content/public/browser/download_manager.h" 100 #include "content/public/browser/download_manager.h"
101 #include "content/public/browser/native_web_keyboard_event.h" 101 #include "content/public/browser/native_web_keyboard_event.h"
102 #include "content/public/browser/notification_service.h" 102 #include "content/public/browser/notification_service.h"
103 #include "content/public/browser/render_frame_host.h"
103 #include "content/public/browser/render_view_host.h" 104 #include "content/public/browser/render_view_host.h"
104 #include "content/public/browser/render_widget_host.h"
105 #include "content/public/browser/user_metrics.h" 105 #include "content/public/browser/user_metrics.h"
106 #include "content/public/browser/web_contents.h" 106 #include "content/public/browser/web_contents.h"
107 #include "content/public/browser/web_contents_view.h" 107 #include "content/public/browser/web_contents_view.h"
108 #include "content/public/common/content_switches.h" 108 #include "content/public/common/content_switches.h"
109 #include "grit/chromium_strings.h" 109 #include "grit/chromium_strings.h"
110 #include "grit/generated_resources.h" 110 #include "grit/generated_resources.h"
111 #include "grit/locale_settings.h" 111 #include "grit/locale_settings.h"
112 #include "grit/theme_resources.h" 112 #include "grit/theme_resources.h"
113 #include "grit/ui_resources.h" 113 #include "grit/ui_resources.h"
114 #include "grit/ui_strings.h" 114 #include "grit/ui_strings.h"
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 } 1412 }
1413 1413
1414 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always 1414 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always
1415 // enabled in the page menu regardless of whether the command will do 1415 // enabled in the page menu regardless of whether the command will do
1416 // anything. When someone selects the menu item, we just act as if they hit 1416 // anything. When someone selects the menu item, we just act as if they hit
1417 // the keyboard shortcut for the command by sending the associated key press 1417 // the keyboard shortcut for the command by sending the associated key press
1418 // to windows. The real fix to this bug is to disable the commands when they 1418 // to windows. The real fix to this bug is to disable the commands when they
1419 // won't do anything. We'll need something like an overall clipboard command 1419 // won't do anything. We'll need something like an overall clipboard command
1420 // manager to do that. 1420 // manager to do that.
1421 void BrowserView::Cut() { 1421 void BrowserView::Cut() {
1422 // If a WebContent is focused, call RenderWidgetHost::Cut. Otherwise, e.g. if 1422 // If a WebContent is focused, call RenderFrameHost::Cut. Otherwise, e.g. if
1423 // Omnibox is focused, send a Ctrl+x key event to Chrome. Using RWH interface 1423 // Omnibox is focused, send a Ctrl+x key event to Chrome. Using RWH interface
1424 // rather than the fake key event for a WebContent is important since the fake 1424 // rather than the fake key event for a WebContent is important since the fake
1425 // event might be consumed by the web content (crbug.com/137908). 1425 // event might be consumed by the web content (crbug.com/137908).
1426 DoCutCopyPaste(&content::RenderWidgetHost::Cut, IDS_APP_CUT); 1426 DoCutCopyPaste(&content::RenderFrameHost::Cut, IDS_APP_CUT);
1427 } 1427 }
1428 1428
1429 void BrowserView::Copy() { 1429 void BrowserView::Copy() {
1430 DoCutCopyPaste(&content::RenderWidgetHost::Copy, IDS_APP_COPY); 1430 DoCutCopyPaste(&content::RenderFrameHost::Copy, IDS_APP_COPY);
1431 } 1431 }
1432 1432
1433 void BrowserView::Paste() { 1433 void BrowserView::Paste() {
1434 DoCutCopyPaste(&content::RenderWidgetHost::Paste, IDS_APP_PASTE); 1434 DoCutCopyPaste(&content::RenderFrameHost::Paste, IDS_APP_PASTE);
1435 } 1435 }
1436 1436
1437 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds( 1437 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds(
1438 const gfx::Rect& bounds) { 1438 const gfx::Rect& bounds) {
1439 #if defined(OS_WIN) 1439 #if defined(OS_WIN)
1440 // If we are in Win8's single window Metro mode, we can't allow popup windows. 1440 // If we are in Win8's single window Metro mode, we can't allow popup windows.
1441 return win8::IsSingleWindowMetroMode() ? NEW_BACKGROUND_TAB : NEW_POPUP; 1441 return win8::IsSingleWindowMetroMode() ? NEW_BACKGROUND_TAB : NEW_POPUP;
1442 #else 1442 #else
1443 return NEW_POPUP; 1443 return NEW_POPUP;
1444 #endif 1444 #endif
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
2512 void BrowserView::ShowPageActionPopup( 2512 void BrowserView::ShowPageActionPopup(
2513 const extensions::Extension* extension) { 2513 const extensions::Extension* extension) {
2514 toolbar_->ShowPageActionPopup(extension); 2514 toolbar_->ShowPageActionPopup(extension);
2515 } 2515 }
2516 2516
2517 void BrowserView::ShowBrowserActionPopup( 2517 void BrowserView::ShowBrowserActionPopup(
2518 const extensions::Extension* extension) { 2518 const extensions::Extension* extension) {
2519 toolbar_->ShowBrowserActionPopup(extension); 2519 toolbar_->ShowBrowserActionPopup(extension);
2520 } 2520 }
2521 2521
2522 void BrowserView::DoCutCopyPaste(void (content::RenderWidgetHost::*method)(), 2522 void BrowserView::DoCutCopyPaste(void (content::RenderFrameHost::*method)(),
2523 int command_id) { 2523 int command_id) {
2524 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); 2524 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents();
2525 if (!contents) 2525 if (!contents)
2526 return; 2526 return;
2527 if (DoCutCopyPasteForWebContents(contents, method)) 2527 if (DoCutCopyPasteForWebContents(contents, method))
2528 return; 2528 return;
2529 2529
2530 DevToolsWindow* devtools_window = 2530 DevToolsWindow* devtools_window =
2531 DevToolsWindow::GetDockedInstanceForInspectedTab(contents); 2531 DevToolsWindow::GetDockedInstanceForInspectedTab(contents);
2532 if (devtools_window && 2532 if (devtools_window &&
2533 DoCutCopyPasteForWebContents(devtools_window->web_contents(), method)) { 2533 DoCutCopyPasteForWebContents(devtools_window->web_contents(), method)) {
2534 return; 2534 return;
2535 } 2535 }
2536 2536
2537 views::FocusManager* focus_manager = GetFocusManager(); 2537 views::FocusManager* focus_manager = GetFocusManager();
2538 views::View* focused = focus_manager->GetFocusedView(); 2538 views::View* focused = focus_manager->GetFocusedView();
2539 if (focused && 2539 if (focused &&
2540 (!strcmp(focused->GetClassName(), views::Textfield::kViewClassName) || 2540 (!strcmp(focused->GetClassName(), views::Textfield::kViewClassName) ||
2541 !strcmp(focused->GetClassName(), OmniboxViewViews::kViewClassName))) { 2541 !strcmp(focused->GetClassName(), OmniboxViewViews::kViewClassName))) {
2542 views::Textfield* textfield = static_cast<views::Textfield*>(focused); 2542 views::Textfield* textfield = static_cast<views::Textfield*>(focused);
2543 textfield->ExecuteCommand(command_id); 2543 textfield->ExecuteCommand(command_id);
2544 } 2544 }
2545 } 2545 }
2546 2546
2547 bool BrowserView::DoCutCopyPasteForWebContents( 2547 bool BrowserView::DoCutCopyPasteForWebContents(
2548 WebContents* contents, 2548 WebContents* contents,
2549 void (content::RenderWidgetHost::*method)()) { 2549 void (content::RenderFrameHost::*method)()) {
2550 gfx::NativeView native_view = contents->GetView()->GetContentNativeView(); 2550 gfx::NativeView native_view = contents->GetView()->GetContentNativeView();
2551 if (!native_view) 2551 if (!native_view)
2552 return false; 2552 return false;
2553 #if defined(USE_AURA) 2553 #if defined(USE_AURA)
2554 if (native_view->HasFocus()) { 2554 if (native_view->HasFocus()) {
2555 #elif defined(OS_WIN) 2555 #elif defined(OS_WIN)
2556 if (native_view == ::GetFocus()) { 2556 if (native_view == ::GetFocus()) {
2557 #endif 2557 #endif
2558 (contents->GetRenderViewHost()->*method)(); 2558 content::RenderFrameHost* frame =
2559 contents->GetRenderViewHost()->GetFocusedFrame();
2560 if (frame)
2561 (frame->*method)();
2559 return true; 2562 return true;
2560 } 2563 }
2561 2564
2562 return false; 2565 return false;
2563 } 2566 }
2564 2567
2565 void BrowserView::ActivateAppModalDialog() const { 2568 void BrowserView::ActivateAppModalDialog() const {
2566 // If another browser is app modal, flash and activate the modal browser. 2569 // If another browser is app modal, flash and activate the modal browser.
2567 AppModalDialog* active_dialog = 2570 AppModalDialog* active_dialog =
2568 AppModalDialogQueue::GetInstance()->active_dialog(); 2571 AppModalDialogQueue::GetInstance()->active_dialog();
(...skipping 18 matching lines...) Expand all
2587 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { 2590 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) {
2588 gfx::Point icon_bottom( 2591 gfx::Point icon_bottom(
2589 toolbar_->location_bar()->GetLocationBarAnchorPoint()); 2592 toolbar_->location_bar()->GetLocationBarAnchorPoint());
2590 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); 2593 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom);
2591 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); 2594 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL));
2592 ConvertPointToTarget(infobar_container_, this, &infobar_top); 2595 ConvertPointToTarget(infobar_container_, this, &infobar_top);
2593 top_arrow_height = infobar_top.y() - icon_bottom.y(); 2596 top_arrow_height = infobar_top.y() - icon_bottom.y();
2594 } 2597 }
2595 return top_arrow_height; 2598 return top_arrow_height;
2596 } 2599 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698