diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-19 22:56:52 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-19 22:56:52 +0000 |
commit | 3381b5cf273a8d0311230cbc9e72f08484dd9af7 (patch) | |
tree | 53a5bec6592e5f19dc4f586056b798dc6aa8f888 /chrome | |
parent | d922d0034bf1a8c8584fa3bbfd54ff94ae1ede92 (diff) | |
download | chromium_src-3381b5cf273a8d0311230cbc9e72f08484dd9af7.zip chromium_src-3381b5cf273a8d0311230cbc9e72f08484dd9af7.tar.gz chromium_src-3381b5cf273a8d0311230cbc9e72f08484dd9af7.tar.bz2 |
Add a skeleton browser_frame implementation for GTK, make browser_view (which
it needs) compile on GTK.
Review URL: http://codereview.chromium.org/113589
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16426 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/views/frame/browser_frame_gtk.cc | 57 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_frame_gtk.h | 41 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_frame_win.h | 2 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 26 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 19 | ||||
-rw-r--r-- | chrome/chrome.gyp | 4 |
6 files changed, 133 insertions, 16 deletions
diff --git a/chrome/browser/views/frame/browser_frame_gtk.cc b/chrome/browser/views/frame/browser_frame_gtk.cc new file mode 100644 index 0000000..e9ac7a2 --- /dev/null +++ b/chrome/browser/views/frame/browser_frame_gtk.cc @@ -0,0 +1,57 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/logging.h" +#include "chrome/browser/views/frame/browser_frame_gtk.h" +#include "chrome/browser/views/frame/browser_view.h" + +// static (Factory method.) +BrowserFrame* BrowserFrame::Create(BrowserView* browser_view, + Profile* profile) { + BrowserFrameGtk* frame = new BrowserFrameGtk(browser_view, profile); + frame->Init(); + return frame; +} + +BrowserFrameGtk::BrowserFrameGtk(BrowserView* browser_view, Profile* profile) + : WindowGtk(browser_view), + browser_view_(browser_view), + profile_(profile) { + browser_view_->set_frame(this); + GetNonClientView()->SetFrameView(CreateFrameViewForWindow()); + // Don't focus anything on creation, selecting a tab will set the focus. +} + +BrowserFrameGtk::~BrowserFrameGtk() { +} + +void BrowserFrameGtk::Init() { + WindowGtk::Init(gfx::Rect()); +} + +views::Window* BrowserFrameGtk::GetWindow() { + return this; +} + +void BrowserFrameGtk::TabStripCreated(TabStrip* tabstrip) { + NOTIMPLEMENTED(); +} + +int BrowserFrameGtk::GetMinimizeButtonOffset() const { + NOTIMPLEMENTED(); + return 0; +} + +gfx::Rect BrowserFrameGtk::GetBoundsForTabStrip(TabStrip* tabstrip) const { + NOTIMPLEMENTED(); + return gfx::Rect(); +} + +void BrowserFrameGtk::UpdateThrobber(bool running) { + NOTIMPLEMENTED(); +} + +ThemeProvider* BrowserFrameGtk::GetThemeProviderForFrame() const { + return profile_->GetThemeProvider(); +} diff --git a/chrome/browser/views/frame/browser_frame_gtk.h b/chrome/browser/views/frame/browser_frame_gtk.h new file mode 100644 index 0000000..650e24f --- /dev/null +++ b/chrome/browser/views/frame/browser_frame_gtk.h @@ -0,0 +1,41 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_VIEWS_FRAME_GTK_BROWSER_FRAME_GTK_H_ +#define CHROME_BROWSER_VIEWS_FRAME_GTK_BROWSER_FRAME_GTK_H_ + +#include "base/basictypes.h" +#include "chrome/browser/views/frame/browser_frame.h" +#include "views/window/window_gtk.h" + +class BrowserFrameGtk : public BrowserFrame, + public views::WindowGtk { + public: + // Normally you will create this class by calling BrowserFrame::Create. + // Init must be called before using this class, which Create will do for you. + BrowserFrameGtk(BrowserView* browser_view, Profile* profile); + virtual ~BrowserFrameGtk(); + + // This initialization function must be called after construction, it is + // separate to avoid recursive calling of the frame from its constructor. + void Init(); + + // BrowserFrame implementation. + virtual views::Window* GetWindow(); + virtual void TabStripCreated(TabStrip* tabstrip); + virtual int GetMinimizeButtonOffset() const; + virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const; + virtual void UpdateThrobber(bool running); + virtual ThemeProvider* GetThemeProviderForFrame() const; + + private: + // The BrowserView is our ClientView. This is a pointer to it. + BrowserView* browser_view_; + + Profile* profile_; + + DISALLOW_COPY_AND_ASSIGN(BrowserFrameGtk); +}; + +#endif // CHROME_BROWSER_VIEWS_FRAME_GTK_BROWSER_FRAME_GTK_H_ diff --git a/chrome/browser/views/frame/browser_frame_win.h b/chrome/browser/views/frame/browser_frame_win.h index 5d72df4..90a5b30 100644 --- a/chrome/browser/views/frame/browser_frame_win.h +++ b/chrome/browser/views/frame/browser_frame_win.h @@ -96,7 +96,7 @@ class BrowserFrameWin : public BrowserFrame, public views::WindowWin { // An unowning reference to the root view associated with the window. We save // a copy as a BrowserRootView to avoid evil casting later, when we need to - // call functions only on BrowserRootView. + // call functions that only exist on BrowserRootView (versus RootView). BrowserRootView* root_view_; bool frame_initialized_; diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index ddd2958..000371c 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -483,6 +483,7 @@ SkBitmap BrowserView::GetOTRAvatarIcon() { return otr_avatar_; } +#if defined(OS_WIN) void BrowserView::PrepareToRunSystemMenu(HMENU menu) { for (int i = 0; i < arraysize(kMenuLayout); ++i) { int command = kMenuLayout[i].command; @@ -506,6 +507,7 @@ void BrowserView::PrepareToRunSystemMenu(HMENU menu) { } } } +#endif // static void BrowserView::RegisterBrowserViewPrefs(PrefService* prefs) { @@ -571,8 +573,8 @@ bool BrowserView::IsActive() const { return frame_->GetWindow()->IsActive(); } -#if defined(OS_WIN) void BrowserView::FlashFrame() { +#if defined(OS_WIN) FLASHWINFO fwi; fwi.cbSize = sizeof(fwi); fwi.hwnd = frame_->GetWindow()->GetNativeWindow(); @@ -580,8 +582,10 @@ void BrowserView::FlashFrame() { fwi.uCount = 4; fwi.dwTimeout = 0; FlashWindowEx(&fwi); -} +#else + NOTIMPLEMENTED(); #endif +} gfx::NativeWindow BrowserView::GetNativeHandle() { return GetWidget()->GetNativeView(); @@ -641,8 +645,8 @@ bool BrowserView::IsMaximized() const { return frame_->GetWindow()->IsMaximized(); } -#if defined(OS_WIN) void BrowserView::SetFullscreen(bool fullscreen) { +#if defined(OS_WIN) if (IsFullscreen() == fullscreen) return; // Nothing to do. @@ -696,8 +700,10 @@ void BrowserView::SetFullscreen(bool fullscreen) { ignore_layout_ = false; Layout(); frame_->GetWindow()->PopForceHidden(); -} +#else + NOTIMPLEMENTED(); #endif +} bool BrowserView::IsFullscreen() const { return frame_->GetWindow()->IsFullscreen(); @@ -873,17 +879,19 @@ void BrowserView::ConfirmBrowserCloseWithPendingDownloads() { delegate)->Show(); } -#if defined(OS_WIN) void BrowserView::ShowHTMLDialog(HtmlDialogUIDelegate* delegate, void* parent_window) { +#if defined(OS_WIN) HWND parent_hwnd = reinterpret_cast<HWND>(parent_window); parent_hwnd = parent_hwnd ? parent_hwnd : GetWidget()->GetNativeView(); HtmlDialogView* html_view = new HtmlDialogView(browser_.get(), delegate); views::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), html_view); html_view->InitDialog(); html_view->window()->Show(); -} +#else + NOTIMPLEMENTED(); #endif +} void BrowserView::UserChangedTheme() { frame_->GetWindow()->GetNonClientView()->SetUseNativeFrame(false); @@ -1135,8 +1143,8 @@ bool BrowserView::CanClose() const { return true; } -#if defined(OS_WIN) int BrowserView::NonClientHitTest(const gfx::Point& point) { +#if defined(OS_WIN) // Since the TabStrip only renders in some parts of the top of the window, // the un-obscured area is considered to be part of the non-client caption // area of the window. So we need to treat hit-tests in these regions as @@ -1213,8 +1221,10 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) { // If the point is somewhere else, delegate to the default implementation. return views::ClientView::NonClientHitTest(point); -} +#else + NOTIMPLEMENTED(); #endif +} gfx::Size BrowserView::GetMinimumSize() { // TODO: In theory the tabstrip width should probably be diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index fa3298f..fcb7b4d 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -9,13 +9,16 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" -#include "chrome/browser/hang_monitor/hung_plugin_action.h" -#include "chrome/browser/hang_monitor/hung_window_detector.h" #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/views/frame/browser_frame.h" #include "views/window/client_view.h" #include "views/window/window_delegate.h" +#if defined(OS_WIN) +#include "chrome/browser/hang_monitor/hung_plugin_action.h" +#include "chrome/browser/hang_monitor/hung_window_detector.h" +#endif + // NOTE: For more information about the objects and files in this directory, // view: http://dev.chromium.org/developers/design-documents/browser-window @@ -60,10 +63,12 @@ class BrowserView : public BrowserWindow, void set_frame(BrowserFrame* frame) { frame_ = frame; } BrowserFrame* frame() const { return frame_; } +#if defined(OS_WIN) // Returns a pointer to the BrowserView* interface implementation (an // instance of this object, typically) for a given HWND, or NULL if there is // no such association. static BrowserView* GetBrowserViewForHWND(HWND window); +#endif // Returns the show flag that should be used to show the frame containing // this view. @@ -125,10 +130,6 @@ class BrowserView : public BrowserWindow, // otherwise. bool GetAccelerator(int cmd_id, views::Accelerator* accelerator); - // Handles incoming system messages. Returns true if the message was - // handled. - bool SystemCommandReceived(UINT notification_code, const gfx::Point& point); - // Shows the next app-modal dialog box, if there is one to be shown, or moves // an existing showing one to the front. Returns true if one was shown or // activated, false if none was shown. @@ -148,9 +149,11 @@ class BrowserView : public BrowserWindow, // Retrieves the icon to use in the frame to indicate an OTR window. SkBitmap GetOTRAvatarIcon(); +#if defined(OS_WIN) // Called right before displaying the system menu to allow the BrowserView // to add or delete entries. void PrepareToRunSystemMenu(HMENU menu); +#endif // Returns true if the Browser object associated with this BrowserView is a // normal-type window (i.e. a browser window, not an app or popup). @@ -375,7 +378,7 @@ class BrowserView : public BrowserWindow, scoped_ptr<StatusBubbleViews> status_bubble_; // A mapping between accelerators and commands. - scoped_ptr<std::map<views::Accelerator, int>> accelerator_table_; + scoped_ptr< std::map<views::Accelerator, int> > accelerator_table_; // True if we have already been initialized. bool initialized_; @@ -398,6 +401,7 @@ class BrowserView : public BrowserWindow, // The delegate for the encoding menu. scoped_ptr<EncodingMenuControllerDelegate> encoding_menu_delegate_; +#if defined(OS_WIN) // This object is used to perform periodic actions in a worker // thread. It is currently used to monitor hung plugin windows. WorkerThreadTicker ticker_; @@ -410,6 +414,7 @@ class BrowserView : public BrowserWindow, // This object is invoked by hung_window_detector_ when it detects a hung // plugin window. HungPluginAction hung_plugin_action_; +#endif // The timer used to update frames for the Loading Animation. base::RepeatingTimer<BrowserView> loading_animation_timer_; diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 6155d2f..6644c45 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -1356,6 +1356,8 @@ 'browser/views/first_run_view.h', 'browser/views/first_run_view_base.cc', 'browser/views/first_run_view_base.h', + 'browser/views/frame/browser_frame_gtk.cc', + 'browser/views/frame/browser_frame_gtk.h', 'browser/views/frame/browser_frame_win.cc', 'browser/views/frame/browser_frame_win.h', 'browser/views/frame/browser_root_view.cc', @@ -1599,6 +1601,8 @@ ['include', '^browser/dock_info_gtk.cc'], ['include', '^browser/dock_info.cc'], ['include', '^browser/dock_info.h'], + ['include', '^browser/views/frame/browser_frame_gtk.cc'], + ['include', '^browser/views/frame/browser_frame_gtk.h'], ['include', '^browser/views/tabs/dragged_tab_view.cc'], ['include', '^browser/views/tabs/dragged_tab_view.h'], ['include', '^browser/views/tabs/tab.cc'], |