Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: chrome/browser/infobars/infobar_container.h

Issue 12036075: alternate ntp: fix website page jankiness when suggestions show and top bars are hidden (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: changed mechanism to receive PreviewStateChanged Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/infobars/infobar_container.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_ 5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_
6 #define CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_ 6 #define CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "chrome/browser/instant/instant_model_observer.h"
12 #include "chrome/browser/ui/search/search_model_observer.h" 13 #include "chrome/browser/ui/search/search_model_observer.h"
13 #include "chrome/common/search_types.h" 14 #include "chrome/common/search_types.h"
14 #include "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 16 #include "content/public/browser/notification_registrar.h"
16 #include "third_party/skia/include/core/SkColor.h" 17 #include "third_party/skia/include/core/SkColor.h"
17 18
18 class InfoBar; 19 class InfoBar;
19 class InfoBarDelegate; 20 class InfoBarDelegate;
20 class InfoBarService; 21 class InfoBarService;
21 22
22 namespace chrome { 23 namespace chrome {
23 namespace search { 24 namespace search {
24 class SearchModel; 25 class SearchModel;
25 } 26 }
26 } 27 }
27 28
28 // InfoBarContainer is a cross-platform base class to handle the visibility- 29 // InfoBarContainer is a cross-platform base class to handle the visibility-
29 // related aspects of InfoBars. While InfoBars own themselves, the 30 // related aspects of InfoBars. While InfoBars own themselves, the
30 // InfoBarContainer is responsible for telling particular InfoBars that they 31 // InfoBarContainer is responsible for telling particular InfoBars that they
31 // should be hidden or visible. 32 // should be hidden or visible.
32 // 33 //
33 // Platforms need to subclass this to implement a few platform-specific 34 // Platforms need to subclass this to implement a few platform-specific
34 // functions, which are pure virtual here. 35 // functions, which are pure virtual here.
35 // 36 //
36 // This class also observes changes to the SearchModel mode. If the user changes 37 // This class also observes changes to the SearchModel modes. It hides infobars
37 // into suggestions mode, it hides all the infobars temporarily. When the user 38 // temporarily if the user changes into |SEARCH_SUGGESTIONS| mode (refer to
38 // changes back out of suggestions mode, it reshows any infobars, and starts a 39 // chrome::search::Mode in chrome/common/search_types.h for all search modes)
39 // 50 ms window during which any attempts to re-hide any infobars are handled 40 // when on a :
40 // without animation. This prevents glitchy-looking behavior when the user 41 // - |DEFAULT| page: when instant preview is ready;
41 // navigates following a mode change, which otherwise would re-show the infobars 42 // - |NTP| or |SEARCH_RESULTS| page: immediately;
42 // only to instantly animate them closed. The window is canceled if a tab 43 // TODO(kuan): this scenario requires more complex synchronization with
43 // change occurs. 44 // renderer SearchBoxAPI and will be implemented as the next step;
45 // for now, hiding is immediate.
46 // When the user changes back out of |SEARCH_SUGGESTIONS| mode, it reshows any
47 // infobars, and starts a 50 ms window during which any attempts to re-hide any
48 // infobars are handled without animation. This prevents glitchy-looking
49 // behavior when the user navigates following a mode change, which otherwise
50 // would re-show the infobars only to instantly animate them closed. The window
51 // to re-hide infobars without animation is canceled if a tab change occurs.
44 class InfoBarContainer : public content::NotificationObserver, 52 class InfoBarContainer : public content::NotificationObserver,
45 public chrome::search::SearchModelObserver { 53 public chrome::search::SearchModelObserver,
54 public InstantModelObserver {
46 public: 55 public:
47 class Delegate { 56 class Delegate {
48 public: 57 public:
49 // The separator color may vary depending on where the container is hosted. 58 // The separator color may vary depending on where the container is hosted.
50 virtual SkColor GetInfoBarSeparatorColor() const = 0; 59 virtual SkColor GetInfoBarSeparatorColor() const = 0;
51 60
52 // The delegate is notified each time the infobar container changes height, 61 // The delegate is notified each time the infobar container changes height,
53 // as well as when it stops animating. 62 // as well as when it stops animating.
54 virtual void InfoBarContainerStateChanged(bool is_animating) = 0; 63 virtual void InfoBarContainerStateChanged(bool is_animating) = 0;
55 64
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // anything necessary to respond, e.g. re-layout. 103 // anything necessary to respond, e.g. re-layout.
95 void OnInfoBarStateChanged(bool is_animating); 104 void OnInfoBarStateChanged(bool is_animating);
96 105
97 // Called by |infobar| to request that it be removed from the container, as it 106 // Called by |infobar| to request that it be removed from the container, as it
98 // is about to delete itself. At this point, |infobar| should already be 107 // is about to delete itself. At this point, |infobar| should already be
99 // hidden. 108 // hidden.
100 void RemoveInfoBar(InfoBar* infobar); 109 void RemoveInfoBar(InfoBar* infobar);
101 110
102 const Delegate* delegate() const { return delegate_; } 111 const Delegate* delegate() const { return delegate_; }
103 112
113 // InstantModelObserver:
114 virtual void PreviewStateChanged(const InstantModel& model) OVERRIDE;
115
104 protected: 116 protected:
105 // Subclasses must call this during destruction, so that we can remove 117 // Subclasses must call this during destruction, so that we can remove
106 // infobars (which will call the pure virtual functions below) while the 118 // infobars (which will call the pure virtual functions below) while the
107 // subclass portion of |this| has not yet been destroyed. 119 // subclass portion of |this| has not yet been destroyed.
108 void RemoveAllInfoBarsForDestruction(); 120 void RemoveAllInfoBarsForDestruction();
109 121
110 // These must be implemented on each platform to e.g. adjust the visible 122 // These must be implemented on each platform to e.g. adjust the visible
111 // object hierarchy. 123 // object hierarchy.
112 virtual void PlatformSpecificAddInfoBar(InfoBar* infobar, 124 virtual void PlatformSpecificAddInfoBar(InfoBar* infobar,
113 size_t position) = 0; 125 size_t position) = 0;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Extended. 177 // Extended.
166 chrome::search::SearchModel* search_model_; 178 chrome::search::SearchModel* search_model_;
167 179
168 // Calculated in SetMaxTopArrowHeight(). 180 // Calculated in SetMaxTopArrowHeight().
169 int top_arrow_target_height_; 181 int top_arrow_target_height_;
170 182
171 DISALLOW_COPY_AND_ASSIGN(InfoBarContainer); 183 DISALLOW_COPY_AND_ASSIGN(InfoBarContainer);
172 }; 184 };
173 185
174 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_ 186 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_CONTAINER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/infobars/infobar_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698