| OLD | NEW |
| 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 last_focused_view_storage_id_( | 388 last_focused_view_storage_id_( |
| 389 views::ViewStorage::GetInstance()->CreateStorageID()), | 389 views::ViewStorage::GetInstance()->CreateStorageID()), |
| 390 frame_(NULL), | 390 frame_(NULL), |
| 391 top_container_(NULL), | 391 top_container_(NULL), |
| 392 tabstrip_(NULL), | 392 tabstrip_(NULL), |
| 393 toolbar_(NULL), | 393 toolbar_(NULL), |
| 394 find_bar_host_view_(NULL), | 394 find_bar_host_view_(NULL), |
| 395 infobar_container_(NULL), | 395 infobar_container_(NULL), |
| 396 contents_web_view_(NULL), | 396 contents_web_view_(NULL), |
| 397 contents_container_(NULL), | 397 contents_container_(NULL), |
| 398 devtools_window_(NULL), | |
| 399 initialized_(false), | 398 initialized_(false), |
| 400 in_process_fullscreen_(false), | 399 in_process_fullscreen_(false), |
| 401 #if defined(OS_WIN) | 400 #if defined(OS_WIN) |
| 402 hung_window_detector_(&hung_plugin_action_), | 401 hung_window_detector_(&hung_plugin_action_), |
| 403 ticker_(0), | 402 ticker_(0), |
| 404 #endif | 403 #endif |
| 405 force_location_bar_focus_(false), | 404 force_location_bar_focus_(false), |
| 406 #if defined(OS_CHROMEOS) | 405 #if defined(OS_CHROMEOS) |
| 407 scroll_end_effect_controller_(ScrollEndEffectController::Create()), | 406 scroll_end_effect_controller_(ScrollEndEffectController::Create()), |
| 408 #endif | 407 #endif |
| (...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2092 | 2091 |
| 2093 bool BrowserView::MaybeShowInfoBar(WebContents* contents) { | 2092 bool BrowserView::MaybeShowInfoBar(WebContents* contents) { |
| 2094 // TODO(beng): Remove this function once the interface between | 2093 // TODO(beng): Remove this function once the interface between |
| 2095 // InfoBarContainer, DownloadShelfView and WebContents and this | 2094 // InfoBarContainer, DownloadShelfView and WebContents and this |
| 2096 // view is sorted out. | 2095 // view is sorted out. |
| 2097 return true; | 2096 return true; |
| 2098 } | 2097 } |
| 2099 | 2098 |
| 2100 void BrowserView::UpdateDevToolsForContents( | 2099 void BrowserView::UpdateDevToolsForContents( |
| 2101 WebContents* web_contents, bool update_devtools_web_contents) { | 2100 WebContents* web_contents, bool update_devtools_web_contents) { |
| 2102 DevToolsWindow* new_devtools_window = web_contents ? | 2101 DevToolsContentsResizingStrategy strategy; |
| 2103 DevToolsWindow::GetDockedInstanceForInspectedTab(web_contents) : NULL; | 2102 WebContents* devtools = DevToolsWindow::GetInTabWebContents( |
| 2103 web_contents, &strategy); |
| 2104 | 2104 |
| 2105 // Replace devtools WebContents. | 2105 if (!devtools_web_view_->web_contents() && devtools && |
| 2106 WebContents* new_contents = new_devtools_window ? | |
| 2107 new_devtools_window->web_contents() : NULL; | |
| 2108 if (devtools_web_view_->web_contents() != new_contents && | |
| 2109 update_devtools_web_contents) { | |
| 2110 devtools_web_view_->SetWebContents(new_contents); | |
| 2111 } | |
| 2112 | |
| 2113 if (!devtools_window_ && new_devtools_window && | |
| 2114 !devtools_focus_tracker_.get()) { | 2106 !devtools_focus_tracker_.get()) { |
| 2115 // Install devtools focus tracker when dev tools window is shown for the | 2107 // Install devtools focus tracker when dev tools window is shown for the |
| 2116 // first time. | 2108 // first time. |
| 2117 devtools_focus_tracker_.reset( | 2109 devtools_focus_tracker_.reset( |
| 2118 new views::ExternalFocusTracker(devtools_web_view_, | 2110 new views::ExternalFocusTracker(devtools_web_view_, |
| 2119 GetFocusManager())); | 2111 GetFocusManager())); |
| 2120 } | 2112 } |
| 2121 | 2113 |
| 2122 // Restore focus to the last focused view when hiding devtools window. | 2114 // Restore focus to the last focused view when hiding devtools window. |
| 2123 if (devtools_window_ && !new_devtools_window && | 2115 if (devtools_web_view_->web_contents() && !devtools && |
| 2124 devtools_focus_tracker_.get()) { | 2116 devtools_focus_tracker_.get()) { |
| 2125 devtools_focus_tracker_->FocusLastFocusedExternalView(); | 2117 devtools_focus_tracker_->FocusLastFocusedExternalView(); |
| 2126 devtools_focus_tracker_.reset(); | 2118 devtools_focus_tracker_.reset(); |
| 2127 } | 2119 } |
| 2128 | 2120 |
| 2129 devtools_window_ = new_devtools_window; | 2121 // Replace devtools WebContents. |
| 2130 if (devtools_window_) { | 2122 if (devtools_web_view_->web_contents() != devtools && |
| 2131 devtools_web_view_->SetPreferredSize(devtools_window_->GetMinimumSize()); | 2123 update_devtools_web_contents) { |
| 2124 devtools_web_view_->SetWebContents(devtools); |
| 2125 } |
| 2126 |
| 2127 if (devtools) { |
| 2132 devtools_web_view_->SetVisible(true); | 2128 devtools_web_view_->SetVisible(true); |
| 2133 GetContentsLayoutManager()->SetContentsResizingStrategy( | 2129 GetContentsLayoutManager()->SetContentsResizingStrategy(strategy); |
| 2134 devtools_window_->GetContentsResizingStrategy()); | |
| 2135 } else { | 2130 } else { |
| 2136 devtools_web_view_->SetVisible(false); | 2131 devtools_web_view_->SetVisible(false); |
| 2137 GetContentsLayoutManager()->SetContentsResizingStrategy( | 2132 GetContentsLayoutManager()->SetContentsResizingStrategy( |
| 2138 DevToolsContentsResizingStrategy()); | 2133 DevToolsContentsResizingStrategy()); |
| 2139 } | 2134 } |
| 2140 contents_container_->Layout(); | 2135 contents_container_->Layout(); |
| 2141 } | 2136 } |
| 2142 | 2137 |
| 2143 void BrowserView::UpdateUIForContents(WebContents* contents) { | 2138 void BrowserView::UpdateUIForContents(WebContents* contents) { |
| 2144 bool needs_layout = MaybeShowBookmarkBar(contents); | 2139 bool needs_layout = MaybeShowBookmarkBar(contents); |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2492 } | 2487 } |
| 2493 | 2488 |
| 2494 void BrowserView::DoCutCopyPaste(void (WebContents::*method)(), | 2489 void BrowserView::DoCutCopyPaste(void (WebContents::*method)(), |
| 2495 int command_id) { | 2490 int command_id) { |
| 2496 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); | 2491 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); |
| 2497 if (!contents) | 2492 if (!contents) |
| 2498 return; | 2493 return; |
| 2499 if (DoCutCopyPasteForWebContents(contents, method)) | 2494 if (DoCutCopyPasteForWebContents(contents, method)) |
| 2500 return; | 2495 return; |
| 2501 | 2496 |
| 2502 DevToolsWindow* devtools_window = | 2497 WebContents* devtools = DevToolsWindow::GetInTabWebContents(contents, NULL); |
| 2503 DevToolsWindow::GetDockedInstanceForInspectedTab(contents); | 2498 if (devtools && DoCutCopyPasteForWebContents(devtools, method)) |
| 2504 if (devtools_window && | |
| 2505 DoCutCopyPasteForWebContents(devtools_window->web_contents(), method)) { | |
| 2506 return; | 2499 return; |
| 2507 } | |
| 2508 | 2500 |
| 2509 views::FocusManager* focus_manager = GetFocusManager(); | 2501 views::FocusManager* focus_manager = GetFocusManager(); |
| 2510 views::View* focused = focus_manager->GetFocusedView(); | 2502 views::View* focused = focus_manager->GetFocusedView(); |
| 2511 if (focused && | 2503 if (focused && |
| 2512 (!strcmp(focused->GetClassName(), views::Textfield::kViewClassName) || | 2504 (!strcmp(focused->GetClassName(), views::Textfield::kViewClassName) || |
| 2513 !strcmp(focused->GetClassName(), OmniboxViewViews::kViewClassName))) { | 2505 !strcmp(focused->GetClassName(), OmniboxViewViews::kViewClassName))) { |
| 2514 views::Textfield* textfield = static_cast<views::Textfield*>(focused); | 2506 views::Textfield* textfield = static_cast<views::Textfield*>(focused); |
| 2515 textfield->ExecuteCommand(command_id); | 2507 textfield->ExecuteCommand(command_id); |
| 2516 } | 2508 } |
| 2517 } | 2509 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2555 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { | 2547 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { |
| 2556 gfx::Point icon_bottom( | 2548 gfx::Point icon_bottom( |
| 2557 toolbar_->location_bar()->GetLocationBarAnchorPoint()); | 2549 toolbar_->location_bar()->GetLocationBarAnchorPoint()); |
| 2558 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); | 2550 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); |
| 2559 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); | 2551 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); |
| 2560 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2552 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
| 2561 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2553 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
| 2562 } | 2554 } |
| 2563 return top_arrow_height; | 2555 return top_arrow_height; |
| 2564 } | 2556 } |
| OLD | NEW |