Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: chrome/browser/extensions/webstore_installer.h

Issue 8983010: Convert WebContents to return a content::NavigationController instead of the implementation. Upda... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 17
18 class FilePath; 18 class FilePath;
19 class Profile;
20
21 namespace content {
19 class NavigationController; 22 class NavigationController;
20 class Profile; 23 }
21 24
22 // Downloads and installs extensions from the web store. 25 // Downloads and installs extensions from the web store.
23 class WebstoreInstaller : public content::NotificationObserver, 26 class WebstoreInstaller : public content::NotificationObserver,
24 public base::RefCounted<WebstoreInstaller> { 27 public base::RefCounted<WebstoreInstaller> {
25 public: 28 public:
26 enum Flag { 29 enum Flag {
27 FLAG_NONE = 0, 30 FLAG_NONE = 0,
28 31
29 // Inline installs trigger slightly different behavior (install source 32 // Inline installs trigger slightly different behavior (install source
30 // is different, download referrers are the item's page in the gallery). 33 // is different, download referrers are the item's page in the gallery).
31 FLAG_INLINE_INSTALL = 1 << 0 34 FLAG_INLINE_INSTALL = 1 << 0
32 }; 35 };
33 36
34 class Delegate { 37 class Delegate {
35 public: 38 public:
36 virtual void OnExtensionInstallSuccess(const std::string& id) = 0; 39 virtual void OnExtensionInstallSuccess(const std::string& id) = 0;
37 virtual void OnExtensionInstallFailure(const std::string& id, 40 virtual void OnExtensionInstallFailure(const std::string& id,
38 const std::string& error) = 0; 41 const std::string& error) = 0;
39 }; 42 };
40 43
41 44
42 // Creates a WebstoreInstaller for downloading and installing the extension 45 // Creates a WebstoreInstaller for downloading and installing the extension
43 // with the given |id| from the Chrome Web Store. If |delegate| is not NULL, 46 // with the given |id| from the Chrome Web Store. If |delegate| is not NULL,
44 // it will be notified when the install succeeds or fails. The installer will 47 // it will be notified when the install succeeds or fails. The installer will
45 // use the specified |controller| to download the extension. Only one 48 // use the specified |controller| to download the extension. Only one
46 // WebstoreInstaller can use a specific controller at any given time. 49 // WebstoreInstaller can use a specific controller at any given time.
47 // Note: the delegate should stay alive until being called back. 50 // Note: the delegate should stay alive until being called back.
48 WebstoreInstaller(Profile* profile, 51 WebstoreInstaller(Profile* profile,
49 Delegate* delegate, 52 Delegate* delegate,
50 NavigationController* controller, 53 content::NavigationController* controller,
51 const std::string& id, 54 const std::string& id,
52 int flags); 55 int flags);
53 virtual ~WebstoreInstaller(); 56 virtual ~WebstoreInstaller();
54 57
55 // Starts downloading and installing the extension. 58 // Starts downloading and installing the extension.
56 void Start(); 59 void Start();
57 60
58 // content::NotificationObserver 61 // content::NotificationObserver
59 virtual void Observe(int type, 62 virtual void Observe(int type,
60 const content::NotificationSource& source, 63 const content::NotificationSource& source,
(...skipping 12 matching lines...) Expand all
73 void ReportFailure(const std::string& error); 76 void ReportFailure(const std::string& error);
74 77
75 // Reports a successful install to the delegate for the given extension if 78 // Reports a successful install to the delegate for the given extension if
76 // this managed its installation. This also removes the associated 79 // this managed its installation. This also removes the associated
77 // PendingInstall. 80 // PendingInstall.
78 void ReportSuccess(); 81 void ReportSuccess();
79 82
80 content::NotificationRegistrar registrar_; 83 content::NotificationRegistrar registrar_;
81 Profile* profile_; 84 Profile* profile_;
82 Delegate* delegate_; 85 Delegate* delegate_;
83 NavigationController* controller_; 86 content::NavigationController* controller_;
84 std::string id_; 87 std::string id_;
85 int flags_; 88 int flags_;
86 GURL download_url_; 89 GURL download_url_;
87 }; 90 };
88 91
89 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ 92 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698