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

Unified Diff: chrome/browser/extensions/extension_install_prompt.h

Issue 10388252: Refactoring ExtenionInstallUI to abstract the Browser references. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Yoyo's comments. Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_install_prompt.h
diff --git a/chrome/browser/extensions/extension_install_ui.h b/chrome/browser/extensions/extension_install_prompt.h
similarity index 82%
copy from chrome/browser/extensions/extension_install_ui.h
copy to chrome/browser/extensions/extension_install_prompt.h
index 4f6307d23f09933cf5837e688c4b8792ecffb163..61a4d2de19a29f3c38d150201a9257e57696f246 100644
--- a/chrome/browser/extensions/extension_install_ui.h
+++ b/chrome/browser/extensions/extension_install_prompt.h
@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_
-#define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_
#pragma once
#include <string>
#include <vector>
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
#include "chrome/browser/extensions/image_loading_tracker.h"
#include "chrome/common/extensions/url_pattern.h"
@@ -17,7 +18,7 @@
#include "ui/gfx/image/image.h"
#include "ui/gfx/native_widget_types.h"
-class Browser;
+class ExtensionInstallUI;
class ExtensionPermissionSet;
class MessageLoop;
class Profile;
@@ -26,15 +27,15 @@ class TabContentsWrapper;
namespace base {
class DictionaryValue;
-}
+} // namespace base
namespace extensions {
class BundleInstaller;
class Extension;
-}
+} // namespace extensions
// Displays all the UI around extension installation.
-class ExtensionInstallUI : public ImageLoadingTracker::Observer {
+class ExtensionInstallPrompt : public ImageLoadingTracker::Observer {
public:
enum PromptType {
UNSET_PROMPT_TYPE = -1,
@@ -147,8 +148,8 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
const std::string& localized_description,
std::string* error);
- explicit ExtensionInstallUI(Profile* profile);
- virtual ~ExtensionInstallUI();
+ explicit ExtensionInstallPrompt(Profile* profile);
+ virtual ~ExtensionInstallPrompt();
// TODO(asargent) Normally we navigate to the new tab page when an app is
// installed, but we're experimenting with instead showing a bubble when
@@ -158,10 +159,10 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
use_app_installed_bubble_ = use_bubble;
}
+ ExtensionInstallUI* install_ui() const { return install_ui_.get(); }
+
// Whether or not to show the default UI after completing the installation.
- void set_skip_post_install_ui(bool skip_ui) {
- skip_post_install_ui_ = skip_ui;
- }
+ void SetSkipPostInstallUI(bool skip_ui);
Yoyo Zhou 2012/06/01 21:07:43 Can this be removed too? It's UI-specific, and the
Jay Civelli 2012/06/04 17:15:30 Done.
// This is called by the bundle installer to verify whether the bundle
// should be installed.
@@ -209,39 +210,18 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
const extensions::Extension* extension,
const ExtensionPermissionSet* permissions);
- // Installation was successful. This is declared virtual for testing.
- virtual void OnInstallSuccess(const extensions::Extension* extension,
- SkBitmap* icon);
-
- // Installation failed. This is declared virtual for testing.
- virtual void OnInstallFailure(const string16& error);
-
// ImageLoadingTracker::Observer:
virtual void OnImageLoaded(const gfx::Image& image,
const std::string& extension_id,
int index) OVERRIDE;
- // Opens apps UI and animates the app icon for the app with id |app_id|.
- static void OpenAppInstalledUI(Browser* browser, const std::string& app_id);
-
protected:
friend class ExtensionNoConfirmWebstorePrivateApiTest;
friend class WebstoreInlineInstallUnpackFailureTest;
- // Disables showing UI (ErrorBox, etc.) for install failures. To be used only
- // in tests.
- static void DisableFailureUIForTests();
-
private:
friend class GalleryInstallApiTestObserver;
- // Show an infobar for a newly-installed theme. previous_theme_id
- // should be empty if the previous theme was the system/default
- // theme.
- static void ShowThemeInfoBar(
- const std::string& previous_theme_id, bool previous_using_native_theme,
- const extensions::Extension* new_theme, Profile* profile);
-
// Sets the icon that will be used in any UI. If |icon| is NULL, or contains
// an empty bitmap, then a default icon will be used instead.
void SetIcon(const SkBitmap* icon);
@@ -254,21 +234,9 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
// Shows the actual UI (the icon should already be loaded).
void ShowConfirmation();
- // Returns the delegate to control the browser's info bar. This is
- // within its own function due to its platform-specific nature.
- static InfoBarDelegate* GetNewThemeInstalledInfoBarDelegate(
- TabContentsWrapper* tab_contents,
- const extensions::Extension* new_theme,
- const std::string& previous_theme_id,
- bool previous_using_native_theme);
-
Profile* profile_;
MessageLoop* ui_loop_;
- // Used to undo theme installation.
- std::string previous_theme_id_;
- bool previous_using_native_theme_;
-
// The extensions installation icon.
SkBitmap icon_;
@@ -281,6 +249,9 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
// The permissions being prompted for.
scoped_refptr<const ExtensionPermissionSet> permissions_;
+ // The object responsible for doing the UI specific actions.
+ scoped_ptr<ExtensionInstallUI> install_ui_;
+
// The delegate we will call Proceed/Abort on after confirmation UI.
Delegate* delegate_;
@@ -297,9 +268,6 @@ class ExtensionInstallUI : public ImageLoadingTracker::Observer {
// Whether to show an installed bubble on app install, or use the default
// action of opening a new tab page.
bool use_app_installed_bubble_;
-
- // Whether or not to show the default UI after completing the installation.
- bool skip_post_install_ui_;
};
-#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_UI_H_
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALL_PROMPT_H_

Powered by Google App Engine
This is Rietveld 408576698