12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_STARTUP_INSTALLER_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CHROME_BROWSER_EXTENSIONS_WEBSTORE_STARTUP_INSTALLER_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
87dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "url/gurl.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "webstore_standalone_installer.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace content {
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class WebContents;
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace extensions {
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Manages inline installs requested to be performed at startup, e.g. via a
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// command line option: downloads and parses metadata from the webstore,
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// optionally shows an install UI, starts the download once the user
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// confirms.
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)//
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Clients will be notified of success or failure via the |callback| argument
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// passed into the constructor.
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class WebstoreStartupInstaller
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    : public WebstoreStandaloneInstaller {
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  typedef WebstoreStandaloneInstaller::Callback Callback;
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  WebstoreStartupInstaller(const std::string& webstore_item_id,
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                         Profile* profile,
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                         bool show_prompt,
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                         const Callback& callback);
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) protected:
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  friend class base::RefCountedThreadSafe<WebstoreStartupInstaller>;
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  FRIEND_TEST_ALL_PREFIXES(WebstoreStartupInstallerTest, DomainVerification);
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~WebstoreStartupInstaller();
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Implementations WebstoreStandaloneInstaller Template Method's hooks.
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool CheckRequestorAlive() const OVERRIDE;
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual const GURL& GetRequestorURL() const OVERRIDE;
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool ShouldShowPostInstallUI() const OVERRIDE;
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool ShouldShowAppInstalledBubble() const OVERRIDE;
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual content::WebContents* GetWebContents() const OVERRIDE;
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual scoped_ptr<ExtensionInstallPrompt::Prompt>
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      CreateInstallPrompt() const OVERRIDE;
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool CheckInlineInstallPermitted(
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const base::DictionaryValue& webstore_data,
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      std::string* error) const OVERRIDE;
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool CheckRequestorPermitted(
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const base::DictionaryValue& webstore_data,
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      std::string* error) const OVERRIDE;
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool show_prompt_;
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GURL dummy_requestor_url_;
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_ptr<content::WebContents> dummy_web_contents_;
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DISALLOW_IMPLICIT_CONSTRUCTORS(WebstoreStartupInstaller);
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace extensions
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // CHROME_BROWSER_EXTENSIONS_WEBSTORE_STARTUP_INSTALLER_H_
66