diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/instant/instant_controller.cc | 16 | ||||
-rw-r--r-- | chrome/browser/instant/instant_controller.h | 3 | ||||
-rw-r--r-- | chrome/browser/instant/instant_page.cc | 4 | ||||
-rw-r--r-- | chrome/browser/instant/instant_page.h | 3 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/browser_instant_controller.cc | 54 | ||||
-rw-r--r-- | chrome/browser/ui/browser_instant_controller.h | 14 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/browser_view.cc | 8 |
8 files changed, 28 insertions, 79 deletions
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc index 1f25d3d..c879f60 100644 --- a/chrome/browser/instant/instant_controller.cc +++ b/chrome/browser/instant/instant_controller.cc @@ -805,18 +805,6 @@ void InstantController::ThemeChanged(const ThemeBackgroundInfo& theme_info) { instant_tab_->SendThemeBackgroundInfo(theme_info); } -void InstantController::ThemeAreaHeightChanged(int height) { - if (!extended_enabled_) - return; - - if (overlay_) - overlay_->SendThemeAreaHeight(height); - if (ntp_) - ntp_->SendThemeAreaHeight(height); - if (instant_tab_) - instant_tab_->SendThemeAreaHeight(height); -} - void InstantController::SwappedOverlayContents() { model_.SetPreviewContents(GetPreviewContents()); } @@ -864,7 +852,7 @@ void InstantController::InstantPageRenderViewCreated( return; // Update theme info so that the page picks it up. - browser_->UpdateThemeInfoForPreview(); + browser_->UpdateThemeInfo(false); // Ensure the searchbox API has the correct initial state. if (IsContentsFrom(overlay(), contents)) { @@ -1181,7 +1169,7 @@ void InstantController::ResetInstantTab() { instant_tab_.reset(new InstantTab(this)); instant_tab_->Init(active_tab); // Update theme info for this tab. - browser_->UpdateThemeInfoForPreview(); + browser_->UpdateThemeInfo(false); instant_tab_->SetDisplayInstantResults(instant_enabled_); instant_tab_->SetMarginSize(start_margin_, end_margin_); instant_tab_->InitializeFonts(); diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h index 98c691f..e6abd1a 100644 --- a/chrome/browser/instant/instant_controller.h +++ b/chrome/browser/instant/instant_controller.h @@ -153,9 +153,6 @@ class InstantController : public InstantPage::Delegate { // The theme has changed. Pass the message to the preview page. void ThemeChanged(const ThemeBackgroundInfo& theme_info); - // The theme area height has changed. Pass the message to the preview page. - void ThemeAreaHeightChanged(int height); - // Called when someone else swapped in a different contents in the |overlay_|. void SwappedOverlayContents(); diff --git a/chrome/browser/instant/instant_page.cc b/chrome/browser/instant/instant_page.cc index 8463eb8..a82a9c6 100644 --- a/chrome/browser/instant/instant_page.cc +++ b/chrome/browser/instant/instant_page.cc @@ -77,10 +77,6 @@ void InstantPage::SendThemeBackgroundInfo( Send(new ChromeViewMsg_SearchBoxThemeChanged(routing_id(), theme_info)); } -void InstantPage::SendThemeAreaHeight(int height) { - Send(new ChromeViewMsg_SearchBoxThemeAreaHeightChanged(routing_id(), height)); -} - void InstantPage::SetDisplayInstantResults(bool display_instant_results) { Send(new ChromeViewMsg_SearchBoxSetDisplayInstantResults( routing_id(), display_instant_results)); diff --git a/chrome/browser/instant/instant_page.h b/chrome/browser/instant/instant_page.h index 2a02262..2256524 100644 --- a/chrome/browser/instant/instant_page.h +++ b/chrome/browser/instant/instant_page.h @@ -149,9 +149,6 @@ class InstantPage : public content::WebContentsObserver { // Tells the page about the current theme background. void SendThemeBackgroundInfo(const ThemeBackgroundInfo& theme_info); - // Tells the page about the current theme area height. - void SendThemeAreaHeight(int height); - // Tells the page whether it is allowed to display Instant results. void SetDisplayInstantResults(bool display_instant_results); diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 98afd97..dc2f63c 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -2175,6 +2175,11 @@ void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { bookmark_bar_state_ = state; + // Inform NTP page of change in bookmark bar state, so that it can adjust the + // theme image top offset if necessary. + if (instant_controller_) + instant_controller_->UpdateThemeInfo(true); + if (!window_) return; // This is called from the constructor when window_ is NULL. diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc index 14f0113..00493e2 100644 --- a/chrome/browser/ui/browser_instant_controller.cc +++ b/chrome/browser/ui/browser_instant_controller.cc @@ -10,6 +10,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" +#include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/omnibox/location_bar.h" @@ -43,8 +44,7 @@ BrowserInstantController::BrowserInstantController(Browser* browser) instant_(ALLOW_THIS_IN_INITIALIZER_LIST(this), chrome::search::IsInstantExtendedAPIEnabled(profile())), instant_unload_handler_(browser), - initialized_theme_info_(false), - theme_area_height_(0) { + initialized_theme_info_(false) { profile_pref_registrar_.Init(profile()->GetPrefs()); profile_pref_registrar_.Add( GetInstantPrefName(profile()), @@ -208,15 +208,10 @@ void BrowserInstantController::TabDeactivated(content::WebContents* contents) { instant_.TabDeactivated(contents); } -void BrowserInstantController::SetContentHeight(int height) { - OnThemeAreaHeightChanged(height); -} - -void BrowserInstantController::UpdateThemeInfoForPreview() { - // Update theme background info and theme area height. - // Initialize |theme_info| if necessary. - // |OnThemeChanged| also updates theme area height if necessary. - if (!initialized_theme_info_) +void BrowserInstantController::UpdateThemeInfo(bool parse_theme_info) { + // Update theme background info. + // Initialize or re-parse |theme_info| if necessary. + if (!initialized_theme_info_ || parse_theme_info) OnThemeChanged(ThemeServiceFactory::GetForProfile(profile())); else OnThemeChanged(NULL); @@ -251,7 +246,7 @@ void BrowserInstantController::ModeChanged(const search::Mode& old_mode, const search::Mode& new_mode) { // If mode is now |NTP|, send theme-related information to instant. if (new_mode.is_ntp()) - UpdateThemeInfoForPreview(); + UpdateThemeInfo(false); instant_.SearchModeChanged(old_mode, new_mode); } @@ -301,12 +296,19 @@ void BrowserInstantController::OnThemeChanged(ThemeService* theme_service) { } // Set theme background image vertical alignment. - if (alignment & ThemeService::ALIGN_TOP) + if (alignment & ThemeService::ALIGN_TOP) { theme_info_.image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_TOP; - else if (alignment & ThemeService::ALIGN_BOTTOM) +#if !defined(OS_ANDROID) + // A detached bookmark bar will draw the top part of a top-aligned theme + // image as its background, so offset the image by the bar height. + if (browser_->bookmark_bar_state() == BookmarkBar::DETACHED) + theme_info_.image_top_offset = -chrome::kNTPBookmarkBarHeight; +#endif // !defined(OS_ANDROID) + } else if (alignment & ThemeService::ALIGN_BOTTOM) { theme_info_.image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_BOTTOM; - else // ALIGN_CENTER + } else { // ALIGN_CENTER theme_info_.image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_CENTER; + } // Set theme background image tiling. int tiling = 0; @@ -339,28 +341,8 @@ void BrowserInstantController::OnThemeChanged(ThemeService* theme_service) { DCHECK(initialized_theme_info_); - if (browser_->search_model()->mode().is_ntp()) { + if (browser_->search_model()->mode().is_ntp()) instant_.ThemeChanged(theme_info_); - - // Theme area height is only sent to preview for non-top-aligned images; - // new theme may have a different alignment that requires preview to know - // theme area height. - OnThemeAreaHeightChanged(theme_area_height_); - } -} - -void BrowserInstantController::OnThemeAreaHeightChanged(int height) { - theme_area_height_ = height; - - // Notify preview only if mode is |NTP| and theme background image is not top- - // aligned; top-aligned images don't need theme area height to determine which - // part of the image overlay should draw, 'cos the origin is top-left. - if (!browser_->search_model()->mode().is_ntp() || - theme_info_.theme_id.empty() || - theme_info_.image_vertical_alignment == THEME_BKGRND_IMAGE_ALIGN_TOP) { - return; - } - instant_.ThemeAreaHeightChanged(theme_area_height_); } } // namespace chrome diff --git a/chrome/browser/ui/browser_instant_controller.h b/chrome/browser/ui/browser_instant_controller.h index 8a96910..e8702ef 100644 --- a/chrome/browser/ui/browser_instant_controller.h +++ b/chrome/browser/ui/browser_instant_controller.h @@ -96,13 +96,9 @@ class BrowserInstantController : public content::NotificationObserver, // Invoked by |browser_| when the active tab is about to be deactivated. void TabDeactivated(content::WebContents* contents); - // Invoked by |BrowserWindow| during layout to set content height which is - // used as theme area height, i.e. the height of the area that the entire - // theme background image should fill up. - void SetContentHeight(int height); - - // Invoked by |instant_| to update theme information for preview. - void UpdateThemeInfoForPreview(); + // Invoked by |instant_| or |browser_| to update theme information for NTP. + // Set |parse_theme_info| to true to force re-parsing of theme information. + void UpdateThemeInfo(bool parse_theme_info); // Invoked by the InstantController when it wants to open a URL. void OpenURLInCurrentTab(const GURL& url, content::PageTransition transition); @@ -127,9 +123,6 @@ class BrowserInstantController : public content::NotificationObserver, // Helper for handling theme change. void OnThemeChanged(ThemeService* theme_service); - // Helper for handling theme area height change. - void OnThemeAreaHeightChanged(int height); - // Replaces the contents at tab |index| with |new_contents| and deletes the // existing contents. void ReplaceWebContentsAt(int index, @@ -143,7 +136,6 @@ class BrowserInstantController : public content::NotificationObserver, // Theme-related data for NTP preview to adopt themes. bool initialized_theme_info_; // True if theme_info_ has been initialized. ThemeBackgroundInfo theme_info_; - int theme_area_height_; PrefChangeRegistrar profile_pref_registrar_; diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 7fa4869..737268a 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -1806,18 +1806,10 @@ void BrowserView::Layout() { if (ignore_layout_) return; - int prev_content_height = contents_container_->height(); - views::View::Layout(); // The status bubble position requires that all other layout finish first. LayoutStatusBubble(); - - if (browser_->instant_controller() && - prev_content_height != contents_container_->height()) { - browser_->instant_controller()->SetContentHeight( - contents_container_->height()); - } } void BrowserView::PaintChildren(gfx::Canvas* canvas) { |