| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_INSTANT_INSTANT_LOADER_H_ | 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
| 6 #define CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ | 6 #define CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 bool is_pointer_down_from_activate() const { | 75 bool is_pointer_down_from_activate() const { |
| 76 return is_pointer_down_from_activate_; | 76 return is_pointer_down_from_activate_; |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Returns info about the last navigation by the Instant page. If the page | 79 // Returns info about the last navigation by the Instant page. If the page |
| 80 // hasn't navigated since the last Update(), the URL is empty. | 80 // hasn't navigated since the last Update(), the URL is empty. |
| 81 const history::HistoryAddPageArgs& last_navigation() const { | 81 const history::HistoryAddPageArgs& last_navigation() const { |
| 82 return last_navigation_; | 82 return last_navigation_; |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Tells the loader that it is in fallback mode. |
| 86 void set_is_in_fallback_mode(); |
| 87 bool is_in_fallback_mode() const { return is_in_fallback_mode_; } |
| 88 |
| 85 // Called by the history tab helper with information that it would have added | 89 // Called by the history tab helper with information that it would have added |
| 86 // to the history service had this WebContents not been used for Instant. | 90 // to the history service had this WebContents not been used for Instant. |
| 87 void DidNavigate(const history::HistoryAddPageArgs& add_page_args); | 91 void DidNavigate(const history::HistoryAddPageArgs& add_page_args); |
| 88 | 92 |
| 89 // Returns true if the loader is using | 93 // Returns true if the loader is using |
| 90 // InstantController::kLocalOmniboxPopupURL as the |instant_url_|. | 94 // InstantController::kLocalOmniboxPopupURL as the |instant_url_|. |
| 91 bool IsUsingLocalPreview() const; | 95 bool IsUsingLocalPreview() const; |
| 92 | 96 |
| 93 // Calls through to methods of the same name on InstantClient. | 97 // Calls through to methods of the same name on InstantClient. |
| 94 void Update(const string16& text, | 98 void Update(const string16& text, |
| 95 size_t selection_start, | 99 size_t selection_start, |
| 96 size_t selection_end, | 100 size_t selection_end, |
| 97 bool verbatim); | 101 bool verbatim); |
| 98 void Submit(const string16& text); | 102 void Submit(const string16& text); |
| 99 void Cancel(const string16& text); | 103 void Cancel(const string16& text); |
| 100 void SetPopupBounds(const gfx::Rect& bounds); | 104 void SetPopupBounds(const gfx::Rect& bounds); |
| 101 void SetMarginSize(int start, int end); | 105 void SetMarginSize(int start, int end); |
| 106 void InitializeFonts(); |
| 102 void SendAutocompleteResults( | 107 void SendAutocompleteResults( |
| 103 const std::vector<InstantAutocompleteResult>& results); | 108 const std::vector<InstantAutocompleteResult>& results); |
| 104 void UpOrDownKeyPressed(int count); | 109 void UpOrDownKeyPressed(int count); |
| 105 void SearchModeChanged(const chrome::search::Mode& mode); | 110 void SearchModeChanged(const chrome::search::Mode& mode); |
| 106 void SendThemeBackgroundInfo(const ThemeBackgroundInfo& theme_info); | 111 void SendThemeBackgroundInfo(const ThemeBackgroundInfo& theme_info); |
| 107 void SendThemeAreaHeight(int height); | 112 void SendThemeAreaHeight(int height); |
| 108 void SetDisplayInstantResults(bool display_instant_results); | 113 void SetDisplayInstantResults(bool display_instant_results); |
| 109 void KeyCaptureChanged(bool is_key_capture_enabled); | 114 void KeyCaptureChanged(bool is_key_capture_enabled); |
| 110 | 115 |
| 111 private: | 116 private: |
| 112 class WebContentsDelegateImpl; | 117 class WebContentsDelegateImpl; |
| 113 | 118 |
| 114 // Overridden from InstantClient::Delegate: | 119 // Overridden from InstantClient::Delegate: |
| 115 virtual void SetSuggestions( | 120 virtual void SetSuggestions( |
| 116 const std::vector<InstantSuggestion>& suggestions) OVERRIDE; | 121 const std::vector<InstantSuggestion>& suggestions) OVERRIDE; |
| 117 virtual void InstantSupportDetermined(bool supports_instant) OVERRIDE; | 122 virtual void InstantSupportDetermined(bool supports_instant) OVERRIDE; |
| 118 virtual void ShowInstantPreview(InstantShownReason reason, | 123 virtual void ShowInstantPreview(InstantShownReason reason, |
| 119 int height, | 124 int height, |
| 120 InstantSizeUnits units) OVERRIDE; | 125 InstantSizeUnits units) OVERRIDE; |
| 121 virtual void StartCapturingKeyStrokes() OVERRIDE; | 126 virtual void StartCapturingKeyStrokes() OVERRIDE; |
| 122 virtual void StopCapturingKeyStrokes() OVERRIDE; | 127 virtual void StopCapturingKeyStrokes() OVERRIDE; |
| 123 virtual void RenderViewGone() OVERRIDE; | 128 virtual void RenderViewGone() OVERRIDE; |
| 124 virtual void AboutToNavigateMainFrame(const GURL& url) OVERRIDE; | 129 virtual void AboutToNavigateMainFrame(const GURL& url) OVERRIDE; |
| 125 virtual void NavigateToURL(const GURL& url, | 130 virtual void NavigateToURL(const GURL& url, |
| 126 content::PageTransition transition) OVERRIDE; | 131 content::PageTransition transition) OVERRIDE; |
| 132 virtual void RenderViewCreated(content::RenderViewHost* host) OVERRIDE; |
| 127 | 133 |
| 128 // Overridden from content::NotificationObserver: | 134 // Overridden from content::NotificationObserver: |
| 129 virtual void Observe(int type, | 135 virtual void Observe(int type, |
| 130 const content::NotificationSource& source, | 136 const content::NotificationSource& source, |
| 131 const content::NotificationDetails& details) OVERRIDE; | 137 const content::NotificationDetails& details) OVERRIDE; |
| 132 | 138 |
| 133 void SetupPreviewContents(); | 139 void SetupPreviewContents(); |
| 134 void CleanupPreviewContents(); | 140 void CleanupPreviewContents(); |
| 135 void ReplacePreviewContents(content::WebContents* old_contents, | 141 void ReplacePreviewContents(content::WebContents* old_contents, |
| 136 content::WebContents* new_contents); | 142 content::WebContents* new_contents); |
| 137 | 143 |
| 138 InstantClient client_; | 144 InstantClient client_; |
| 139 InstantController* const controller_; | 145 InstantController* const controller_; |
| 140 | 146 |
| 141 // Delegate of the preview WebContents. Used when the user does some gesture | 147 // Delegate of the preview WebContents. Used when the user does some gesture |
| 142 // on the preview and it needs to be activated. | 148 // on the preview and it needs to be activated. |
| 143 scoped_ptr<WebContentsDelegateImpl> delegate_; | 149 scoped_ptr<WebContentsDelegateImpl> delegate_; |
| 144 scoped_ptr<content::WebContents> contents_; | 150 scoped_ptr<content::WebContents> contents_; |
| 145 | 151 |
| 146 const std::string instant_url_; | 152 const std::string instant_url_; |
| 147 bool supports_instant_; | 153 bool supports_instant_; |
| 148 bool is_pointer_down_from_activate_; | 154 bool is_pointer_down_from_activate_; |
| 149 history::HistoryAddPageArgs last_navigation_; | 155 history::HistoryAddPageArgs last_navigation_; |
| 150 | 156 |
| 157 // Indicates if this loader is running as a fallback loader using the local |
| 158 // preview because the actual instant page was too slow to load. |
| 159 bool is_in_fallback_mode_; |
| 160 |
| 151 // Used to get notifications about renderers coming and going. | 161 // Used to get notifications about renderers coming and going. |
| 152 content::NotificationRegistrar registrar_; | 162 content::NotificationRegistrar registrar_; |
| 153 | 163 |
| 154 DISALLOW_COPY_AND_ASSIGN(InstantLoader); | 164 DISALLOW_COPY_AND_ASSIGN(InstantLoader); |
| 155 }; | 165 }; |
| 156 | 166 |
| 157 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ | 167 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
| OLD | NEW |