| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" | 46 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" |
| 47 #include "chrome/browser/ui/views/avatar_menu_button.h" | 47 #include "chrome/browser/ui/views/avatar_menu_button.h" |
| 48 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 48 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 49 #include "chrome/browser/ui/views/browser_dialogs.h" | 49 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 50 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" | 50 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" |
| 51 #include "chrome/browser/ui/views/download/download_shelf_view.h" | 51 #include "chrome/browser/ui/views/download/download_shelf_view.h" |
| 52 #include "chrome/browser/ui/views/frame/browser_view_layout.h" | 52 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
| 53 #include "chrome/browser/ui/views/frame/contents_container.h" | 53 #include "chrome/browser/ui/views/frame/contents_container.h" |
| 54 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" | 54 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" |
| 55 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" | 55 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" |
| 56 #include "chrome/browser/ui/views/location_bar/location_bar_container.h" |
| 56 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 57 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 57 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 58 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 58 #include "chrome/browser/ui/views/password_generation_bubble_view.h" | 59 #include "chrome/browser/ui/views/password_generation_bubble_view.h" |
| 59 #include "chrome/browser/ui/views/status_bubble_views.h" | 60 #include "chrome/browser/ui/views/status_bubble_views.h" |
| 60 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" | 61 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" |
| 61 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 62 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 62 #include "chrome/browser/ui/views/toolbar_view.h" | 63 #include "chrome/browser/ui/views/toolbar_view.h" |
| 63 #include "chrome/browser/ui/views/update_recommended_message_box.h" | 64 #include "chrome/browser/ui/views/update_recommended_message_box.h" |
| 64 #include "chrome/browser/ui/views/website_settings_popup_view.h" | 65 #include "chrome/browser/ui/views/website_settings_popup_view.h" |
| 65 #include "chrome/browser/ui/webui/feedback_ui.h" | 66 #include "chrome/browser/ui/webui/feedback_ui.h" |
| (...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 true, false, false, false); | 1281 true, false, false, false); |
| 1281 } | 1282 } |
| 1282 | 1283 |
| 1283 void BrowserView::ShowInstant(TabContents* preview) { | 1284 void BrowserView::ShowInstant(TabContents* preview) { |
| 1284 if (!preview_container_) { | 1285 if (!preview_container_) { |
| 1285 preview_container_ = new views::WebView(browser_->profile()); | 1286 preview_container_ = new views::WebView(browser_->profile()); |
| 1286 preview_container_->set_id(VIEW_ID_TAB_CONTAINER); | 1287 preview_container_->set_id(VIEW_ID_TAB_CONTAINER); |
| 1287 } | 1288 } |
| 1288 contents_->SetPreview(preview_container_, preview->web_contents()); | 1289 contents_->SetPreview(preview_container_, preview->web_contents()); |
| 1289 preview_container_->SetWebContents(preview->web_contents()); | 1290 preview_container_->SetWebContents(preview->web_contents()); |
| 1291 RestackLocationBarContainer(); |
| 1290 } | 1292 } |
| 1291 | 1293 |
| 1292 void BrowserView::HideInstant() { | 1294 void BrowserView::HideInstant() { |
| 1293 if (!preview_container_) | 1295 if (!preview_container_) |
| 1294 return; | 1296 return; |
| 1295 | 1297 |
| 1296 // The contents must be changed before SetPreview is invoked. | 1298 // The contents must be changed before SetPreview is invoked. |
| 1297 preview_container_->SetWebContents(NULL); | 1299 preview_container_->SetWebContents(NULL); |
| 1298 contents_->SetPreview(NULL, NULL); | 1300 contents_->SetPreview(NULL, NULL); |
| 1299 delete preview_container_; | 1301 delete preview_container_; |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1884 | 1886 |
| 1885 #if defined(OS_WIN) && !defined(USE_AURA) | 1887 #if defined(OS_WIN) && !defined(USE_AURA) |
| 1886 // Create a custom JumpList and add it to an observer of TabRestoreService | 1888 // Create a custom JumpList and add it to an observer of TabRestoreService |
| 1887 // so we can update the custom JumpList when a tab is added or removed. | 1889 // so we can update the custom JumpList when a tab is added or removed. |
| 1888 if (JumpList::Enabled()) { | 1890 if (JumpList::Enabled()) { |
| 1889 jumplist_ = new JumpList(); | 1891 jumplist_ = new JumpList(); |
| 1890 jumplist_->AddObserver(browser_->profile()); | 1892 jumplist_->AddObserver(browser_->profile()); |
| 1891 } | 1893 } |
| 1892 #endif | 1894 #endif |
| 1893 | 1895 |
| 1896 ReorderChildView(toolbar_->location_bar_container(), child_count() - 1); |
| 1897 |
| 1894 // We're now initialized and ready to process Layout requests. | 1898 // We're now initialized and ready to process Layout requests. |
| 1895 ignore_layout_ = false; | 1899 ignore_layout_ = false; |
| 1896 } | 1900 } |
| 1897 | 1901 |
| 1898 void BrowserView::LoadingAnimationCallback() { | 1902 void BrowserView::LoadingAnimationCallback() { |
| 1899 base::TimeTicks now = base::TimeTicks::Now(); | 1903 base::TimeTicks now = base::TimeTicks::Now(); |
| 1900 if (!last_animation_time_.is_null()) { | 1904 if (!last_animation_time_.is_null()) { |
| 1901 UMA_HISTOGRAM_TIMES( | 1905 UMA_HISTOGRAM_TIMES( |
| 1902 "Tabs.LoadingAnimationTime", | 1906 "Tabs.LoadingAnimationTime", |
| 1903 now - last_animation_time_); | 1907 now - last_animation_time_); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 TabContents* devtools_tab_contents = | 1979 TabContents* devtools_tab_contents = |
| 1976 DevToolsWindow::GetDevToolsContents(tab_contents->web_contents()); | 1980 DevToolsWindow::GetDevToolsContents(tab_contents->web_contents()); |
| 1977 if (devtools_tab_contents) | 1981 if (devtools_tab_contents) |
| 1978 devtools_contents = devtools_tab_contents->web_contents(); | 1982 devtools_contents = devtools_tab_contents->web_contents(); |
| 1979 } | 1983 } |
| 1980 | 1984 |
| 1981 bool should_show = devtools_contents && !devtools_container_->visible(); | 1985 bool should_show = devtools_contents && !devtools_container_->visible(); |
| 1982 bool should_hide = !devtools_contents && devtools_container_->visible(); | 1986 bool should_hide = !devtools_contents && devtools_container_->visible(); |
| 1983 | 1987 |
| 1984 devtools_container_->SetWebContents(devtools_contents); | 1988 devtools_container_->SetWebContents(devtools_contents); |
| 1989 RestackLocationBarContainer(); |
| 1985 | 1990 |
| 1986 if (should_show) | 1991 if (should_show) |
| 1987 ShowDevToolsContainer(); | 1992 ShowDevToolsContainer(); |
| 1988 else if (should_hide) | 1993 else if (should_hide) |
| 1989 HideDevToolsContainer(); | 1994 HideDevToolsContainer(); |
| 1990 } | 1995 } |
| 1991 | 1996 |
| 1992 void BrowserView::ShowDevToolsContainer() { | 1997 void BrowserView::ShowDevToolsContainer() { |
| 1993 if (!devtools_focus_tracker_.get()) { | 1998 if (!devtools_focus_tracker_.get()) { |
| 1994 // Install devtools focus tracker when dev tools window is shown for the | 1999 // Install devtools focus tracker when dev tools window is shown for the |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2368 // avoid an unnecessary resize and re-layout of a WebContents. | 2373 // avoid an unnecessary resize and re-layout of a WebContents. |
| 2369 if (change_tab_contents) | 2374 if (change_tab_contents) |
| 2370 contents_container_->SetWebContents(NULL); | 2375 contents_container_->SetWebContents(NULL); |
| 2371 infobar_container_->ChangeTabContents(new_contents->infobar_tab_helper()); | 2376 infobar_container_->ChangeTabContents(new_contents->infobar_tab_helper()); |
| 2372 if (bookmark_bar_view_.get()) { | 2377 if (bookmark_bar_view_.get()) { |
| 2373 bookmark_bar_view_->SetBookmarkBarState( | 2378 bookmark_bar_view_->SetBookmarkBarState( |
| 2374 browser_->bookmark_bar_state(), | 2379 browser_->bookmark_bar_state(), |
| 2375 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 2380 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
| 2376 } | 2381 } |
| 2377 UpdateUIForContents(new_contents); | 2382 UpdateUIForContents(new_contents); |
| 2378 if (change_tab_contents) | 2383 if (change_tab_contents) { |
| 2379 contents_container_->SetWebContents(new_contents->web_contents()); | 2384 contents_container_->SetWebContents(new_contents->web_contents()); |
| 2385 RestackLocationBarContainer(); |
| 2386 } |
| 2380 | 2387 |
| 2381 UpdateDevToolsForContents(new_contents); | 2388 UpdateDevToolsForContents(new_contents); |
| 2382 // TODO(beng): This should be called automatically by ChangeWebContents, but I | 2389 // TODO(beng): This should be called automatically by ChangeWebContents, but I |
| 2383 // am striving for parity now rather than cleanliness. This is | 2390 // am striving for parity now rather than cleanliness. This is |
| 2384 // required to make features like Duplicate Tab, Undo Close Tab, | 2391 // required to make features like Duplicate Tab, Undo Close Tab, |
| 2385 // etc not result in sad tab. | 2392 // etc not result in sad tab. |
| 2386 new_contents->web_contents()->DidBecomeSelected(); | 2393 new_contents->web_contents()->DidBecomeSelected(); |
| 2387 if (!browser_->tab_strip_model()->closing_all() && GetWidget()->IsActive() && | 2394 if (!browser_->tab_strip_model()->closing_all() && GetWidget()->IsActive() && |
| 2388 GetWidget()->IsVisible()) { | 2395 GetWidget()->IsVisible()) { |
| 2389 // We only restore focus if our window is visible, to avoid invoking blur | 2396 // We only restore focus if our window is visible, to avoid invoking blur |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2402 } | 2409 } |
| 2403 | 2410 |
| 2404 void BrowserView::SetToolbar(ToolbarView* toolbar) { | 2411 void BrowserView::SetToolbar(ToolbarView* toolbar) { |
| 2405 if (toolbar_) { | 2412 if (toolbar_) { |
| 2406 RemoveChildView(toolbar_); | 2413 RemoveChildView(toolbar_); |
| 2407 delete toolbar_; | 2414 delete toolbar_; |
| 2408 } | 2415 } |
| 2409 toolbar_ = toolbar; | 2416 toolbar_ = toolbar; |
| 2410 if (toolbar) { | 2417 if (toolbar) { |
| 2411 AddChildView(toolbar_); | 2418 AddChildView(toolbar_); |
| 2412 toolbar_->Init(); | 2419 toolbar_->Init(this); |
| 2413 } | 2420 } |
| 2414 } | 2421 } |
| 2415 | 2422 |
| 2416 void BrowserView::CreateLauncherIcon() { | 2423 void BrowserView::CreateLauncherIcon() { |
| 2417 #if defined(USE_ASH) | 2424 #if defined(USE_ASH) |
| 2418 if (browser::IsNativeWindowInAsh(GetNativeWindow()) && | 2425 if (browser::IsNativeWindowInAsh(GetNativeWindow()) && |
| 2419 !launcher_item_controller_.get()) { | 2426 !launcher_item_controller_.get()) { |
| 2420 launcher_item_controller_.reset( | 2427 launcher_item_controller_.reset( |
| 2421 BrowserLauncherItemController::Create(browser_.get())); | 2428 BrowserLauncherItemController::Create(browser_.get())); |
| 2422 } | 2429 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2474 this, | 2481 this, |
| 2475 tab_contents->web_contents()->GetRenderViewHost(), | 2482 tab_contents->web_contents()->GetRenderViewHost(), |
| 2476 password_generator, | 2483 password_generator, |
| 2477 browser_.get(), | 2484 browser_.get(), |
| 2478 tab_contents->password_manager()); | 2485 tab_contents->password_manager()); |
| 2479 | 2486 |
| 2480 views::BubbleDelegateView::CreateBubble(bubble); | 2487 views::BubbleDelegateView::CreateBubble(bubble); |
| 2481 bubble->SetAlignment(views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR); | 2488 bubble->SetAlignment(views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR); |
| 2482 bubble->Show(); | 2489 bubble->Show(); |
| 2483 } | 2490 } |
| 2491 |
| 2492 void BrowserView::RestackLocationBarContainer() { |
| 2493 toolbar_->location_bar_container()->StackAtTop(); |
| 2494 } |
| OLD | NEW |