Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / android / meta_tag_observer.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_ANDROID_META_TAG_OBSERVER_H_
6 #define CHROME_BROWSER_ANDROID_META_TAG_OBSERVER_H_
7
8 #include "content/public/browser/web_contents_observer.h"
9
10 class GURL;
11
12 // Retrieves the content of a particular meta tag when a page has fully loaded.
13 // Subclasses must implement |HandleMetaTagContent|, which gets called after
14 // the DOM has been scanned for the tag.
15 class MetaTagObserver : public content::WebContentsObserver {
16  public:
17   explicit MetaTagObserver(const std::string& meta_tag);
18   virtual ~MetaTagObserver();
19
20   // content::WebContentsObserver overrides:
21   virtual void DidFinishLoad(
22       int64 frame_id,
23       const GURL& validated_url,
24       bool is_main_frame,
25       content::RenderViewHost* render_view_host) OVERRIDE;
26
27   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
28
29  protected:
30   // Called when the meta tag's content has been retrieved successfully.
31   virtual void HandleMetaTagContent(const std::string& tag_content,
32                                     const GURL& expected_url) = 0;
33
34  private:
35   // Called when the renderer has returned information about the meta tag.
36   void OnDidRetrieveMetaTagContent(bool success,
37                                    const std::string& tag_name,
38                                    const std::string& tag_content,
39                                    const GURL& expected_url);
40
41   const std::string meta_tag_;
42   GURL validated_url_;
43
44   DISALLOW_COPY_AND_ASSIGN(MetaTagObserver);
45 };
46
47 #endif  // CHROME_BROWSER_ANDROID_META_TAG_OBSERVER_H_