Home | History | Annotate | Download | only in extensions
      1 // Copyright (c) 2012 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 #include "chrome/browser/extensions/webstore_startup_installer.h"
      6 
      7 #include "chrome/browser/profiles/profile.h"
      8 #include "content/public/browser/web_contents.h"
      9 
     10 using content::WebContents;
     11 
     12 namespace extensions {
     13 
     14 WebstoreStartupInstaller::WebstoreStartupInstaller(
     15     const std::string& webstore_item_id,
     16     Profile* profile,
     17     bool show_prompt,
     18     const Callback& callback)
     19     : WebstoreStandaloneInstaller(
     20           webstore_item_id,
     21           profile,
     22           callback),
     23       show_prompt_(show_prompt),
     24       dummy_web_contents_(
     25           WebContents::Create(WebContents::CreateParams(profile))) {
     26 }
     27 
     28 WebstoreStartupInstaller::~WebstoreStartupInstaller() {}
     29 
     30 bool WebstoreStartupInstaller::CheckRequestorAlive() const {
     31   // Requestor is the command line, so it's always alive.
     32   return true;
     33 }
     34 
     35 const GURL& WebstoreStartupInstaller::GetRequestorURL() const {
     36   return dummy_requestor_url_;
     37 }
     38 
     39 scoped_ptr<ExtensionInstallPrompt::Prompt>
     40 WebstoreStartupInstaller::CreateInstallPrompt() const {
     41   scoped_ptr<ExtensionInstallPrompt::Prompt> prompt;
     42   if (show_prompt_)
     43     prompt.reset(new ExtensionInstallPrompt::Prompt(
     44         ExtensionInstallPrompt::INSTALL_PROMPT));
     45   return prompt.Pass();
     46 }
     47 
     48 bool WebstoreStartupInstaller::ShouldShowPostInstallUI() const {
     49   return false;
     50 }
     51 
     52 bool WebstoreStartupInstaller::ShouldShowAppInstalledBubble() const {
     53   return false;
     54 }
     55 
     56 WebContents* WebstoreStartupInstaller::GetWebContents() const {
     57   return dummy_web_contents_.get();
     58 }
     59 
     60 bool WebstoreStartupInstaller::CheckInlineInstallPermitted(
     61     const base::DictionaryValue& webstore_data,
     62     std::string* error) const {
     63   // Requestor is the command line: ignore the property set in the store
     64   // and always permit inline installs.
     65   *error = "";
     66   return true;
     67 }
     68 
     69 bool WebstoreStartupInstaller::CheckRequestorPermitted(
     70     const base::DictionaryValue& webstore_data,
     71     std::string* error) const {
     72   // Requestor is the command line: always treat it as trusted.
     73   *error = "";
     74   return true;
     75 }
     76 
     77 
     78 }  // namespace extensions
     79