Chromium Code Reviews| 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. | |
|
sreeram
2012/09/25 22:22:29
instant -> Instant, here and elsewhere in this cha
| |
| 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 17 matching lines...) Expand all Loading... | |
| 100 // Returns true if the mouse or a touch pointer is down due to activating the | 108 // Returns true if the mouse or a touch pointer is down due to activating the |
| 101 // preview content. | 109 // preview content. |
| 102 bool IsPointerDownFromActivate() const; | 110 bool IsPointerDownFromActivate() const; |
| 103 | 111 |
| 104 // content::NotificationObserver: | 112 // content::NotificationObserver: |
| 105 virtual void Observe(int type, | 113 virtual void Observe(int type, |
| 106 const content::NotificationSource& source, | 114 const content::NotificationSource& source, |
| 107 const content::NotificationDetails& details) OVERRIDE; | 115 const content::NotificationDetails& details) OVERRIDE; |
| 108 | 116 |
| 109 private: | 117 private: |
| 118 static int kUserDataKey; | |
|
sreeram
2012/09/25 22:22:29
It seems like you can stash this in the .cc file (
jam
2012/09/25 22:42:39
Done.
| |
| 110 class WebContentsDelegateImpl; | 119 class WebContentsDelegateImpl; |
| 111 | 120 |
| 112 void SetupPreviewContents(); | 121 void SetupPreviewContents(); |
| 113 void CleanupPreviewContents(); | 122 void CleanupPreviewContents(); |
| 114 void ReplacePreviewContents(content::WebContents* old_contents, | 123 void ReplacePreviewContents(content::WebContents* old_contents, |
| 115 content::WebContents* new_contents); | 124 content::WebContents* new_contents); |
| 116 | 125 |
| 117 InstantLoaderDelegate* const loader_delegate_; | 126 InstantLoaderDelegate* const loader_delegate_; |
| 118 | 127 |
| 119 // See comments on the getter above. | 128 // See comments on the getter above. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 132 // Used to get notifications about renderers coming and going. | 141 // Used to get notifications about renderers coming and going. |
| 133 content::NotificationRegistrar registrar_; | 142 content::NotificationRegistrar registrar_; |
| 134 | 143 |
| 135 // See comments on the getter above. | 144 // See comments on the getter above. |
| 136 history::HistoryAddPageArgs last_navigation_; | 145 history::HistoryAddPageArgs last_navigation_; |
| 137 | 146 |
| 138 DISALLOW_COPY_AND_ASSIGN(InstantLoader); | 147 DISALLOW_COPY_AND_ASSIGN(InstantLoader); |
| 139 }; | 148 }; |
| 140 | 149 |
| 141 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ | 150 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
| OLD | NEW |