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