diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser.cc | 27 | ||||
-rw-r--r-- | chrome/browser/browser.h | 5 | ||||
-rw-r--r-- | chrome/browser/chromeos/frame/browser_view.cc | 47 | ||||
-rw-r--r-- | chrome/browser/chromeos/frame/browser_view.h | 12 | ||||
-rw-r--r-- | chrome/browser/chromeos/view_ids.h | 4 | ||||
-rw-r--r-- | chrome/browser/defaults.cc | 3 | ||||
-rw-r--r-- | chrome/browser/defaults.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/info_bubble.cc | 20 | ||||
-rw-r--r-- | chrome/browser/views/info_bubble.h | 14 | ||||
-rw-r--r-- | chrome/browser/views/pinned_contents_info_bubble.cc | 16 | ||||
-rw-r--r-- | chrome/browser/views/pinned_contents_info_bubble.h | 27 | ||||
-rw-r--r-- | chrome/browser/views/tabs/browser_tab_strip_controller.cc | 15 |
12 files changed, 60 insertions, 133 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 492ebfb..3d94ed5 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -111,6 +111,10 @@ #include "chrome/browser/cocoa/find_pasteboard.h" #endif +#if defined(OS_CHROMEOS) +#include "chrome/browser/views/app_launcher.h" +#endif + using base::TimeDelta; // How long we wait before updating the browser chrome while loading a page. @@ -1045,6 +1049,21 @@ void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) { command_updater_.UpdateCommandEnabled(IDC_SHOW_PAGE_MENU, show_main_ui); } +bool Browser::OpenAppsPanelAsNewTab() { +#if defined(OS_CHROMEOS) || defined(OS_WIN) + CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kDisableAppsPanel) || + (!browser_defaults::kShowAppsPanelForNewTab && + !command_line->HasSwitch(switches::kAppsPanel))) { + return false; + } + AppLauncher::ShowForNewTab(this, std::string()); + return true; +#endif // OS_CHROMEOS || OS_WIN + + return false; +} + /////////////////////////////////////////////////////////////////////////////// // Browser, Assorted browser commands: @@ -1248,12 +1267,10 @@ void Browser::CloseWindow() { void Browser::NewTab() { UserMetrics::RecordAction(UserMetricsAction("NewTab"), profile_); -#if defined(OS_WIN) - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsPanel)) { - AppLauncher::ShowForNewTab(this, std::string()); + + if (OpenAppsPanelAsNewTab()) return; - } -#endif + if (type() == TYPE_NORMAL) { AddBlankTab(true); } else { diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index 74b5a47..5a7afa5 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -419,6 +419,11 @@ class Browser : public TabStripModelDelegate, // will call this method. void UpdateCommandsForFullscreenMode(bool is_fullscreen); + // Opens the apps panel as a result of a new tab creation, if the browser is + // configured in that mode. Returns true if the apps panel was opened, false + // otherwise. + bool OpenAppsPanelAsNewTab(); + // Assorted browser commands //////////////////////////////////////////////// // NOTE: Within each of the following sections, the IDs are ordered roughly by diff --git a/chrome/browser/chromeos/frame/browser_view.cc b/chrome/browser/chromeos/frame/browser_view.cc index 761459c..1eac964 100644 --- a/chrome/browser/chromeos/frame/browser_view.cc +++ b/chrome/browser/chromeos/frame/browser_view.cc @@ -122,9 +122,9 @@ class ChromeosTabStrip : public TabStrip { namespace chromeos { // LayoutManager for BrowserView, which layouts extra components such as -// main menu, stataus views as follows: -// ____ __ __ -// [AppLauncher] / \ \ \ [StatusArea] +// the status views as follows: +// ____ __ __ +// / \ \ \ [StatusArea] // class BrowserViewLayout : public ::BrowserViewLayout { public: @@ -135,7 +135,6 @@ class BrowserViewLayout : public ::BrowserViewLayout { // BrowserViewLayout overrides: void Installed(views::View* host) { - main_menu_button_ = NULL; compact_navigation_bar_ = NULL; status_area_ = NULL; spacer_ = NULL; @@ -149,9 +148,6 @@ class BrowserViewLayout : public ::BrowserViewLayout { case VIEW_ID_SPACER: spacer_ = view; break; - case VIEW_ID_APP_MENU_BUTTON: - main_menu_button_ = view; - break; case VIEW_ID_STATUS_AREA: status_area_ = static_cast<chromeos::StatusAreaView*>(view); break; @@ -170,7 +166,6 @@ class BrowserViewLayout : public ::BrowserViewLayout { virtual int LayoutTabStrip() { if (browser_view_->IsFullscreen() || !browser_view_->IsTabStripVisible()) { - main_menu_button_->SetVisible(false); compact_navigation_bar_->SetVisible(false); status_area_->SetVisible(false); otr_avatar_icon_->SetVisible(false); @@ -211,12 +206,6 @@ class BrowserViewLayout : public ::BrowserViewLayout { // considered title bar area of client view. bool IsPointInViewsInTitleArea(const gfx::Point& point) const { - gfx::Point point_in_main_menu_coords(point); - views::View::ConvertPointToView(browser_view_, main_menu_button_, - &point_in_main_menu_coords); - if (main_menu_button_->HitTest(point_in_main_menu_coords)) - return true; - gfx::Point point_in_status_area_coords(point); views::View::ConvertPointToView(browser_view_, status_area_, &point_in_status_area_coords); @@ -241,7 +230,6 @@ class BrowserViewLayout : public ::BrowserViewLayout { if (bounds.IsEmpty()) { return 0; } - main_menu_button_->SetVisible(true); compact_navigation_bar_->SetVisible( chromeos_browser_view()->is_compact_style()); tabstrip_->SetVisible(true); @@ -263,11 +251,6 @@ class BrowserViewLayout : public ::BrowserViewLayout { } */ - // Layout main menu before tab strip. - gfx::Size main_menu_size = main_menu_button_->GetPreferredSize(); - main_menu_button_->SetBounds(0, bounds.y(), - main_menu_size.width(), bounds.height()); - status_area_->Update(); // Layout status area after tab strip. gfx::Size status_size = status_area_->GetPreferredSize(); @@ -276,7 +259,7 @@ class BrowserViewLayout : public ::BrowserViewLayout { status_size.height()); LayoutOTRAvatar(bounds); - int curx = bounds.x() + main_menu_size.width(); + int curx = bounds.x(); if (compact_navigation_bar_->IsVisible()) { gfx::Size cnb_size = compact_navigation_bar_->GetPreferredSize(); @@ -326,7 +309,6 @@ class BrowserViewLayout : public ::BrowserViewLayout { } - views::View* main_menu_button_; chromeos::StatusAreaView* status_area_; views::View* compact_navigation_bar_; views::View* spacer_; @@ -337,7 +319,6 @@ class BrowserViewLayout : public ::BrowserViewLayout { BrowserView::BrowserView(Browser* browser) : ::BrowserView(browser), - main_menu_button_(NULL), status_area_(NULL), compact_navigation_bar_(NULL), // Standard style is default. @@ -356,15 +337,8 @@ BrowserView::~BrowserView() { void BrowserView::Init() { ::BrowserView::Init(); - main_menu_button_ = new views::ImageButton(this); - main_menu_button_->SetID(VIEW_ID_APP_MENU_BUTTON); ThemeProvider* theme_provider = frame()->GetThemeProviderForFrame(); - SkBitmap* image = theme_provider->GetBitmapNamed(IDR_APP_LAUNCHER_BUTTON); - main_menu_button_->SetImage(views::CustomButton::BS_NORMAL, image); - main_menu_button_->SetImage(views::CustomButton::BS_HOT, image); - main_menu_button_->SetImage(views::CustomButton::BS_PUSHED, image); - AddChildView(main_menu_button_); compact_location_bar_host_.reset( new chromeos::CompactLocationBarHost(this)); @@ -452,19 +426,6 @@ void BrowserView::ChildPreferredSizeChanged(View* child) { SchedulePaint(); } -// views::ButtonListener overrides. -void BrowserView::ButtonPressed(views::Button* sender, - const views::Event& event) { - gfx::Rect bounds = main_menu_button_->bounds(); - gfx::Point origin = bounds.origin(); - // Move the origin to the right otherwise the app launcher info bubble left - // border will show out of screen. - origin.Offset(kAppLauncherLeftPadding, 0); - views::RootView::ConvertPointToScreen(this, &origin); - bounds.set_origin(origin); - ::AppLauncher::Show(browser(), bounds, gfx::Point(), std::string()); -} - // views::ContextMenuController overrides. void BrowserView::ShowContextMenu(views::View* source, const gfx::Point& p, diff --git a/chrome/browser/chromeos/frame/browser_view.h b/chrome/browser/chromeos/frame/browser_view.h index 49c0daa..2a414bd 100644 --- a/chrome/browser/chromeos/frame/browser_view.h +++ b/chrome/browser/chromeos/frame/browser_view.h @@ -7,7 +7,6 @@ #include "chrome/browser/chromeos/status/status_area_host.h" #include "chrome/browser/views/frame/browser_view.h" -#include "views/controls/button/button.h" class TabStripModel; @@ -33,12 +32,11 @@ class StatusAreaButton; // chromeos::BrowserView adds ChromeOS specific controls and menus to a // BrowserView created with Browser::TYPE_NORMAL. This extender adds controls // to the title bar as follows: -// ____ __ __ -// [AppLauncher] / \ \ \ [StatusArea] +// ____ __ __ +// / \ \ \ [StatusArea] // // and adds the system context menu to the remaining arae of the titlebar. class BrowserView : public ::BrowserView, - public views::ButtonListener, public views::ContextMenuController, public StatusAreaHost { public: @@ -66,9 +64,6 @@ class BrowserView : public ::BrowserView, virtual views::LayoutManager* CreateLayoutManager() const; virtual void ChildPreferredSizeChanged(View* child); - // views::ButtonListener overrides. - virtual void ButtonPressed(views::Button* sender, const views::Event& event); - // views::ContextMenuController overrides. virtual void ShowContextMenu(views::View* source, const gfx::Point& p, @@ -100,9 +95,6 @@ class BrowserView : public ::BrowserView, void InitSystemMenu(); - // AppLauncher button. - views::ImageButton* main_menu_button_; - // Status Area view. BrowserStatusAreaView* status_area_; diff --git a/chrome/browser/chromeos/view_ids.h b/chrome/browser/chromeos/view_ids.h index 54b3b7b..803b8fe 100644 --- a/chrome/browser/chromeos/view_ids.h +++ b/chrome/browser/chromeos/view_ids.h @@ -11,12 +11,10 @@ enum ChromeOSViewIds { // Start with the offset that is big enough to avoid possible // collison. - VIEW_ID_APP_MENU_BUTTON = VIEW_ID_PREDEFINED_COUNT + 10000, - VIEW_ID_COMPACT_NAV_BAR, + VIEW_ID_COMPACT_NAV_BAR = VIEW_ID_PREDEFINED_COUNT + 10000, VIEW_ID_STATUS_AREA, VIEW_ID_SPACER, VIEW_ID_OTR_AVATAR, }; #endif // CHROME_BROWSER_CHROMEOS_VIEW_IDS_H_ - diff --git a/chrome/browser/defaults.cc b/chrome/browser/defaults.cc index a76ebbf..ca50e70 100644 --- a/chrome/browser/defaults.cc +++ b/chrome/browser/defaults.cc @@ -25,6 +25,7 @@ const bool kDownloadPageHasShowInFolder = false; const bool kSizeTabButtonToTopOfTabStrip = true; const bool kBootstrapSyncAuthentication = true; const bool kShowOtherBrowsersInAboutMemory = false; +const bool kShowAppsPanelForNewTab = true; #elif defined(TOOLKIT_USES_GTK) @@ -65,7 +66,7 @@ const bool kOSSupportsOtherBrowsers = true; const bool kSizeTabButtonToTopOfTabStrip = false; const bool kBootstrapSyncAuthentication = false; const bool kShowOtherBrowsersInAboutMemory = true; - +const bool kShowAppsPanelForNewTab = false; #endif #if defined(OS_MACOSX) diff --git a/chrome/browser/defaults.h b/chrome/browser/defaults.h index 11dee1f..8a2b543 100644 --- a/chrome/browser/defaults.h +++ b/chrome/browser/defaults.h @@ -67,6 +67,9 @@ extern const bool kBootstrapSyncAuthentication; // Should other browsers be shown in about:memory page? extern const bool kShowOtherBrowsersInAboutMemory; +// Should we show the app panel when a new tab is created? +extern const bool kShowAppsPanelForNewTab; + } // namespace browser_defaults #endif // CHROME_BROWSER_DEFAULTS_H_ diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc index d1414040..d184c46 100644 --- a/chrome/browser/views/info_bubble.cc +++ b/chrome/browser/views/info_bubble.cc @@ -199,9 +199,9 @@ BorderWidget::BorderWidget() : border_contents_(NULL) { } -void BorderWidget::Init(HWND owner) { +void BorderWidget::Init(BorderContents* border_contents, HWND owner) { DCHECK(!border_contents_); - border_contents_ = CreateBorderContents(); + border_contents_ = border_contents; border_contents_->Init(); WidgetWin::Init(GetAncestor(owner, GA_ROOT), gfx::Rect()); SetContentsView(border_contents_); @@ -236,10 +236,6 @@ gfx::Rect BorderWidget::SizeAndGetBounds( return contents_bounds; } -BorderContents* BorderWidget::CreateBorderContents() { - return new BorderContents(); -} - LRESULT BorderWidget::OnMouseActivate(HWND window, UINT hit_test, UINT mouse_message) { @@ -325,8 +321,8 @@ void InfoBubble::Init(views::Widget* parent, #if defined(OS_WIN) DCHECK(!border_.get()); - border_.reset(CreateBorderWidget()); - border_->Init(GetNativeView()); + border_.reset(new BorderWidget()); + border_->Init(CreateBorderContents(), GetNativeView()); // Initialize and position the border window. window_bounds = border_->SizeAndGetBounds(position_relative_to, @@ -341,7 +337,7 @@ void InfoBubble::Init(views::Widget* parent, views::Background::CreateSolidBackground(kBackgroundColor)); #else // Create a view to paint the border and background. - border_contents_ = new BorderContents; + border_contents_ = CreateBorderContents(); border_contents_->Init(); gfx::Rect contents_bounds; border_contents_->SizeAndGetBounds(position_relative_to, @@ -375,11 +371,9 @@ void InfoBubble::Init(views::Widget* parent, #endif } -#if defined(OS_WIN) -BorderWidget* InfoBubble::CreateBorderWidget() { - return new BorderWidget; +BorderContents* InfoBubble::CreateBorderContents() { + return new BorderContents(); } -#endif void InfoBubble::SizeToContents() { gfx::Rect window_bounds; diff --git a/chrome/browser/views/info_bubble.h b/chrome/browser/views/info_bubble.h index 6dad21f..8b3e1f6 100644 --- a/chrome/browser/views/info_bubble.h +++ b/chrome/browser/views/info_bubble.h @@ -116,7 +116,7 @@ class BorderWidget : public views::WidgetWin { virtual ~BorderWidget() { } // Initializes the BrowserWidget making |owner| its owning window. - void Init(HWND owner); + void Init(BorderContents* border_contents, HWND owner); // Given the size of the contained contents (without margins), and the rect // (in screen coordinates) to point to, sets the border window positions and @@ -129,10 +129,6 @@ class BorderWidget : public views::WidgetWin { const gfx::Size& contents_size); protected: - // Instanciates and returns the BorderContents this BorderWidget should use. - // Subclasses can return their own BorderContents implementation. - virtual BorderContents* CreateBorderContents(); - BorderContents* border_contents_; private: @@ -204,11 +200,9 @@ class InfoBubble views::View* contents, InfoBubbleDelegate* delegate); -#if defined(OS_WIN) - // Instanciates and returns the BorderWidget this InfoBubble should use. - // Subclasses can return their own BorderWidget specialization. - virtual BorderWidget* CreateBorderWidget(); -#endif + // Instanciates and returns the BorderContents this InfoBubble should use. + // Subclasses can return their own BorderContents implementation. + virtual BorderContents* CreateBorderContents(); #if defined(OS_WIN) // Overridden from WidgetWin: diff --git a/chrome/browser/views/pinned_contents_info_bubble.cc b/chrome/browser/views/pinned_contents_info_bubble.cc index 532dcdf..c064c16 100644 --- a/chrome/browser/views/pinned_contents_info_bubble.cc +++ b/chrome/browser/views/pinned_contents_info_bubble.cc @@ -6,9 +6,6 @@ #include "chrome/browser/views/bubble_border.h" -#if defined(OS_WIN) -// BorderWidget --------------------------------------------------------------- - void PinnedContentsBorderContents::SizeAndGetBounds( const gfx::Rect& position_relative_to, BubbleBorder::ArrowLocation arrow_location, @@ -34,11 +31,6 @@ void PinnedContentsBorderContents::SizeAndGetBounds( window_bounds->Offset(0, -(kTopMargin + 1)); } -BorderContents* PinnedContentsBorderWidget::CreateBorderContents() { - return new PinnedContentsBorderContents(bubble_anchor_); -} -#endif - // InfoBubble ----------------------------------------------------------------- // static @@ -56,10 +48,6 @@ PinnedContentsInfoBubble* PinnedContentsInfoBubble::Show( return window; } -// TODO(finnur): This needs to be implemented for other platforms once we decide -// this is the way to go. -#if defined(OS_WIN) -BorderWidget* PinnedContentsInfoBubble::CreateBorderWidget() { - return new PinnedContentsBorderWidget(bubble_anchor_); +BorderContents* PinnedContentsInfoBubble::CreateBorderContents() { + return new PinnedContentsBorderContents(bubble_anchor_); } -#endif diff --git a/chrome/browser/views/pinned_contents_info_bubble.h b/chrome/browser/views/pinned_contents_info_bubble.h index 87d2a9d..8033b39 100644 --- a/chrome/browser/views/pinned_contents_info_bubble.h +++ b/chrome/browser/views/pinned_contents_info_bubble.h @@ -31,25 +31,6 @@ class PinnedContentsBorderContents : public BorderContents { DISALLOW_COPY_AND_ASSIGN(PinnedContentsBorderContents); }; -#if defined(OS_WIN) -// The window that surrounds the info bubble. See base class for details. -class PinnedContentsBorderWidget : public BorderWidget { - public: - explicit PinnedContentsBorderWidget(const gfx::Point& bubble_anchor) - : bubble_anchor_(bubble_anchor) {} - virtual ~PinnedContentsBorderWidget() {} - - // BorderWidget overrides: - virtual BorderContents* CreateBorderContents(); - - private: - // The location of the pinned contents (in screen coordinates). - const gfx::Point bubble_anchor_; - - DISALLOW_COPY_AND_ASSIGN(PinnedContentsBorderWidget); -}; -#endif - // A specialization of the InfoBubble. Used to draw an InfoBubble which, in // addition to having an arrow pointing to where the user clicked, also shifts // the bubble horizontally to fix it to a specific location. See base class @@ -69,16 +50,14 @@ class PinnedContentsInfoBubble : public InfoBubble { views::View* contents, InfoBubbleDelegate* delegate); + // InfoBubble overrides: + virtual BorderContents* CreateBorderContents(); + private: explicit PinnedContentsInfoBubble(const gfx::Point& bubble_anchor) : bubble_anchor_(bubble_anchor) {} virtual ~PinnedContentsInfoBubble() {} - // InfoBubble overrides: -#if defined(OS_WIN) - virtual BorderWidget* CreateBorderWidget(); -#endif - // The location of the pinned contents (in screen coordinates). const gfx::Point bubble_anchor_; diff --git a/chrome/browser/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/views/tabs/browser_tab_strip_controller.cc index a2a8c92..eeb24eb 100644 --- a/chrome/browser/views/tabs/browser_tab_strip_controller.cc +++ b/chrome/browser/views/tabs/browser_tab_strip_controller.cc @@ -252,18 +252,13 @@ bool BrowserTabStripController::IsCompatibleWith(BaseTabStrip* other) const { } void BrowserTabStripController::CreateNewTab() { - // TODO(jcampan): if we decide to keep the app launcher as the default - // behavior for the new tab button, we should add a method - // on the TabStripDelegate to do so. - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsPanel)) { - NavigationController& controller = - model_->GetSelectedTabContents()->controller(); - AppLauncher::ShowForNewTab( - Browser::GetBrowserForController(&controller, NULL), std::string()); - return; - } UserMetrics::RecordAction(UserMetricsAction("NewTab_Button"), model_->profile()); + + Browser* browser = model_->GetSelectedTabContents()->delegate()->GetBrowser(); + if (browser->OpenAppsPanelAsNewTab()) + return; + model_->delegate()->AddBlankTab(true); } |