| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_ANDROID_META_TAG_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_META_TAG_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_META_TAG_OBSERVER_H_ | 6 #define CHROME_BROWSER_ANDROID_META_TAG_OBSERVER_H_ |
| 7 | 7 |
| 8 #include "content/public/browser/web_contents_observer.h" | 8 #include "content/public/browser/web_contents_observer.h" |
| 9 | 9 |
| 10 class GURL; | 10 class GURL; |
| 11 | 11 |
| 12 // Retrieves the content of a particular meta tag when a page has fully loaded. | 12 // Retrieves the content of a particular meta tag when a page has fully loaded. |
| 13 // Subclasses must implement |HandleMetaTagContent|, which gets called after | 13 // Subclasses must implement |HandleMetaTagContent|, which gets called after |
| 14 // the DOM has been scanned for the tag. | 14 // the DOM has been scanned for the tag. |
| 15 class MetaTagObserver : public content::WebContentsObserver { | 15 class MetaTagObserver : public content::WebContentsObserver { |
| 16 public: | 16 public: |
| 17 explicit MetaTagObserver(const std::string& meta_tag); | 17 explicit MetaTagObserver(const std::string& meta_tag); |
| 18 virtual ~MetaTagObserver(); | 18 virtual ~MetaTagObserver(); |
| 19 | 19 |
| 20 // content::WebContentsObserver overrides: | 20 // content::WebContentsObserver overrides: |
| 21 virtual void DidFinishLoad(content::RenderFrameHost* render_frame_host, | 21 virtual void DidFinishLoad(content::RenderFrameHost* render_frame_host, |
| 22 const GURL& validated_url) OVERRIDE; | 22 const GURL& validated_url) override; |
| 23 | 23 |
| 24 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 24 virtual bool OnMessageReceived(const IPC::Message& message) override; |
| 25 | 25 |
| 26 protected: | 26 protected: |
| 27 // Called when the meta tag's content has been retrieved successfully. | 27 // Called when the meta tag's content has been retrieved successfully. |
| 28 virtual void HandleMetaTagContent(const std::string& tag_content, | 28 virtual void HandleMetaTagContent(const std::string& tag_content, |
| 29 const GURL& expected_url) = 0; | 29 const GURL& expected_url) = 0; |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 // Called when the renderer has returned information about the meta tag. | 32 // Called when the renderer has returned information about the meta tag. |
| 33 void OnDidRetrieveMetaTagContent(bool success, | 33 void OnDidRetrieveMetaTagContent(bool success, |
| 34 const std::string& tag_name, | 34 const std::string& tag_name, |
| 35 const std::string& tag_content, | 35 const std::string& tag_content, |
| 36 const GURL& expected_url); | 36 const GURL& expected_url); |
| 37 | 37 |
| 38 const std::string meta_tag_; | 38 const std::string meta_tag_; |
| 39 GURL validated_url_; | 39 GURL validated_url_; |
| 40 | 40 |
| 41 DISALLOW_COPY_AND_ASSIGN(MetaTagObserver); | 41 DISALLOW_COPY_AND_ASSIGN(MetaTagObserver); |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 #endif // CHROME_BROWSER_ANDROID_META_TAG_OBSERVER_H_ | 44 #endif // CHROME_BROWSER_ANDROID_META_TAG_OBSERVER_H_ |
| OLD | NEW |