Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / extension_install_prompt.cc
index 6e94baa..983b3bb 100644 (file)
@@ -198,7 +198,8 @@ ExtensionInstallPrompt::Prompt::Prompt(PromptType type)
       bundle_(NULL),
       average_rating_(0.0),
       rating_count_(0),
-      show_user_count_(false) {
+      show_user_count_(false),
+      has_webstore_data_(false) {
 }
 
 ExtensionInstallPrompt::Prompt::~Prompt() {
@@ -253,16 +254,17 @@ void ExtensionInstallPrompt::Prompt::SetUserNameFromProfile(Profile* profile) {
   }
 }
 
-void ExtensionInstallPrompt::Prompt::SetInlineInstallWebstoreData(
+void ExtensionInstallPrompt::Prompt::SetWebstoreData(
     const std::string& localized_user_count,
     bool show_user_count,
     double average_rating,
     int rating_count) {
-  CHECK_EQ(INLINE_INSTALL_PROMPT, type_);
+  CHECK(type_ == INLINE_INSTALL_PROMPT || type_ == EXTERNAL_INSTALL_PROMPT);
   localized_user_count_ = localized_user_count;
   show_user_count_ = show_user_count;
   average_rating_ = average_rating;
   rating_count_ = rating_count;
+  has_webstore_data_ = true;
 }
 
 base::string16 ExtensionInstallPrompt::Prompt::GetDialogTitle() const {
@@ -387,7 +389,7 @@ bool ExtensionInstallPrompt::Prompt::ShouldShowPermissions() const {
 void ExtensionInstallPrompt::Prompt::AppendRatingStars(
     StarAppender appender, void* data) const {
   CHECK(appender);
-  CHECK_EQ(INLINE_INSTALL_PROMPT, type_);
+  CHECK(type_ == INLINE_INSTALL_PROMPT || type_ == EXTERNAL_INSTALL_PROMPT);
   int rating_integer = floor(average_rating_);
   double rating_fractional = average_rating_ - rating_integer;
 
@@ -414,13 +416,13 @@ void ExtensionInstallPrompt::Prompt::AppendRatingStars(
 }
 
 base::string16 ExtensionInstallPrompt::Prompt::GetRatingCount() const {
-  CHECK_EQ(INLINE_INSTALL_PROMPT, type_);
+  CHECK(type_ == INLINE_INSTALL_PROMPT || type_ == EXTERNAL_INSTALL_PROMPT);
   return l10n_util::GetStringFUTF16(IDS_EXTENSION_RATING_COUNT,
                                     base::IntToString16(rating_count_));
 }
 
 base::string16 ExtensionInstallPrompt::Prompt::GetUserCount() const {
-  CHECK_EQ(INLINE_INSTALL_PROMPT, type_);
+  CHECK(type_ == INLINE_INSTALL_PROMPT || type_ == EXTERNAL_INSTALL_PROMPT);
 
   if (show_user_count_) {
     return l10n_util::GetStringFUTF16(IDS_EXTENSION_USER_COUNT,
@@ -533,12 +535,12 @@ scoped_refptr<Extension>
       error);
 }
 
-ExtensionInstallPrompt::ExtensionInstallPrompt(
-    content::WebContents* contents)
+ExtensionInstallPrompt::ExtensionInstallPrompt(content::WebContents* contents)
     : OAuth2TokenService::Consumer("extensions_install"),
       record_oauth2_grant_(false),
       ui_loop_(base::MessageLoop::current()),
       extension_(NULL),
+      bundle_(NULL),
       install_ui_(ExtensionInstallUI::Create(ProfileForWebContents(contents))),
       show_params_(contents),
       delegate_(NULL),
@@ -554,6 +556,7 @@ ExtensionInstallPrompt::ExtensionInstallPrompt(
       record_oauth2_grant_(false),
       ui_loop_(base::MessageLoop::current()),
       extension_(NULL),
+      bundle_(NULL),
       install_ui_(ExtensionInstallUI::Create(profile)),
       show_params_(native_window, navigator),
       delegate_(NULL),
@@ -647,12 +650,13 @@ void ExtensionInstallPrompt::ConfirmReEnable(Delegate* delegate,
 void ExtensionInstallPrompt::ConfirmExternalInstall(
     Delegate* delegate,
     const Extension* extension,
-    const ShowDialogCallback& show_dialog_callback) {
+    const ShowDialogCallback& show_dialog_callback,
+    const Prompt& prompt) {
   DCHECK(ui_loop_ == base::MessageLoop::current());
   extension_ = extension;
   permissions_ = extension->GetActivePermissions();
   delegate_ = delegate;
-  prompt_.set_type(EXTERNAL_INSTALL_PROMPT);
+  prompt_ = prompt;
   show_dialog_callback_ = show_dialog_callback;
 
   LoadImageIfNeeded();