| 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" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "chrome/browser/history/history_types.h" |
| 15 #include "chrome/browser/instant/instant_commit_type.h" | 16 #include "chrome/browser/instant/instant_commit_type.h" |
| 16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 18 | 19 |
| 19 struct InstantAutocompleteResult; | 20 struct InstantAutocompleteResult; |
| 20 class InstantLoaderDelegate; | 21 class InstantLoaderDelegate; |
| 21 class TabContents; | 22 class TabContents; |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| 24 class NotificationDetails; | 25 class NotificationDetails; |
| 25 class NotificationSource; | 26 class NotificationSource; |
| 26 class WebContents; | 27 class WebContents; |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace gfx { | 30 namespace gfx { |
| 30 class Rect; | 31 class Rect; |
| 31 } | 32 } |
| 32 | 33 |
| 33 namespace history { | |
| 34 class HistoryAddPageArgs; | |
| 35 } | |
| 36 | |
| 37 // 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 |
| 38 // its delegate (usually InstantController) of all interesting events. For | 35 // its delegate (usually InstantController) of all interesting events. For |
| 39 // example, it determines if the page actually supports the Instant API | 36 // example, it determines if the page actually supports the Instant API |
| 40 // (http://dev.chromium.org/searchbox) and forwards messages (such as queries | 37 // (http://dev.chromium.org/searchbox) and forwards messages (such as queries |
| 41 // and autocomplete suggestions) between the page and the delegate. | 38 // and autocomplete suggestions) between the page and the delegate. |
| 42 class InstantLoader : public content::NotificationObserver { | 39 class InstantLoader : public content::NotificationObserver { |
| 43 public: | 40 public: |
| 44 // Creates a new empty WebContents. Use Init() to actually load |instant_url|. | 41 // Creates a new empty WebContents. Use Init() to actually load |instant_url|. |
| 45 // |tab_contents| is the page the preview will be shown on top of and | 42 // |tab_contents| is the page the preview will be shown on top of and |
| 46 // potentially replace. |instant_url| is typically the instant_url field of | 43 // potentially replace. |instant_url| is typically the instant_url field of |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // Returns true if the preview page is known to support the Instant API. This | 85 // Returns true if the preview page is known to support the Instant API. This |
| 89 // starts out false, and becomes true whenever we get any message from the | 86 // starts out false, and becomes true whenever we get any message from the |
| 90 // page. Once true, it never becomes false (the page isn't expected to drop | 87 // page. Once true, it never becomes false (the page isn't expected to drop |
| 91 // Instant API support suddenly). | 88 // Instant API support suddenly). |
| 92 bool supports_instant() const { return supports_instant_; } | 89 bool supports_instant() const { return supports_instant_; } |
| 93 | 90 |
| 94 // Returns the URL that we're loading. | 91 // Returns the URL that we're loading. |
| 95 const std::string& instant_url() const { return instant_url_; } | 92 const std::string& instant_url() const { return instant_url_; } |
| 96 | 93 |
| 97 // Returns info about the last navigation by the Instant page. If the page | 94 // Returns info about the last navigation by the Instant page. If the page |
| 98 // hasn't navigated since the last Update(), this contains NULL. | 95 // hasn't navigated since the last Update(), the URL is empty. |
| 99 scoped_refptr<history::HistoryAddPageArgs> last_navigation() const { | 96 const history::HistoryAddPageArgs& last_navigation() const { |
| 100 return last_navigation_; | 97 return last_navigation_; |
| 101 } | 98 } |
| 102 | 99 |
| 103 // Returns true if the mouse or a touch pointer is down due to activating the | 100 // Returns true if the mouse or a touch pointer is down due to activating the |
| 104 // preview content. | 101 // preview content. |
| 105 bool IsPointerDownFromActivate() const; | 102 bool IsPointerDownFromActivate() const; |
| 106 | 103 |
| 107 // content::NotificationObserver: | 104 // content::NotificationObserver: |
| 108 virtual void Observe(int type, | 105 virtual void Observe(int type, |
| 109 const content::NotificationSource& source, | 106 const content::NotificationSource& source, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 129 // See comments on the getter above. | 126 // See comments on the getter above. |
| 130 bool supports_instant_; | 127 bool supports_instant_; |
| 131 | 128 |
| 132 // See comments on the getter above. | 129 // See comments on the getter above. |
| 133 const std::string instant_url_; | 130 const std::string instant_url_; |
| 134 | 131 |
| 135 // Used to get notifications about renderers coming and going. | 132 // Used to get notifications about renderers coming and going. |
| 136 content::NotificationRegistrar registrar_; | 133 content::NotificationRegistrar registrar_; |
| 137 | 134 |
| 138 // See comments on the getter above. | 135 // See comments on the getter above. |
| 139 scoped_refptr<history::HistoryAddPageArgs> last_navigation_; | 136 history::HistoryAddPageArgs last_navigation_; |
| 140 | 137 |
| 141 DISALLOW_COPY_AND_ASSIGN(InstantLoader); | 138 DISALLOW_COPY_AND_ASSIGN(InstantLoader); |
| 142 }; | 139 }; |
| 143 | 140 |
| 144 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ | 141 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
| OLD | NEW |