summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/ntp_background_util.h
diff options
context:
space:
mode:
authorkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-20 02:52:06 +0000
committerkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-20 02:52:06 +0000
commit1adefead3eb81b0fb5b3ca47a1e7ff3a1df8f352 (patch)
tree2c0aac4637d6a51e66f3548ede703b55b33b09f5 /chrome/browser/ui/ntp_background_util.h
parent8483e942d965822180f98f80790a328f586c58bd (diff)
downloadchromium_src-1adefead3eb81b0fb5b3ca47a1e7ff3a1df8f352.zip
chromium_src-1adefead3eb81b0fb5b3ca47a1e7ff3a1df8f352.tar.gz
chromium_src-1adefead3eb81b0fb5b3ca47a1e7ff3a1df8f352.tar.bz2
implement themes for instant extended api
feature description: - for non-top-aligned images in NTP, the NTP background theme image extends from top of tab to bottom of content view i.e. the theme image is displayed seamlessly across the active tab, toolbar, search provider logo, middle omnibox and bottom panel of thumbnails as a whole, changing in unison when browser window is resized - for top-aligned images in NTP, toolbar and tab use IDR_THEME_TOOLBAR like regular chrome, while the NTP background image extends from below toolbar border to bottom of content view across search provider logo, middle omnibox and bottom panel of thumbnails; during resizing, image doesn't change but gets clipped - for non-NTP pages, everything behaves like regular chrome high-level design: - for non-top-aligned images, toolbar, tabstrip and active tab, and top part of SearchNTPContainerView (i.e. search provider logo and middle omnibox) determine which parts of the image they should each display and paint them accordingly - when content view is laid out in SearchViewController and SearchNTPContainerView, a notification is fired if theme has just changed or the background-position in new_tab_theme.css needs to change because of changes in content view's y-pos or bounds. for top-aligned images, y-pos is a negative constant. for bottom-aligned images, y-pos is always 0. for center-aligned images, y-pos changes as browser window is resized. - NewTabUI observes this notification, and calls js to set backgroundPositionY. - NTPResourceCache observes this notification, resets the CSS storage, and stores the y-pos to be used in the re-generation of CSS string. - SearchViewController observes for theme change and forces SearchNTPContainerView to fire notification of y-pos even if it hasn't changed; this is necessary because the backgroundPositionY set in js takes precedence over that in css, so re-generated css from theme change won't take effect. - if theme is used, use white google logo for ntp. misc: - code move-around and restructuring - properly fix the white outline around omnibox border BUG=134937 TEST=verify per bug rpt Review URL: https://chromiumcodereview.appspot.com/11092061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163137 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/ntp_background_util.h')
-rw-r--r--chrome/browser/ui/ntp_background_util.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/chrome/browser/ui/ntp_background_util.h b/chrome/browser/ui/ntp_background_util.h
new file mode 100644
index 0000000..c04dc61
--- /dev/null
+++ b/chrome/browser/ui/ntp_background_util.h
@@ -0,0 +1,60 @@
+// 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_UI_NTP_BACKGROUND_UTIL_H_
+#define CHROME_BROWSER_UI_NTP_BACKGROUND_UTIL_H_
+
+namespace gfx {
+class Canvas;
+class Rect;
+class Size;
+}
+
+namespace ui {
+class ThemeProvider;
+}
+
+class Profile;
+
+class NtpBackgroundUtil {
+ public:
+ // Paints the NTP background on |canvas| where the theme image fills up
+ // |tab_contents_height|.
+ // - |area| is the area of the canvas that gets painted and also serves as the
+ // origin of the image (for top-aligned images).
+ // - |tab_contents_height| is necessary for correctly painting bottom-aligned
+ // images since then the origin is the bottom of the web page.
+ static void PaintBackgroundDetachedMode(Profile* profile,
+ gfx::Canvas* canvas,
+ const gfx::Rect& area,
+ int tab_contents_height);
+
+ // Paints the NTP background on |canvas| where the theme image fills up
+ // the entire browser client area from top of tab to bottom of browser client
+ // area.
+ // - |area_in_canvas| is the area of and relative to the canvas that gets
+ // painted.
+ // - |browser_client_area_size| is the size of browser client area where the
+ // entire image will be displayed
+ // - |area_in_browser_client_area| is |area_in_canvas| relative to browser
+ // client area of |browser_client_area_size|.
+ static void PaintBackgroundForBrowserClientArea(
+ Profile* profile,
+ gfx::Canvas* canvas,
+ const gfx::Rect& area_in_canvas,
+ const gfx::Size& browser_client_area_size,
+ const gfx::Rect& area_in_browser_client);
+
+ // Returns the x or y coordinate in |view_dimension| where a center-aligned
+ // image of |image_dimension| should be placed:
+ // - if dimension is width, x-pos is returned.
+ // - if dimension is height, y-pos is returned.
+ static int GetPlacementOfCenterAlignedImage(int view_dimension,
+ int image_dimension);
+
+ private:
+ NtpBackgroundUtil() {}
+};
+
+#endif // CHROME_BROWSER_UI_NTP_BACKGROUND_UTIL_H_