diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 1 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 23 | ||||
-rw-r--r-- | chrome/browser/browser.h | 8 | ||||
-rw-r--r-- | chrome/browser/browser_commands.cc | 11 | ||||
-rw-r--r-- | chrome/browser/browser_window.h | 22 | ||||
-rw-r--r-- | chrome/browser/native_ui_contents.cc | 5 | ||||
-rw-r--r-- | chrome/browser/vista_frame.cc | 34 | ||||
-rw-r--r-- | chrome/browser/vista_frame.h | 11 | ||||
-rw-r--r-- | chrome/browser/web_contents.cc | 1 | ||||
-rw-r--r-- | chrome/browser/xp_frame.cc | 32 | ||||
-rw-r--r-- | chrome/browser/xp_frame.h | 13 |
11 files changed, 117 insertions, 44 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index fa4f63f..1ca0d81 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -45,6 +45,7 @@ #include "chrome/browser/printing/print_job.h" #include "chrome/browser/save_package.h" #include "chrome/browser/ssl_blocking_page.h" +#include "chrome/browser/views/location_bar_view.h" #include "chrome/common/chrome_paths.h" #include "chrome/test/automation/automation_messages.h" #include "net/base/cookie_monster.h" diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index fa76bd9..cec09dd 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -211,7 +211,6 @@ Browser::Browser(const gfx::Rect& initial_bounds, initial_show_command_(show_command), is_processing_tab_unload_events_(false), controller_(this), - toolbar_(&controller_, this), chrome_updater_factory_(this), method_factory_(this), hung_window_detector_(&hung_plugin_action_), @@ -235,9 +234,6 @@ Browser::Browser(const gfx::Rect& initial_bounds, initial_show_command_ = SW_SHOWMAXIMIZED; window_ = FrameUtil::CreateBrowserWindow(create_bounds, this); - toolbar_.SetID(VIEW_ID_TOOLBAR); - toolbar_.Init(profile_); - // See note where SIZE_TO_CONTENTS is defined in browser.h for an explanation // of this hack. if (show_command == SIZE_TO_CONTENTS) { @@ -308,11 +304,6 @@ Browser::~Browser() { NotificationService::AllSources()); ChromeViews::View* p; - // Remove our main views from the view hierarchy to prevent - // a double delete (the Browser is deleted before the RootView that contains - // the toolbar and tab_strip). - if ((p = toolbar_.GetParent())) - p->RemoveChildView(&toolbar_); if (bookmark_bar_view_.get() && (p = bookmark_bar_view_->GetParent())) p->RemoveChildView(bookmark_bar_view_.get()); @@ -370,10 +361,6 @@ void Browser::CloseFrame() { window_->Close(); } -ChromeViews::View* Browser::GetToolbar() { - return &toolbar_; -} - GURL Browser::GetHomePage() { if (profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) { return NewTabUIURL(); @@ -414,14 +401,14 @@ void Browser::WindowActivationChanged(bool is_active) { // Toolbar creation, management LocationBarView* Browser::GetLocationBarView() const { - return toolbar_.GetLocationBarView(); + return window_->GetLocationBarView(); } //////////////////////////////////////////////////////////////////////////////// // Chrome update coalescing void Browser::UpdateToolBar(bool should_restore_state) { - toolbar_.Update(GetSelectedTabContents(), should_restore_state); + window_->Update(GetSelectedTabContents(), should_restore_state); } void Browser::ScheduleUIUpdate(const TabContents* source, @@ -903,11 +890,11 @@ void Browser::UpdateTargetURL(TabContents* source, const GURL& url) { } void Browser::SetStarredButtonToggled(bool starred) { - toolbar_.star_button()->SetToggled(starred); + window_->GetStarButton()->SetToggled(starred); } GoButton* Browser::GetGoButton() { - return toolbar_.GetGoButton(); + return window_->GetGoButton(); } void Browser::ContentsZoomChange(bool zoom_in) { @@ -1417,7 +1404,7 @@ void Browser::TabSelectedAt(TabContents* old_contents, new_contents->RestoreFocus(); // Propagate the profile to the location bar. - toolbar_.SetProfile(new_contents->profile()); + window_->ProfileChanged(new_contents->profile()); UpdateToolBar(true); // Force the go/stop button to change. diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index 807ed07..80a9824 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -32,6 +32,7 @@ #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser_type.h" +#include "chrome/browser/controller.h" #include "chrome/browser/hang_monitor/hung_plugin_action.h" #include "chrome/browser/hang_monitor/hung_window_detector.h" #include "chrome/browser/render_process_host.h" @@ -43,7 +44,6 @@ #include "chrome/browser/tabs/tab.h" #include "chrome/browser/toolbar_model.h" #include "chrome/browser/views/html_dialog_view.h" -#include "chrome/browser/views/toolbar_view.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_member.h" @@ -398,9 +398,6 @@ class Browser : public TabStripModelDelegate, // Closes the frame. void CloseFrame(); - // Invoked by the frame. Return the toolbar for this browser. - ChromeViews::View* GetToolbar(); - // Returns the root view for this browser. ChromeViews::RootView* GetRootView() const; @@ -542,9 +539,6 @@ class Browser : public TabStripModelDelegate, // subsequent calls to Show() should be ignored. int initial_show_command_; - // The toolbar view. - BrowserToolbarView toolbar_; - class BrowserToolbarModel : public ToolbarModel { public: explicit BrowserToolbarModel(Browser* browser) : browser_(browser) { } diff --git a/chrome/browser/browser_commands.cc b/chrome/browser/browser_commands.cc index cdfc7a2..79e1f06 100644 --- a/chrome/browser/browser_commands.cc +++ b/chrome/browser/browser_commands.cc @@ -393,10 +393,7 @@ void Browser::ExecuteCommand(int id) { case IDC_FOCUS_TOOLBAR: UserMetrics::RecordAction(L"FocusToolbar", profile_); { - ChromeViews::View* tb = GetToolbar(); - if (tb) { - tb->RequestFocus(); - } + window_->FocusToolbar(); } break; @@ -871,8 +868,8 @@ void Browser::StarCurrentTabContents() { if (url.is_empty() || !url.is_valid()) return; - if (toolbar_.star_button()) { - if (!toolbar_.star_button()->is_bubble_showing()) { + if (window_->GetStarButton()) { + if (!window_->GetStarButton()->is_bubble_showing()) { const bool newly_bookmarked = (model->GetNodeByURL(url) == NULL); if (newly_bookmarked) { model->SetURLStarred(url, entry->GetTitle(), true); @@ -882,7 +879,7 @@ void Browser::StarCurrentTabContents() { return; } } - toolbar_.star_button()->ShowStarBubble(url, newly_bookmarked); + window_->GetStarButton()->ShowStarBubble(url, newly_bookmarked); } } else if (model->GetNodeByURL(url)) { // If we can't find the star button and the user wanted to unstar it, diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h index 8f5a0da..4e06efd 100644 --- a/chrome/browser/browser_window.h +++ b/chrome/browser/browser_window.h @@ -40,9 +40,13 @@ class BrowserList; namespace ChromeViews { class RootView; } +class GoButton; +class LocationBarView; +class Profile; class StatusBubble; class TabContents; class TabStrip; +class ToolbarStarToggle; //////////////////////////////////////////////////////////////////////////////// // BrowserWindow interface @@ -174,6 +178,24 @@ class BrowserWindow { DefWindowProc(hwnd, WM_NCACTIVATE, FALSE, 0); } + // Returns the star button. + virtual ToolbarStarToggle* GetStarButton() const = 0; + + // Returns the location bar. + virtual LocationBarView* GetLocationBarView() const = 0; + + // Returns the go button. + virtual GoButton* GetGoButton() const = 0; + + // Updates the toolbar with the state for the specified |contents|. + virtual void Update(TabContents* contents, bool should_restore_state) = 0; + + // Updates the UI with the specified Profile. + virtual void ProfileChanged(Profile* profile) = 0; + + // Focuses the toolbar (for accessibility). + virtual void FocusToolbar() = 0; + protected: friend class BrowserList; virtual void DestroyBrowser() = 0; diff --git a/chrome/browser/native_ui_contents.cc b/chrome/browser/native_ui_contents.cc index ff7b24d..977aae8 100644 --- a/chrome/browser/native_ui_contents.cc +++ b/chrome/browser/native_ui_contents.cc @@ -37,13 +37,14 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/os_exchange_data.h" #include "chrome/common/resource_bundle.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/background.h" #include "chrome/views/checkbox.h" #include "chrome/views/grid_layout.h" +#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/image_view.h" #include "chrome/views/root_view.h" #include "chrome/views/scroll_view.h" #include "chrome/views/throbber.h" -#include "chrome/views/background.h" #include "generated_resources.h" diff --git a/chrome/browser/vista_frame.cc b/chrome/browser/vista_frame.cc index e437d33..a1ddfc6 100644 --- a/chrome/browser/vista_frame.cc +++ b/chrome/browser/vista_frame.cc @@ -48,8 +48,10 @@ #include "chrome/browser/tab_contents_container_view.h" #include "chrome/browser/tabs/tab_strip.h" #include "chrome/browser/window_clipping_info.h" +#include "chrome/browser/view_ids.h" #include "chrome/browser/views/bookmark_bar_view.h" #include "chrome/browser/views/download_shelf_view.h" +#include "chrome/browser/views/toolbar_view.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/l10n_util.h" @@ -403,10 +405,12 @@ void VistaFrame::Init() { root_view_.SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); frame_view_->SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); - toolbar_ = browser_->GetToolbar(); - toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); + toolbar_ = new BrowserToolbarView(browser_->controller(), browser_); frame_view_->AddChildView(toolbar_); - + toolbar_->SetID(VIEW_ID_TOOLBAR); + toolbar_->Init(browser_->profile()); + toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); + tabstrip_ = CreateTabStrip(browser_); tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP)); frame_view_->AddChildView(tabstrip_); @@ -613,6 +617,30 @@ void VistaFrame::InfoBubbleShowing() { ignore_ncactivate_ = true; } +ToolbarStarToggle* VistaFrame::GetStarButton() const { + return toolbar_->star_button(); +} + +LocationBarView* VistaFrame::GetLocationBarView() const { + return toolbar_->GetLocationBarView(); +} + +GoButton* VistaFrame::GetGoButton() const { + return toolbar_->GetGoButton(); +} + +void VistaFrame::Update(TabContents* contents, bool should_restore_state) { + toolbar_->Update(contents, should_restore_state); +} + +void VistaFrame::ProfileChanged(Profile* profile) { + toolbar_->SetProfile(profile); +} + +void VistaFrame::FocusToolbar() { + toolbar_->RequestFocus(); +} + //////////////////////////////////////////////////////////////////////////////// // // Events diff --git a/chrome/browser/vista_frame.h b/chrome/browser/vista_frame.h index e9e1d0a..a545d37 100644 --- a/chrome/browser/vista_frame.h +++ b/chrome/browser/vista_frame.h @@ -50,6 +50,7 @@ #define VISTA_FRAME_CLASSNAME L"Chrome_VistaFrame" class Browser; +class BrowserToolbarView; class TabContentsContainerView; class ChromeViews::FocusManager; class SkBitmap; @@ -202,6 +203,12 @@ class VistaFrame : public BrowserWindow, virtual void SetBounds(const gfx::Rect& bounds); virtual void DetachFromBrowser(); virtual void InfoBubbleShowing(); + virtual ToolbarStarToggle* GetStarButton() const; + virtual LocationBarView* GetLocationBarView() const; + virtual GoButton* GetGoButton() const; + virtual void Update(TabContents* contents, bool should_restore_state); + virtual void ProfileChanged(Profile* profile); + virtual void FocusToolbar(); //////////////////////////////////////////////////////////////////////////////// // ChromeViews::ViewContainer @@ -361,8 +368,8 @@ class VistaFrame : public BrowserWindow, // The view that contains the tabs and any associated controls. TabStrip* tabstrip_; - // Toolbar provided by our browser - ChromeViews::View* toolbar_; + // The Toolbar containing the navigation buttons, menus and the address bar. + BrowserToolbarView* toolbar_; // Browser contents TabContentsContainerView* tab_contents_container_; diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc index 0d5ed17..bed2787 100644 --- a/chrome/browser/web_contents.cc +++ b/chrome/browser/web_contents.cc @@ -65,6 +65,7 @@ #include "chrome/browser/web_drag_source.h" #include "chrome/browser/web_drop_target.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/os_exchange_data.h" #include "chrome/common/pref_names.h" #include "chrome/common/resource_bundle.h" diff --git a/chrome/browser/xp_frame.cc b/chrome/browser/xp_frame.cc index d3f57f2..72f8478 100644 --- a/chrome/browser/xp_frame.cc +++ b/chrome/browser/xp_frame.cc @@ -43,8 +43,10 @@ #include "chrome/browser/tab_contents_container_view.h" #include "chrome/browser/tabs/tab_strip.h" #include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/view_ids.h" #include "chrome/browser/views/bookmark_bar_view.h" #include "chrome/browser/views/download_shelf_view.h" +#include "chrome/browser/views/toolbar_view.h" #include "chrome/browser/window_clipping_info.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/gfx/chrome_canvas.h" @@ -437,9 +439,11 @@ void XPFrame::Init() { root_view_.SetBackground( ChromeViews::Background::CreateSolidBackground(SK_ColorWHITE)); - toolbar_ = browser_->GetToolbar(); - toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); + toolbar_ = new BrowserToolbarView(browser_->controller(), browser_); frame_view_->AddChildView(toolbar_); + toolbar_->SetID(VIEW_ID_TOOLBAR); + toolbar_->Init(browser_->profile()); + toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); tabstrip_ = CreateTabStrip(browser_); tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP)); @@ -1845,6 +1849,30 @@ void XPFrame::InfoBubbleClosing() { InvalidateRect(NULL, false); } +ToolbarStarToggle* XPFrame::GetStarButton() const { + return toolbar_->star_button(); +} + +LocationBarView* XPFrame::GetLocationBarView() const { + return toolbar_->GetLocationBarView(); +} + +GoButton* XPFrame::GetGoButton() const { + return toolbar_->GetGoButton(); +} + +void XPFrame::Update(TabContents* contents, bool should_restore_state) { + toolbar_->Update(contents, should_restore_state); +} + +void XPFrame::ProfileChanged(Profile* profile) { + toolbar_->SetProfile(profile); +} + +void XPFrame::FocusToolbar() { + toolbar_->RequestFocus(); +} + void XPFrame::MoveToFront(bool should_activate) { int flags = SWP_NOMOVE | SWP_NOSIZE; if (!should_activate) { diff --git a/chrome/browser/xp_frame.h b/chrome/browser/xp_frame.h index a3fa706..f500fad 100644 --- a/chrome/browser/xp_frame.h +++ b/chrome/browser/xp_frame.h @@ -51,6 +51,7 @@ class ChromeViews::RootView; class Browser; +class BrowserToolbarView; class TabContentsContainerView; class TabStrip; class TemporaryPlaceholder; @@ -109,6 +110,12 @@ class XPFrame : public BrowserWindow, virtual void DetachFromBrowser(); virtual void InfoBubbleShowing(); virtual void InfoBubbleClosing(); + virtual ToolbarStarToggle* GetStarButton() const; + virtual LocationBarView* GetLocationBarView() const; + virtual GoButton* GetGoButton() const; + virtual void Update(TabContents* contents, bool should_restore_state); + virtual void ProfileChanged(Profile* profile); + virtual void FocusToolbar(); // // CWindowImpl event management magic. See atlcrack.h @@ -423,9 +430,6 @@ class XPFrame : public BrowserWindow, // Top level view used to render the frame itself including the title bar XPFrameView* frame_view_; - // Toolbar provided by our browser - ChromeViews::View* toolbar_; - // Browser contents TabContentsContainerView* tab_contents_container_; @@ -491,6 +495,9 @@ class XPFrame : public BrowserWindow, // The view that contains the tabs and any associated controls. TabStrip* tabstrip_; + // The Toolbar containing the navigation buttons, menus and the address bar. + BrowserToolbarView* toolbar_; + // The optional container for the off the record icon. ChromeViews::ImageView* off_the_record_image_; |