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

Side by Side Diff: chrome/browser/gtk/browser_window_gtk.cc

Issue 159019: Begin work on extension shelf for Linux. (Closed)
Patch Set: Created 11 years, 5 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
« no previous file with comments | « chrome/browser/gtk/browser_window_gtk.h ('k') | chrome/browser/gtk/extension_shelf_gtk.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/gtk/browser_window_gtk.h" 5 #include "chrome/browser/gtk/browser_window_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <X11/XF86keysym.h> 8 #include <X11/XF86keysym.h>
9 9
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 18 matching lines...) Expand all
29 #include "chrome/browser/download/download_manager.h" 29 #include "chrome/browser/download/download_manager.h"
30 #include "chrome/browser/gtk/about_chrome_dialog.h" 30 #include "chrome/browser/gtk/about_chrome_dialog.h"
31 #include "chrome/browser/gtk/active_window_watcher.h" 31 #include "chrome/browser/gtk/active_window_watcher.h"
32 #include "chrome/browser/gtk/bookmark_bar_gtk.h" 32 #include "chrome/browser/gtk/bookmark_bar_gtk.h"
33 #include "chrome/browser/gtk/bookmark_manager_gtk.h" 33 #include "chrome/browser/gtk/bookmark_manager_gtk.h"
34 #include "chrome/browser/gtk/browser_titlebar.h" 34 #include "chrome/browser/gtk/browser_titlebar.h"
35 #include "chrome/browser/gtk/browser_toolbar_gtk.h" 35 #include "chrome/browser/gtk/browser_toolbar_gtk.h"
36 #include "chrome/browser/gtk/clear_browsing_data_dialog_gtk.h" 36 #include "chrome/browser/gtk/clear_browsing_data_dialog_gtk.h"
37 #include "chrome/browser/gtk/download_shelf_gtk.h" 37 #include "chrome/browser/gtk/download_shelf_gtk.h"
38 #include "chrome/browser/gtk/edit_search_engine_dialog.h" 38 #include "chrome/browser/gtk/edit_search_engine_dialog.h"
39 #include "chrome/browser/gtk/extension_shelf_gtk.h"
39 #include "chrome/browser/gtk/find_bar_gtk.h" 40 #include "chrome/browser/gtk/find_bar_gtk.h"
40 #include "chrome/browser/gtk/go_button_gtk.h" 41 #include "chrome/browser/gtk/go_button_gtk.h"
41 #include "chrome/browser/gtk/gtk_theme_provider.h" 42 #include "chrome/browser/gtk/gtk_theme_provider.h"
42 #include "chrome/browser/gtk/import_dialog_gtk.h" 43 #include "chrome/browser/gtk/import_dialog_gtk.h"
43 #include "chrome/browser/gtk/infobar_container_gtk.h" 44 #include "chrome/browser/gtk/infobar_container_gtk.h"
44 #include "chrome/browser/gtk/keyword_editor_view.h" 45 #include "chrome/browser/gtk/keyword_editor_view.h"
45 #include "chrome/browser/gtk/nine_box.h" 46 #include "chrome/browser/gtk/nine_box.h"
46 #include "chrome/browser/gtk/status_bubble_gtk.h" 47 #include "chrome/browser/gtk/status_bubble_gtk.h"
47 #include "chrome/browser/gtk/tab_contents_container_gtk.h" 48 #include "chrome/browser/gtk/tab_contents_container_gtk.h"
48 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h" 49 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h"
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 639
639 bool BrowserWindowGtk::IsMaximized() const { 640 bool BrowserWindowGtk::IsMaximized() const {
640 return (state_ & GDK_WINDOW_STATE_MAXIMIZED); 641 return (state_ & GDK_WINDOW_STATE_MAXIMIZED);
641 } 642 }
642 643
643 void BrowserWindowGtk::SetFullscreen(bool fullscreen) { 644 void BrowserWindowGtk::SetFullscreen(bool fullscreen) {
644 full_screen_ = fullscreen; 645 full_screen_ = fullscreen;
645 UpdateCustomFrame(); 646 UpdateCustomFrame();
646 647
647 if (fullscreen) { 648 if (fullscreen) {
648 // These three balanced by ShowSupportedWindowFeatures(). 649 // These four balanced by ShowSupportedWindowFeatures().
649 toolbar_->Hide(); 650 toolbar_->Hide();
650 tabstrip_->Hide(); 651 tabstrip_->Hide();
651 bookmark_bar_->Hide(false); 652 bookmark_bar_->Hide(false);
653 extension_shelf_->Hide();
652 654
653 gtk_window_fullscreen(window_); 655 gtk_window_fullscreen(window_);
654 } else { 656 } else {
655 ShowSupportedWindowFeatures(); 657 ShowSupportedWindowFeatures();
656 658
657 gtk_window_unfullscreen(window_); 659 gtk_window_unfullscreen(window_);
658 } 660 }
659 } 661 }
660 662
661 bool BrowserWindowGtk::IsFullscreen() const { 663 bool BrowserWindowGtk::IsFullscreen() const {
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 show_bar = prefs->GetBoolean(prefs::kShowBookmarkBar); 899 show_bar = prefs->GetBoolean(prefs::kShowBookmarkBar);
898 } 900 }
899 901
900 if (show_bar) { 902 if (show_bar) {
901 bookmark_bar_->Show(animate); 903 bookmark_bar_->Show(animate);
902 } else { 904 } else {
903 bookmark_bar_->Hide(animate); 905 bookmark_bar_->Hide(animate);
904 } 906 }
905 } 907 }
906 908
909 void BrowserWindowGtk::MaybeShowExtensionShelf() {
910 extension_shelf_->Show();
911 }
912
907 void BrowserWindowGtk::UpdateDevToolsForContents(TabContents* contents) { 913 void BrowserWindowGtk::UpdateDevToolsForContents(TabContents* contents) {
908 TabContents* old_devtools = devtools_container_->GetTabContents(); 914 TabContents* old_devtools = devtools_container_->GetTabContents();
909 if (old_devtools) 915 if (old_devtools)
910 devtools_container_->DetachTabContents(old_devtools); 916 devtools_container_->DetachTabContents(old_devtools);
911 917
912 TabContents* devtools_contents = contents ? 918 TabContents* devtools_contents = contents ?
913 DevToolsWindow::GetDevToolsContents(contents) : NULL; 919 DevToolsWindow::GetDevToolsContents(contents) : NULL;
914 devtools_container_->SetTabContents(devtools_contents); 920 devtools_container_->SetTabContents(devtools_contents);
915 if (devtools_contents) { 921 if (devtools_contents) {
916 // TabContentsViewGtk::WasShown is not called when tab contents is shown by 922 // TabContentsViewGtk::WasShown is not called when tab contents is shown by
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 gtk_widget_show(content_vbox_); 1107 gtk_widget_show(content_vbox_);
1102 1108
1103 toolbar_.reset(new BrowserToolbarGtk(browser_.get(), this)); 1109 toolbar_.reset(new BrowserToolbarGtk(browser_.get(), this));
1104 toolbar_->Init(browser_->profile(), window_); 1110 toolbar_->Init(browser_->profile(), window_);
1105 toolbar_->AddToolbarToBox(content_vbox_); 1111 toolbar_->AddToolbarToBox(content_vbox_);
1106 1112
1107 bookmark_bar_.reset(new BookmarkBarGtk(browser_->profile(), browser_.get(), 1113 bookmark_bar_.reset(new BookmarkBarGtk(browser_->profile(), browser_.get(),
1108 this)); 1114 this));
1109 bookmark_bar_->AddBookmarkbarToBox(content_vbox_); 1115 bookmark_bar_->AddBookmarkbarToBox(content_vbox_);
1110 1116
1117 extension_shelf_.reset(new ExtensionShelfGtk(browser()->profile(),
1118 browser_.get()));
1119 extension_shelf_->AddShelfToBox(content_vbox_);
1120 MaybeShowExtensionShelf();
1121
1111 // This vbox surrounds the render area: find bar, info bars and render view. 1122 // This vbox surrounds the render area: find bar, info bars and render view.
1112 // The reason is that this area as a whole needs to be grouped in its own 1123 // The reason is that this area as a whole needs to be grouped in its own
1113 // GdkWindow hierarchy so that animations originating inside it (infobar, 1124 // GdkWindow hierarchy so that animations originating inside it (infobar,
1114 // download shelf, find bar) are all clipped to that area. This is why 1125 // download shelf, find bar) are all clipped to that area. This is why
1115 // |render_area_vbox_| is packed in |event_box|. 1126 // |render_area_vbox_| is packed in |event_box|.
1116 render_area_vbox_ = gtk_vbox_new(FALSE, 0); 1127 render_area_vbox_ = gtk_vbox_new(FALSE, 0);
1117 infobar_container_.reset(new InfoBarContainerGtk(this)); 1128 infobar_container_.reset(new InfoBarContainerGtk(this));
1118 gtk_box_pack_start(GTK_BOX(render_area_vbox_), 1129 gtk_box_pack_start(GTK_BOX(render_area_vbox_),
1119 infobar_container_->widget(), 1130 infobar_container_->widget(),
1120 FALSE, FALSE, 0); 1131 FALSE, FALSE, 0);
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 1411
1401 void BrowserWindowGtk::ShowSupportedWindowFeatures() { 1412 void BrowserWindowGtk::ShowSupportedWindowFeatures() {
1402 if (IsTabStripSupported()) 1413 if (IsTabStripSupported())
1403 tabstrip_->Show(); 1414 tabstrip_->Show();
1404 1415
1405 if (IsToolbarSupported()) 1416 if (IsToolbarSupported())
1406 toolbar_->Show(); 1417 toolbar_->Show();
1407 1418
1408 if (IsBookmarkBarSupported()) 1419 if (IsBookmarkBarSupported())
1409 MaybeShowBookmarkBar(browser_->GetSelectedTabContents(), false); 1420 MaybeShowBookmarkBar(browser_->GetSelectedTabContents(), false);
1421
1422 if (IsExtensionShelfSupported())
1423 MaybeShowExtensionShelf();
1410 } 1424 }
1411 1425
1412 void BrowserWindowGtk::HideUnsupportedWindowFeatures() { 1426 void BrowserWindowGtk::HideUnsupportedWindowFeatures() {
1413 if (!IsTabStripSupported()) 1427 if (!IsTabStripSupported())
1414 tabstrip_->Hide(); 1428 tabstrip_->Hide();
1415 1429
1416 if (!IsToolbarSupported()) 1430 if (!IsToolbarSupported())
1417 toolbar_->Hide(); 1431 toolbar_->Hide();
1418 1432
1419 if (!IsBookmarkBarSupported()) 1433 if (!IsBookmarkBarSupported())
1420 bookmark_bar_->Hide(false); 1434 bookmark_bar_->Hide(false);
1435
1436 if (!IsExtensionShelfSupported())
1437 extension_shelf_->Hide();
1421 } 1438 }
1422 1439
1423 bool BrowserWindowGtk::IsTabStripSupported() { 1440 bool BrowserWindowGtk::IsTabStripSupported() {
1424 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); 1441 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP);
1425 } 1442 }
1426 1443
1427 bool BrowserWindowGtk::IsToolbarSupported() { 1444 bool BrowserWindowGtk::IsToolbarSupported() {
1428 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || 1445 return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) ||
1429 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); 1446 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR);
1430 } 1447 }
1431 1448
1432 bool BrowserWindowGtk::IsBookmarkBarSupported() { 1449 bool BrowserWindowGtk::IsBookmarkBarSupported() {
1433 return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR); 1450 return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR);
1434 } 1451 }
1435 1452
1453 bool BrowserWindowGtk::IsExtensionShelfSupported() {
1454 return browser_->SupportsWindowFeature(Browser::FEATURE_EXTENSIONSHELF);
1455 }
1456
1436 bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { 1457 bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) {
1437 if (!use_custom_frame_.GetValue()) 1458 if (!use_custom_frame_.GetValue())
1438 return false; 1459 return false;
1439 1460
1440 if (IsMaximized() || IsFullscreen()) 1461 if (IsMaximized() || IsFullscreen())
1441 return false; 1462 return false;
1442 1463
1443 if (x < kFrameBorderThickness) { 1464 if (x < kFrameBorderThickness) {
1444 // Left edge. 1465 // Left edge.
1445 if (y < kResizeAreaCornerSize - kTopResizeAdjust) { 1466 if (y < kResizeAreaCornerSize - kTopResizeAdjust) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 *edge = GDK_WINDOW_EDGE_NORTH_EAST; 1501 *edge = GDK_WINDOW_EDGE_NORTH_EAST;
1481 } else if (y < bounds_.height() - kResizeAreaCornerSize) { 1502 } else if (y < bounds_.height() - kResizeAreaCornerSize) {
1482 *edge = GDK_WINDOW_EDGE_EAST; 1503 *edge = GDK_WINDOW_EDGE_EAST;
1483 } else { 1504 } else {
1484 *edge = GDK_WINDOW_EDGE_SOUTH_EAST; 1505 *edge = GDK_WINDOW_EDGE_SOUTH_EAST;
1485 } 1506 }
1486 return true; 1507 return true;
1487 } 1508 }
1488 NOTREACHED(); 1509 NOTREACHED();
1489 } 1510 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/browser_window_gtk.h ('k') | chrome/browser/gtk/extension_shelf_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698