Home | History | Annotate | Download | only in common
      1 // Copyright (c) 2013 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 EXTENSIONS_COMMON_INSTALL_WARNING_H_
      6 #define EXTENSIONS_COMMON_INSTALL_WARNING_H_
      7 
      8 #include <ostream>
      9 #include <string>
     10 
     11 namespace extensions {
     12 
     13 // A struct to describe a non-fatal issue discovered in the installation of an
     14 // extension.
     15 struct InstallWarning {
     16   explicit InstallWarning(const std::string& message);
     17   InstallWarning(const std::string& message,
     18                  const std::string& key);
     19   InstallWarning(const std::string& message,
     20                  const std::string& key,
     21                  const std::string& specific);
     22   ~InstallWarning();
     23 
     24   bool operator==(const InstallWarning& other) const {
     25     // We don't have to look at |key| or |specific| here, because they are each
     26     // used in the the message itself.
     27     // For example, a full message would be "Permission 'foo' is unknown or URL
     28     // pattern is malformed." |key| here is "permissions", and |specific| is
     29     // "foo", but these are redundant with the message.
     30     return message == other.message;
     31   }
     32 
     33   // The warning's message (human-friendly).
     34   std::string message;
     35   // Optional - for specifying the incorrect key in the manifest (e.g.,
     36   // "permissions").
     37   std::string key;
     38   // Optional - for specifying the incorrect portion of a key in the manifest
     39   // (e.g., an unrecognized permission "foo" in "permissions").
     40   std::string specific;
     41 };
     42 
     43 // Let gtest print InstallWarnings.
     44 void PrintTo(const InstallWarning&, ::std::ostream* os);
     45 
     46 }  // namespace extensions
     47 
     48 #endif  // EXTENSIONS_COMMON_INSTALL_WARNING_H_
     49