diff options
author | jhaas@chromium.org <jhaas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-16 20:41:22 +0000 |
---|---|---|
committer | jhaas@chromium.org <jhaas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-16 20:41:22 +0000 |
commit | e57d57f04228aee2cfe96a598669f8e0b1662f09 (patch) | |
tree | 44ae18e58aad2d5216adcf483b09de503f3f2dba /chrome | |
parent | d778c4701b5e5ffec54eee51d2427836f4f5c0b1 (diff) | |
download | chromium_src-e57d57f04228aee2cfe96a598669f8e0b1662f09.zip chromium_src-e57d57f04228aee2cfe96a598669f8e0b1662f09.tar.gz chromium_src-e57d57f04228aee2cfe96a598669f8e0b1662f09.tar.bz2 |
Added code for personalization to the new frame class
Review URL: http://codereview.chromium.org/3074
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2278 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/views/frame/browser_view2.cc | 30 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view2.h | 19 |
2 files changed, 48 insertions, 1 deletions
diff --git a/chrome/browser/views/frame/browser_view2.cc b/chrome/browser/views/frame/browser_view2.cc index cd34924..1ce9174 100644 --- a/chrome/browser/views/frame/browser_view2.cc +++ b/chrome/browser/views/frame/browser_view2.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/command_line.h" + #include "chrome/browser/views/frame/browser_view2.h" #include "chrome/app/chrome_dll_resource.h" @@ -18,6 +20,7 @@ #include "chrome/browser/views/tab_contents_container_view.h" #include "chrome/browser/views/tabs/tab_strip.h" #include "chrome/browser/views/toolbar_view.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/drag_drop_types.h" #include "chrome/common/l10n_util.h" #include "chrome/common/notification_service.h" @@ -91,6 +94,10 @@ BrowserView2::BrowserView2(Browser* browser) contents_container_(NULL), initialized_(false), can_drop_(false), +#ifdef CHROME_PERSONALIZATION + personalization_enabled_(false), + personalization_(NULL), +#endif forwarding_to_tab_strip_(false) { InitClass(); show_bookmark_bar_pref_.Init(prefs::kShowBookmarkBar, @@ -285,6 +292,14 @@ void BrowserView2::Init() { AddChildView(contents_container_); status_bubble_.reset(new StatusBubble(GetViewContainer())); + +#ifdef CHROME_PERSONALIZATION + EnablePersonalization(CommandLine().HasSwitch(switches::kEnableP13n)); + if (IsPersonalizationEnabled()) { + personalization_ = Personalization::CreateFramePersonalization( + browser_->profile(), this); + } +#endif } void BrowserView2::Show(int command, bool adjust_to_fit) { @@ -752,6 +767,14 @@ void BrowserView2::Layout() { int bottom = LayoutDownloadShelf(); LayoutTabContents(top, bottom); LayoutStatusBubble(bottom); +#ifdef CHROME_PERSONALIZATION + if (IsPersonalizationEnabled()) { + Personalization::ConfigureFramePersonalization(personalization_, + toolbar_, 0); + } +#endif + + SchedulePaint(); } @@ -876,7 +899,12 @@ int BrowserView2::LayoutToolbar(int top) { // by a pixel to make things look good. if (!IsTabStripVisible() && win_util::ShouldUseVistaFrame()) ps.cy -= 1; - toolbar_->SetBounds(0, toolbar_y, GetWidth(), ps.cy); + int browser_view_width = GetWidth(); +#ifdef CHROME_PERSONALIZATION + if (IsPersonalizationEnabled()) + Personalization::AdjustBrowserView(personalization_, &browser_view_width); +#endif + toolbar_->SetBounds(0, toolbar_y, browser_view_width, ps.cy); return toolbar_y + ps.cy; } toolbar_->SetVisible(false); diff --git a/chrome/browser/views/frame/browser_view2.h b/chrome/browser/views/frame/browser_view2.h index 5d97e58..6f1329d 100644 --- a/chrome/browser/views/frame/browser_view2.h +++ b/chrome/browser/views/frame/browser_view2.h @@ -205,6 +205,19 @@ class BrowserView2 : public BrowserWindow, virtual bool CanClose() const; virtual int NonClientHitTest(const gfx::Point& point); + // Is P13N enabled for this browser window? +#ifdef CHROME_PERSONALIZATION + virtual bool IsPersonalizationEnabled() const { + return personalization_enabled_; + } + + void EnablePersonalization(bool enable_personalization) { + personalization_enabled_ = enable_personalization; + } +#endif + + + protected: // Overridden from ChromeViews::View: virtual void Layout(); @@ -353,6 +366,12 @@ class BrowserView2 : public BrowserWindow, // The delegate for the encoding menu. scoped_ptr<EncodingMenuControllerDelegate> encoding_menu_delegate_; + // P13N stuff +#ifdef CHROME_PERSONALIZATION + FramePersonalization personalization_; + bool personalization_enabled_; +#endif + DISALLOW_EVIL_CONSTRUCTORS(BrowserView2); }; |