| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_BROWSER_INSTANT_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/prefs/public/pref_change_registrar.h" | 11 #include "base/prefs/public/pref_change_registrar.h" |
| 12 #include "base/prefs/public/pref_observer.h" | 12 #include "base/prefs/public/pref_observer.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "chrome/browser/instant/instant_unload_handler.h" | 14 #include "chrome/browser/instant/instant_unload_handler.h" |
| 15 #include "chrome/browser/ui/search/search_model_observer.h" | 15 #include "chrome/browser/ui/search/search_model_observer.h" |
| 16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 17 #include "chrome/common/instant_types.h" | 17 #include "chrome/common/instant_types.h" |
| 18 #include "webkit/glue/window_open_disposition.h" | 18 #include "webkit/glue/window_open_disposition.h" |
| 19 #include "content/public/browser/notification_observer.h" |
| 20 #include "content/public/browser/notification_registrar.h" |
| 19 | 21 |
| 20 class Browser; | 22 class Browser; |
| 21 class InstantController; | 23 class InstantController; |
| 22 class InstantTest; | 24 class InstantTest; |
| 23 class TabContents; | 25 class TabContents; |
| 24 | 26 |
| 25 namespace gfx { | 27 namespace gfx { |
| 26 class Rect; | 28 class Rect; |
| 27 } | 29 } |
| 28 | 30 |
| 31 namespace ui { |
| 32 class ThemeProvider; |
| 33 }; |
| 34 |
| 29 namespace chrome { | 35 namespace chrome { |
| 30 | 36 |
| 31 class BrowserInstantController : public TabStripModelObserver, | 37 class BrowserInstantController : public TabStripModelObserver, |
| 32 public search::SearchModelObserver, | 38 public search::SearchModelObserver, |
| 33 public PrefObserver { | 39 public PrefObserver, |
| 40 public content::NotificationObserver { |
| 34 public: | 41 public: |
| 35 explicit BrowserInstantController(Browser* browser); | 42 explicit BrowserInstantController(Browser* browser); |
| 36 virtual ~BrowserInstantController(); | 43 virtual ~BrowserInstantController(); |
| 37 | 44 |
| 38 // Commits the current Instant, returning true on success. This is intended | 45 // Commits the current Instant, returning true on success. This is intended |
| 39 // for use from OpenCurrentURL. | 46 // for use from OpenCurrentURL. |
| 40 bool OpenInstant(WindowOpenDisposition disposition); | 47 bool OpenInstant(WindowOpenDisposition disposition); |
| 41 | 48 |
| 42 // Returns the InstantController or NULL if there is no InstantController for | 49 // Returns the InstantController or NULL if there is no InstantController for |
| 43 // this BrowserInstantController. | 50 // this BrowserInstantController. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 55 gfx::Rect GetInstantBounds(); | 62 gfx::Rect GetInstantBounds(); |
| 56 | 63 |
| 57 // Invoked by |instant_| to notify that the preview gained focus, usually due | 64 // Invoked by |instant_| to notify that the preview gained focus, usually due |
| 58 // to the user clicking on it. | 65 // to the user clicking on it. |
| 59 void InstantPreviewFocused(); | 66 void InstantPreviewFocused(); |
| 60 | 67 |
| 61 // Invoked by |instant_| to get the currently active tab, over which the | 68 // Invoked by |instant_| to get the currently active tab, over which the |
| 62 // preview would be shown. | 69 // preview would be shown. |
| 63 TabContents* GetActiveTabContents() const; | 70 TabContents* GetActiveTabContents() const; |
| 64 | 71 |
| 72 // Invoked by |BrowserWindow| during layout to set content height which is |
| 73 // used as theme area height, i.e. the height of the area that the entire |
| 74 // theme background image should fill up. |
| 75 void SetContentHeight(int height); |
| 76 |
| 77 // Invoked by |instant_| to update theme-related information in preview. |
| 78 void UpdateThemeRelatedInfoForPreview(); |
| 79 |
| 65 // Overridden from PrefObserver: | 80 // Overridden from PrefObserver: |
| 66 virtual void OnPreferenceChanged(PrefServiceBase* service, | 81 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 67 const std::string& pref_name) OVERRIDE; | 82 const std::string& pref_name) OVERRIDE; |
| 68 | 83 |
| 69 // Overridden from TabStripModelObserver: | 84 // Overridden from TabStripModelObserver: |
| 70 virtual void ActiveTabChanged(content::WebContents* old_contents, | 85 virtual void ActiveTabChanged(content::WebContents* old_contents, |
| 71 content::WebContents* new_contents, | 86 content::WebContents* new_contents, |
| 72 int index, | 87 int index, |
| 73 bool user_gesture) OVERRIDE; | 88 bool user_gesture) OVERRIDE; |
| 74 | 89 |
| 75 // Overridden from search::SearchModelObserver: | 90 // Overridden from search::SearchModelObserver: |
| 76 virtual void ModeChanged(const search::Mode& old_mode, | 91 virtual void ModeChanged(const search::Mode& old_mode, |
| 77 const search::Mode& new_mode) OVERRIDE; | 92 const search::Mode& new_mode) OVERRIDE; |
| 78 | 93 |
| 94 private: |
| 95 // content::NotificationObserver implementation. |
| 96 virtual void Observe(int type, |
| 97 const content::NotificationSource& source, |
| 98 const content::NotificationDetails& details) OVERRIDE; |
| 99 |
| 79 // If this browser should have Instant, a new InstantController created; | 100 // If this browser should have Instant, a new InstantController created; |
| 80 // otherwise any existing InstantController is destroyed. | 101 // otherwise any existing InstantController is destroyed. |
| 81 void ResetInstant(); | 102 void ResetInstant(); |
| 82 | 103 |
| 104 // Helper for handling theme change. |
| 105 void OnThemeChanged(ui::ThemeProvider* theme_provider); |
| 106 |
| 107 // Helper for handling theme area height change. |
| 108 void OnThemeAreaHeightChanged(int height); |
| 109 |
| 83 Browser* browser_; | 110 Browser* browser_; |
| 84 | 111 |
| 85 scoped_ptr<InstantController> instant_; | 112 scoped_ptr<InstantController> instant_; |
| 86 InstantUnloadHandler instant_unload_handler_; | 113 InstantUnloadHandler instant_unload_handler_; |
| 87 | 114 |
| 115 // Theme-related data for NTP preview to adopt themes. |
| 116 ThemeBackgroundInfo theme_info_; |
| 117 int theme_image_alignment_; |
| 118 int theme_area_height_; |
| 119 |
| 88 PrefChangeRegistrar profile_pref_registrar_; | 120 PrefChangeRegistrar profile_pref_registrar_; |
| 89 | 121 |
| 122 content::NotificationRegistrar registrar_; |
| 123 |
| 90 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); | 124 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); |
| 91 }; | 125 }; |
| 92 | 126 |
| 93 } // namespace chrome | 127 } // namespace chrome |
| 94 | 128 |
| 95 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ | 129 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ |
| OLD | NEW |