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

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

Issue 10086026: Revert 132281 - Add more functionality to WebView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | ui/views/controls/webview/webview.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 #include "ui/base/accelerators/accelerator.h" 86 #include "ui/base/accelerators/accelerator.h"
87 #include "ui/base/accessibility/accessible_view_state.h" 87 #include "ui/base/accessibility/accessible_view_state.h"
88 #include "ui/base/hit_test.h" 88 #include "ui/base/hit_test.h"
89 #include "ui/base/l10n/l10n_util.h" 89 #include "ui/base/l10n/l10n_util.h"
90 #include "ui/base/resource/resource_bundle.h" 90 #include "ui/base/resource/resource_bundle.h"
91 #include "ui/gfx/canvas.h" 91 #include "ui/gfx/canvas.h"
92 #include "ui/gfx/color_utils.h" 92 #include "ui/gfx/color_utils.h"
93 #include "ui/gfx/sys_color_change_listener.h" 93 #include "ui/gfx/sys_color_change_listener.h"
94 #include "ui/ui_controls/ui_controls.h" 94 #include "ui/ui_controls/ui_controls.h"
95 #include "ui/views/controls/single_split_view.h" 95 #include "ui/views/controls/single_split_view.h"
96 #include "ui/views/controls/webview/webview.h"
97 #include "ui/views/events/event.h" 96 #include "ui/views/events/event.h"
98 #include "ui/views/focus/external_focus_tracker.h" 97 #include "ui/views/focus/external_focus_tracker.h"
99 #include "ui/views/focus/view_storage.h" 98 #include "ui/views/focus/view_storage.h"
100 #include "ui/views/layout/grid_layout.h" 99 #include "ui/views/layout/grid_layout.h"
101 #include "ui/views/widget/native_widget.h" 100 #include "ui/views/widget/native_widget.h"
102 #include "ui/views/widget/root_view.h" 101 #include "ui/views/widget/root_view.h"
103 #include "ui/views/widget/widget.h" 102 #include "ui/views/widget/widget.h"
104 #include "ui/views/window/dialog_delegate.h" 103 #include "ui/views/window/dialog_delegate.h"
105 104
106 #if defined(USE_ASH) 105 #if defined(USE_ASH)
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 void BrowserView::UserChangedTheme() { 1193 void BrowserView::UserChangedTheme() {
1195 frame_->FrameTypeChanged(); 1194 frame_->FrameTypeChanged();
1196 } 1195 }
1197 1196
1198 int BrowserView::GetExtraRenderViewHeight() const { 1197 int BrowserView::GetExtraRenderViewHeight() const {
1199 // Currently this is only used on linux. 1198 // Currently this is only used on linux.
1200 return 0; 1199 return 0;
1201 } 1200 }
1202 1201
1203 void BrowserView::WebContentsFocused(WebContents* contents) { 1202 void BrowserView::WebContentsFocused(WebContents* contents) {
1204 contents_container_->OnWebContentsFocused(contents); 1203 contents_container_->WebContentsFocused(contents);
1205 } 1204 }
1206 1205
1207 void BrowserView::ShowPageInfo(Profile* profile, 1206 void BrowserView::ShowPageInfo(Profile* profile,
1208 const GURL& url, 1207 const GURL& url,
1209 const SSLStatus& ssl, 1208 const SSLStatus& ssl,
1210 bool show_history) { 1209 bool show_history) {
1211 browser::ShowPageInfoBubble(GetLocationBarView()->location_icon_view(), 1210 browser::ShowPageInfoBubble(GetLocationBarView()->location_icon_view(),
1212 profile, url, ssl, show_history); 1211 profile, url, ssl, show_history);
1213 } 1212 }
1214 1213
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_C, 1306 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_C,
1308 true, false, false, false); 1307 true, false, false, false);
1309 } 1308 }
1310 1309
1311 void BrowserView::Paste() { 1310 void BrowserView::Paste() {
1312 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_V, 1311 ui_controls::SendKeyPress(GetNativeHandle(), ui::VKEY_V,
1313 true, false, false, false); 1312 true, false, false, false);
1314 } 1313 }
1315 1314
1316 void BrowserView::ShowInstant(TabContentsWrapper* preview) { 1315 void BrowserView::ShowInstant(TabContentsWrapper* preview) {
1317 if (!preview_container_) { 1316 if (!preview_container_)
1318 preview_container_ = new views::WebView(browser_->profile()); 1317 preview_container_ = new TabContentsContainer();
1319 preview_container_->set_id(VIEW_ID_TAB_CONTAINER);
1320 }
1321 contents_->SetPreview(preview_container_, preview->web_contents()); 1318 contents_->SetPreview(preview_container_, preview->web_contents());
1322 preview_container_->SetWebContents(preview->web_contents()); 1319 preview_container_->ChangeWebContents(preview->web_contents());
1323 } 1320 }
1324 1321
1325 void BrowserView::HideInstant() { 1322 void BrowserView::HideInstant() {
1326 if (!preview_container_) 1323 if (!preview_container_)
1327 return; 1324 return;
1328 1325
1329 // The contents must be changed before SetPreview is invoked. 1326 // The contents must be changed before SetPreview is invoked.
1330 preview_container_->SetWebContents(NULL); 1327 preview_container_->ChangeWebContents(NULL);
1331 contents_->SetPreview(NULL, NULL); 1328 contents_->SetPreview(NULL, NULL);
1332 delete preview_container_; 1329 delete preview_container_;
1333 preview_container_ = NULL; 1330 preview_container_ = NULL;
1334 } 1331 }
1335 1332
1336 gfx::Rect BrowserView::GetInstantBounds() { 1333 gfx::Rect BrowserView::GetInstantBounds() {
1337 return contents_->GetPreviewBounds(); 1334 return contents_->GetPreviewBounds();
1338 } 1335 }
1339 1336
1340 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds( 1337 WindowOpenDisposition BrowserView::GetDispositionForPopupBounds(
(...skipping 27 matching lines...) Expand all
1368 1365
1369 BookmarkBarView* BrowserView::GetBookmarkBarView() const { 1366 BookmarkBarView* BrowserView::GetBookmarkBarView() const {
1370 return bookmark_bar_view_.get(); 1367 return bookmark_bar_view_.get();
1371 } 1368 }
1372 1369
1373 LocationBarView* BrowserView::GetLocationBarView() const { 1370 LocationBarView* BrowserView::GetLocationBarView() const {
1374 return toolbar_ ? toolbar_->location_bar() : NULL; 1371 return toolbar_ ? toolbar_->location_bar() : NULL;
1375 } 1372 }
1376 1373
1377 views::View* BrowserView::GetTabContentsContainerView() const { 1374 views::View* BrowserView::GetTabContentsContainerView() const {
1378 return contents_container_; 1375 return contents_container_->GetFocusView();
1379 } 1376 }
1380 1377
1381 ToolbarView* BrowserView::GetToolbarView() const { 1378 ToolbarView* BrowserView::GetToolbarView() const {
1382 return toolbar_; 1379 return toolbar_;
1383 } 1380 }
1384 1381
1385 /////////////////////////////////////////////////////////////////////////////// 1382 ///////////////////////////////////////////////////////////////////////////////
1386 // BrowserView, TabStripModelObserver implementation: 1383 // BrowserView, TabStripModelObserver implementation:
1387 1384
1388 void BrowserView::TabDetachedAt(TabContentsWrapper* contents, int index) { 1385 void BrowserView::TabDetachedAt(TabContentsWrapper* contents, int index) {
1389 // We use index here rather than comparing |contents| because by this time 1386 // We use index here rather than comparing |contents| because by this time
1390 // the model has already removed |contents| from its list, so 1387 // the model has already removed |contents| from its list, so
1391 // browser_->GetSelectedWebContents() will return NULL or something else. 1388 // browser_->GetSelectedWebContents() will return NULL or something else.
1392 if (index == browser_->active_index()) { 1389 if (index == browser_->active_index()) {
1393 // We need to reset the current tab contents to NULL before it gets 1390 // We need to reset the current tab contents to NULL before it gets
1394 // freed. This is because the focus manager performs some operations 1391 // freed. This is because the focus manager performs some operations
1395 // on the selected TabContents when it is removed. 1392 // on the selected TabContents when it is removed.
1396 contents_container_->SetWebContents(NULL); 1393 contents_container_->ChangeWebContents(NULL);
1397 infobar_container_->ChangeTabContents(NULL); 1394 infobar_container_->ChangeTabContents(NULL);
1398 UpdateDevToolsForContents(NULL); 1395 UpdateDevToolsForContents(NULL);
1399 } 1396 }
1400 } 1397 }
1401 1398
1402 void BrowserView::TabDeactivated(TabContentsWrapper* contents) { 1399 void BrowserView::TabDeactivated(TabContentsWrapper* contents) {
1403 // We do not store the focus when closing the tab to work-around bug 4633. 1400 // We do not store the focus when closing the tab to work-around bug 4633.
1404 // Some reports seem to show that the focus manager and/or focused view can 1401 // Some reports seem to show that the focus manager and/or focused view can
1405 // be garbage at that point, it is not clear why. 1402 // be garbage at that point, it is not clear why.
1406 if (!contents->web_contents()->IsBeingDestroyed()) 1403 if (!contents->web_contents()->IsBeingDestroyed())
(...skipping 11 matching lines...) Expand all
1418 TabContentsWrapper* old_contents, 1415 TabContentsWrapper* old_contents,
1419 TabContentsWrapper* new_contents, 1416 TabContentsWrapper* new_contents,
1420 int index) { 1417 int index) {
1421 if (index != browser_->tabstrip_model()->active_index()) 1418 if (index != browser_->tabstrip_model()->active_index())
1422 return; 1419 return;
1423 1420
1424 if (contents_->preview_web_contents() == new_contents->web_contents()) { 1421 if (contents_->preview_web_contents() == new_contents->web_contents()) {
1425 // If 'preview' is becoming active, swap the 'active' and 'preview' and 1422 // If 'preview' is becoming active, swap the 'active' and 'preview' and
1426 // delete what was the active. 1423 // delete what was the active.
1427 contents_->MakePreviewContentsActiveContents(); 1424 contents_->MakePreviewContentsActiveContents();
1428 views::WebView* old_container = contents_container_; 1425 TabContentsContainer* old_container = contents_container_;
1429 contents_container_ = preview_container_; 1426 contents_container_ = preview_container_;
1430 old_container->SetWebContents(NULL); 1427 old_container->ChangeWebContents(NULL);
1431 delete old_container; 1428 delete old_container;
1432 preview_container_ = NULL; 1429 preview_container_ = NULL;
1433 } 1430 }
1434 // Update the UI for the new contents. 1431 // Update the UI for the new contents.
1435 ProcessTabSelected(new_contents); 1432 ProcessTabSelected(new_contents);
1436 } 1433 }
1437 1434
1438 void BrowserView::TabStripEmpty() { 1435 void BrowserView::TabStripEmpty() {
1439 // Make sure all optional UI is removed before we are destroyed, otherwise 1436 // Make sure all optional UI is removed before we are destroyed, otherwise
1440 // there will be consequences (since our view hierarchy will still have 1437 // there will be consequences (since our view hierarchy will still have
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1896 1893
1897 LoadAccelerators(); 1894 LoadAccelerators();
1898 1895
1899 InitTabStrip(browser_->tabstrip_model()); 1896 InitTabStrip(browser_->tabstrip_model());
1900 1897
1901 SetToolbar(CreateToolbar()); 1898 SetToolbar(CreateToolbar());
1902 1899
1903 infobar_container_ = new InfoBarContainerView(this); 1900 infobar_container_ = new InfoBarContainerView(this);
1904 AddChildView(infobar_container_); 1901 AddChildView(infobar_container_);
1905 1902
1906 contents_container_ = new views::WebView(browser_->profile()); 1903 contents_container_ = new TabContentsContainer;
1907 contents_container_->set_id(VIEW_ID_TAB_CONTAINER);
1908 contents_ = new ContentsContainer(contents_container_); 1904 contents_ = new ContentsContainer(contents_container_);
1909 1905
1910 SkColor bg_color = GetWidget()->GetThemeProvider()-> 1906 SkColor bg_color = GetWidget()->GetThemeProvider()->
1911 GetColor(ThemeService::COLOR_TOOLBAR); 1907 GetColor(ThemeService::COLOR_TOOLBAR);
1912 1908
1913 devtools_container_ = new TabContentsContainer; 1909 devtools_container_ = new TabContentsContainer;
1914 devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED); 1910 devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED);
1915 devtools_container_->SetVisible(false); 1911 devtools_container_->SetVisible(false);
1916 1912
1917 views::View* contents_view = contents_; 1913 views::View* contents_view = contents_;
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
2411 bool change_tab_contents = 2407 bool change_tab_contents =
2412 contents_container_->web_contents() != new_contents->web_contents(); 2408 contents_container_->web_contents() != new_contents->web_contents();
2413 2409
2414 // Update various elements that are interested in knowing the current 2410 // Update various elements that are interested in knowing the current
2415 // TabContents. 2411 // TabContents.
2416 2412
2417 // When we toggle the NTP floating bookmarks bar and/or the info bar, 2413 // When we toggle the NTP floating bookmarks bar and/or the info bar,
2418 // we don't want any TabContents to be attached, so that we 2414 // we don't want any TabContents to be attached, so that we
2419 // avoid an unnecessary resize and re-layout of a TabContents. 2415 // avoid an unnecessary resize and re-layout of a TabContents.
2420 if (change_tab_contents) 2416 if (change_tab_contents)
2421 contents_container_->SetWebContents(NULL); 2417 contents_container_->ChangeWebContents(NULL);
2422 infobar_container_->ChangeTabContents(new_contents->infobar_tab_helper()); 2418 infobar_container_->ChangeTabContents(new_contents->infobar_tab_helper());
2423 if (bookmark_bar_view_.get()) { 2419 if (bookmark_bar_view_.get()) {
2424 bookmark_bar_view_->SetBookmarkBarState( 2420 bookmark_bar_view_->SetBookmarkBarState(
2425 browser_->bookmark_bar_state(), 2421 browser_->bookmark_bar_state(),
2426 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); 2422 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
2427 } 2423 }
2428 UpdateUIForContents(new_contents); 2424 UpdateUIForContents(new_contents);
2429 if (change_tab_contents) 2425 if (change_tab_contents)
2430 contents_container_->SetWebContents(new_contents->web_contents()); 2426 contents_container_->ChangeWebContents(new_contents->web_contents());
2431 2427
2432 UpdateDevToolsForContents(new_contents); 2428 UpdateDevToolsForContents(new_contents);
2433 // TODO(beng): This should be called automatically by ChangeWebContents, but I 2429 // TODO(beng): This should be called automatically by ChangeWebContents, but I
2434 // am striving for parity now rather than cleanliness. This is 2430 // am striving for parity now rather than cleanliness. This is
2435 // required to make features like Duplicate Tab, Undo Close Tab, 2431 // required to make features like Duplicate Tab, Undo Close Tab,
2436 // etc not result in sad tab. 2432 // etc not result in sad tab.
2437 new_contents->web_contents()->DidBecomeSelected(); 2433 new_contents->web_contents()->DidBecomeSelected();
2438 if (BrowserList::GetLastActive() == browser_ && 2434 if (BrowserList::GetLastActive() == browser_ &&
2439 !browser_->tabstrip_model()->closing_all() && GetWidget()->IsVisible()) { 2435 !browser_->tabstrip_model()->closing_all() && GetWidget()->IsVisible()) {
2440 // We only restore focus if our window is visible, to avoid invoking blur 2436 // We only restore focus if our window is visible, to avoid invoking blur
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 return; 2511 return;
2516 2512
2517 PasswordGenerationBubbleView* bubble = 2513 PasswordGenerationBubbleView* bubble =
2518 new PasswordGenerationBubbleView(bounds, 2514 new PasswordGenerationBubbleView(bounds,
2519 this, 2515 this,
2520 web_contents->GetRenderViewHost()); 2516 web_contents->GetRenderViewHost());
2521 views::BubbleDelegateView::CreateBubble(bubble); 2517 views::BubbleDelegateView::CreateBubble(bubble);
2522 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 2518 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
2523 bubble->Show(); 2519 bubble->Show();
2524 } 2520 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | ui/views/controls/webview/webview.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698