| 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_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 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 class Rect; | 31 class Rect; |
| 32 } | 32 } |
| 33 | 33 |
| 34 // InstantLoader is created with an "Instant URL". It loads the URL and tells | 34 // InstantLoader is created with an "Instant URL". It loads the URL and tells |
| 35 // its delegate (usually InstantController) of all interesting events. For | 35 // its delegate (usually InstantController) of all interesting events. For |
| 36 // example, it determines if the page actually supports the Instant API | 36 // example, it determines if the page actually supports the Instant API |
| 37 // (http://dev.chromium.org/searchbox) and forwards messages (such as queries | 37 // (http://dev.chromium.org/searchbox) and forwards messages (such as queries |
| 38 // and autocomplete suggestions) between the page and the delegate. | 38 // and autocomplete suggestions) between the page and the delegate. |
| 39 class InstantLoader : public content::NotificationObserver { | 39 class InstantLoader : public content::NotificationObserver { |
| 40 public: | 40 public: |
| 41 // Returns the Instant loader for |web_contents| if it's used for Instant. |
| 42 static InstantLoader* FromWebContents(content::WebContents* web_contents); |
| 43 |
| 41 // Creates a new empty WebContents. Use Init() to actually load |instant_url|. | 44 // Creates a new empty WebContents. Use Init() to actually load |instant_url|. |
| 42 // |tab_contents| is the page the preview will be shown on top of and | 45 // |tab_contents| is the page the preview will be shown on top of and |
| 43 // potentially replace. |instant_url| is typically the instant_url field of | 46 // potentially replace. |instant_url| is typically the instant_url field of |
| 44 // the default search engine's TemplateURL, with the "{searchTerms}" parameter | 47 // the default search engine's TemplateURL, with the "{searchTerms}" parameter |
| 45 // replaced with an empty string. | 48 // replaced with an empty string. |
| 46 InstantLoader(InstantLoaderDelegate* delegate, | 49 InstantLoader(InstantLoaderDelegate* delegate, |
| 47 const std::string& instant_url, | 50 const std::string& instant_url, |
| 48 const TabContents* tab_contents); | 51 const TabContents* tab_contents); |
| 49 virtual ~InstantLoader(); | 52 virtual ~InstantLoader(); |
| 50 | 53 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 63 void SetOmniboxBounds(const gfx::Rect& bounds); | 66 void SetOmniboxBounds(const gfx::Rect& bounds); |
| 64 | 67 |
| 65 // Tells the preview page about the available autocomplete results. | 68 // Tells the preview page about the available autocomplete results. |
| 66 void SendAutocompleteResults( | 69 void SendAutocompleteResults( |
| 67 const std::vector<InstantAutocompleteResult>& results); | 70 const std::vector<InstantAutocompleteResult>& results); |
| 68 | 71 |
| 69 // Tells the preview page that the user pressed the up or down key. |count| | 72 // Tells the preview page that the user pressed the up or down key. |count| |
| 70 // is a repeat count, negative for moving up, positive for moving down. | 73 // is a repeat count, negative for moving up, positive for moving down. |
| 71 void OnUpOrDownKeyPressed(int count); | 74 void OnUpOrDownKeyPressed(int count); |
| 72 | 75 |
| 76 // Called by the history tab helper with the information that it would have |
| 77 // added to the history service had this web contents not been used for |
| 78 // Instant. |
| 79 void DidNavigate(const history::HistoryAddPageArgs& add_page_args); |
| 80 |
| 73 // Releases the preview TabContents passing ownership to the caller. This | 81 // Releases the preview TabContents passing ownership to the caller. This |
| 74 // should be called when the preview is committed. Notifies the page but not | 82 // should be called when the preview is committed. Notifies the page but not |
| 75 // the delegate. |text| is the final omnibox text being committed. NOTE: The | 83 // the delegate. |text| is the final omnibox text being committed. NOTE: The |
| 76 // caller should destroy this loader object right after this method, since | 84 // caller should destroy this loader object right after this method, since |
| 77 // none of the other methods will work once the preview has been released. | 85 // none of the other methods will work once the preview has been released. |
| 78 TabContents* ReleasePreviewContents(InstantCommitType type, | 86 TabContents* ReleasePreviewContents(InstantCommitType type, |
| 79 const string16& text) WARN_UNUSED_RESULT; | 87 const string16& text) WARN_UNUSED_RESULT; |
| 80 | 88 |
| 81 // The preview TabContents. The loader retains ownership. This will be | 89 // The preview TabContents. The loader retains ownership. This will be |
| 82 // non-NULL until ReleasePreviewContents() is called. | 90 // non-NULL until ReleasePreviewContents() is called. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // Used to get notifications about renderers coming and going. | 140 // Used to get notifications about renderers coming and going. |
| 133 content::NotificationRegistrar registrar_; | 141 content::NotificationRegistrar registrar_; |
| 134 | 142 |
| 135 // See comments on the getter above. | 143 // See comments on the getter above. |
| 136 history::HistoryAddPageArgs last_navigation_; | 144 history::HistoryAddPageArgs last_navigation_; |
| 137 | 145 |
| 138 DISALLOW_COPY_AND_ASSIGN(InstantLoader); | 146 DISALLOW_COPY_AND_ASSIGN(InstantLoader); |
| 139 }; | 147 }; |
| 140 | 148 |
| 141 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ | 149 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
| OLD | NEW |