Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / ui / toolbar / origin_chip_info.h
blob92179242a11f2283dc99fbb73b0fe8b02c07b7dc
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.
5 #ifndef CHROME_BROWSER_UI_TOOLBAR_ORIGIN_CHIP_INFO_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_ORIGIN_CHIP_INFO_H_
8 #include "base/strings/string16.h"
9 #include "chrome/browser/extensions/extension_icon_image.h"
10 #include "chrome/browser/ui/toolbar/toolbar_model.h"
12 class GURL;
13 class Profile;
15 namespace content {
16 class WebContents;
19 // This class manages the information to be displayed by the origin chip.
20 class OriginChipInfo {
21 public:
22 // The |owner| owns this OriginChipInfo and must outlive it. If the current
23 // origin is an extension, the |owner|'s OnExtensionIconImageChanged()
24 // method will be called whenever the icon changes.
25 OriginChipInfo(extensions::IconImage::Observer* owner, Profile* profile);
26 ~OriginChipInfo();
28 // Updates the current state. Returns whether the displayable information has
29 // changed.
30 bool Update(const content::WebContents* web_contents,
31 const ToolbarModel* toolbar_model);
33 // Returns the label to be displayed by the origin chip.
34 const base::string16& label() const { return label_; }
36 // Returns the ID of the icon to be displayed by the origin chip. Note that
37 // if |owner_|'s OnExtensionIconImageChanged() method was called with
38 // anything else than NULL, that icon has precedence over whatever this method
39 // returns.
40 int icon() const { return icon_; }
42 // Returns the full URL.
43 const GURL& displayed_url() const { return displayed_url_; }
45 // Returns the security level of the current URL.
46 ToolbarModel::SecurityLevel security_level() const { return security_level_; }
48 // Returns whether the current URL is known to be malware or not.
49 bool is_url_malware() const { return is_url_malware_; }
51 private:
52 // The observer which will receive OnExtensionIconImageChanged() calls.
53 extensions::IconImage::Observer* owner_;
55 Profile* profile_;
57 // State used to determine whether the |label_| and |icon_| need to be
58 // recomputed.
59 GURL displayed_url_;
60 ToolbarModel::SecurityLevel security_level_;
61 bool is_url_malware_;
63 // The label and icon to be displayed by the origin chip.
64 base::string16 label_;
65 int icon_;
67 // extensions::IconImage instance, used for observing changes in an
68 // extension's icon, when the current page belongs to an extension.
69 scoped_ptr<extensions::IconImage> extension_icon_image_;
71 DISALLOW_COPY_AND_ASSIGN(OriginChipInfo);
74 // This class is left here to prevent breaking the views code. It will be
75 // removed soon, and the functions will become local to origin_chip.cc.
76 class OriginChip {
77 public:
78 // Detects client-side or SB malware/phishing hits. Used to decide whether the
79 // origin chip should indicate that the current page has malware or is a known
80 // phishing page.
81 static bool IsMalware(const GURL& url, const content::WebContents* tab);
83 // Gets the label to display on the Origin Chip for the specified URL. The
84 // |profile| is needed in case the URL is from an extension.
85 static base::string16 LabelFromURLForProfile(const GURL& provided_url,
86 Profile* profile);
89 #endif // CHROME_BROWSER_UI_TOOLBAR_ORIGIN_CHIP_INFO_H_