Commit d8076cd6 authored by rdevlin.cronin's avatar rdevlin.cronin Committed by Commit bot

[Extensions] Update TabHelper to use ExtensionId

This was suggested in https://codereview.chromium.org/2103663002, but
I held off because of the bloat of including extension.h. That's no
longer the case with ExtensionId in its own header.

BUG=None

Review-Url: https://codereview.chromium.org/2134653003
Cr-Commit-Position: refs/heads/master@{#404523}
parent 2573dfb1
...@@ -82,7 +82,7 @@ class TabHelper::InlineInstallObserver : public InstallObserver { ...@@ -82,7 +82,7 @@ class TabHelper::InlineInstallObserver : public InstallObserver {
InlineInstallObserver(TabHelper* tab_helper, InlineInstallObserver(TabHelper* tab_helper,
content::BrowserContext* browser_context, content::BrowserContext* browser_context,
int routing_id, int routing_id,
const std::string& extension_id, const ExtensionId& extension_id,
bool observe_download_progress, bool observe_download_progress,
bool observe_install_stage) bool observe_install_stage)
: tab_helper_(tab_helper), : tab_helper_(tab_helper),
...@@ -102,24 +102,24 @@ class TabHelper::InlineInstallObserver : public InstallObserver { ...@@ -102,24 +102,24 @@ class TabHelper::InlineInstallObserver : public InstallObserver {
private: private:
// InstallObserver: // InstallObserver:
void OnBeginExtensionDownload(const std::string& extension_id) override { void OnBeginExtensionDownload(const ExtensionId& extension_id) override {
SendInstallStageChangedMessage(extension_id, SendInstallStageChangedMessage(extension_id,
api::webstore::INSTALL_STAGE_DOWNLOADING); api::webstore::INSTALL_STAGE_DOWNLOADING);
} }
void OnDownloadProgress(const std::string& extension_id, void OnDownloadProgress(const ExtensionId& extension_id,
int percent_downloaded) override { int percent_downloaded) override {
if (observe_download_progress_ && extension_id == extension_id_) { if (observe_download_progress_ && extension_id == extension_id_) {
tab_helper_->Send(new ExtensionMsg_InlineInstallDownloadProgress( tab_helper_->Send(new ExtensionMsg_InlineInstallDownloadProgress(
routing_id_, percent_downloaded)); routing_id_, percent_downloaded));
} }
} }
void OnBeginCrxInstall(const std::string& extension_id) override { void OnBeginCrxInstall(const ExtensionId& extension_id) override {
SendInstallStageChangedMessage(extension_id, SendInstallStageChangedMessage(extension_id,
api::webstore::INSTALL_STAGE_INSTALLING); api::webstore::INSTALL_STAGE_INSTALLING);
} }
void OnShutdown() override { install_observer_.RemoveAll(); } void OnShutdown() override { install_observer_.RemoveAll(); }
void SendInstallStageChangedMessage(const std::string& extension_id, void SendInstallStageChangedMessage(const ExtensionId& extension_id,
api::webstore::InstallStage stage) { api::webstore::InstallStage stage) {
if (observe_install_stage_ && extension_id == extension_id_) { if (observe_install_stage_ && extension_id == extension_id_) {
tab_helper_->Send( tab_helper_->Send(
...@@ -134,7 +134,7 @@ class TabHelper::InlineInstallObserver : public InstallObserver { ...@@ -134,7 +134,7 @@ class TabHelper::InlineInstallObserver : public InstallObserver {
int routing_id_; int routing_id_;
// The id of the extension to observe. // The id of the extension to observe.
std::string extension_id_; ExtensionId extension_id_;
// Whether or not to observe download/install progress. // Whether or not to observe download/install progress.
const bool observe_download_progress_; const bool observe_download_progress_;
...@@ -258,13 +258,13 @@ void TabHelper::SetExtensionApp(const Extension* extension) { ...@@ -258,13 +258,13 @@ void TabHelper::SetExtensionApp(const Extension* extension) {
content::NotificationService::NoDetails()); content::NotificationService::NoDetails());
} }
void TabHelper::SetExtensionAppById(const std::string& extension_app_id) { void TabHelper::SetExtensionAppById(const ExtensionId& extension_app_id) {
const Extension* extension = GetExtension(extension_app_id); const Extension* extension = GetExtension(extension_app_id);
if (extension) if (extension)
SetExtensionApp(extension); SetExtensionApp(extension);
} }
void TabHelper::SetExtensionAppIconById(const std::string& extension_app_id) { void TabHelper::SetExtensionAppIconById(const ExtensionId& extension_app_id) {
const Extension* extension = GetExtension(extension_app_id); const Extension* extension = GetExtension(extension_app_id);
if (extension) if (extension)
UpdateExtensionAppIcon(extension); UpdateExtensionAppIcon(extension);
...@@ -530,7 +530,7 @@ void TabHelper::OnContentScriptsExecuting( ...@@ -530,7 +530,7 @@ void TabHelper::OnContentScriptsExecuting(
OnScriptsExecuted(web_contents(), executing_scripts_map, on_url)); OnScriptsExecuted(web_contents(), executing_scripts_map, on_url));
} }
const Extension* TabHelper::GetExtension(const std::string& extension_app_id) { const Extension* TabHelper::GetExtension(const ExtensionId& extension_app_id) {
if (extension_app_id.empty()) if (extension_app_id.empty())
return NULL; return NULL;
...@@ -582,7 +582,7 @@ WindowController* TabHelper::GetExtensionWindowController() const { ...@@ -582,7 +582,7 @@ WindowController* TabHelper::GetExtensionWindowController() const {
void TabHelper::OnReenableComplete(int install_id, void TabHelper::OnReenableComplete(int install_id,
int return_route_id, int return_route_id,
const std::string& extension_id, const ExtensionId& extension_id,
ExtensionReenabler::ReenableResult result) { ExtensionReenabler::ReenableResult result) {
// Map the re-enable results to webstore-install results. // Map the re-enable results to webstore-install results.
webstore_install::Result webstore_result = webstore_install::SUCCESS; webstore_install::Result webstore_result = webstore_install::SUCCESS;
...@@ -614,7 +614,7 @@ void TabHelper::OnReenableComplete(int install_id, ...@@ -614,7 +614,7 @@ void TabHelper::OnReenableComplete(int install_id,
void TabHelper::OnInlineInstallComplete(int install_id, void TabHelper::OnInlineInstallComplete(int install_id,
int return_route_id, int return_route_id,
const std::string& extension_id, const ExtensionId& extension_id,
bool success, bool success,
const std::string& error, const std::string& error,
webstore_install::Result result) { webstore_install::Result result) {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "extensions/browser/extension_registry_observer.h" #include "extensions/browser/extension_registry_observer.h"
#include "extensions/browser/script_execution_observer.h" #include "extensions/browser/script_execution_observer.h"
#include "extensions/browser/script_executor.h" #include "extensions/browser/script_executor.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/stack_frame.h" #include "extensions/common/stack_frame.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
...@@ -82,10 +83,10 @@ class TabHelper : public content::WebContentsObserver, ...@@ -82,10 +83,10 @@ class TabHelper : public content::WebContentsObserver,
// Convenience for setting the app extension by id. This does nothing if // Convenience for setting the app extension by id. This does nothing if
// |extension_app_id| is empty, or an extension can't be found given the // |extension_app_id| is empty, or an extension can't be found given the
// specified id. // specified id.
void SetExtensionAppById(const std::string& extension_app_id); void SetExtensionAppById(const ExtensionId& extension_app_id);
// Set just the app icon, used by panels created by an extension. // Set just the app icon, used by panels created by an extension.
void SetExtensionAppIconById(const std::string& extension_app_id); void SetExtensionAppIconById(const ExtensionId& extension_app_id);
const Extension* extension_app() const { return extension_app_; } const Extension* extension_app() const { return extension_app_; }
bool is_app() const { return extension_app_ != NULL; } bool is_app() const { return extension_app_ != NULL; }
...@@ -193,14 +194,14 @@ class TabHelper : public content::WebContentsObserver, ...@@ -193,14 +194,14 @@ class TabHelper : public content::WebContentsObserver,
// the extension's image asynchronously. // the extension's image asynchronously.
void UpdateExtensionAppIcon(const Extension* extension); void UpdateExtensionAppIcon(const Extension* extension);
const Extension* GetExtension(const std::string& extension_app_id); const Extension* GetExtension(const ExtensionId& extension_app_id);
void OnImageLoaded(const gfx::Image& image); void OnImageLoaded(const gfx::Image& image);
// WebstoreStandaloneInstaller::Callback. // WebstoreStandaloneInstaller::Callback.
void OnInlineInstallComplete(int install_id, void OnInlineInstallComplete(int install_id,
int return_route_id, int return_route_id,
const std::string& extension_id, const ExtensionId& extension_id,
bool success, bool success,
const std::string& error, const std::string& error,
webstore_install::Result result); webstore_install::Result result);
...@@ -208,7 +209,7 @@ class TabHelper : public content::WebContentsObserver, ...@@ -208,7 +209,7 @@ class TabHelper : public content::WebContentsObserver,
// ExtensionReenabler::Callback. // ExtensionReenabler::Callback.
void OnReenableComplete(int install_id, void OnReenableComplete(int install_id,
int return_route_id, int return_route_id,
const std::string& extension_id, const ExtensionId& extension_id,
ExtensionReenabler::ReenableResult result); ExtensionReenabler::ReenableResult result);
// content::NotificationObserver. // content::NotificationObserver.
...@@ -274,13 +275,13 @@ class TabHelper : public content::WebContentsObserver, ...@@ -274,13 +275,13 @@ class TabHelper : public content::WebContentsObserver,
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
registry_observer_; registry_observer_;
// Map of extension id -> InlineInstallObserver for inline installations that // Map of InlineInstallObservers for inline installations that have progress
// have progress listeners. // listeners.
std::map<std::string, std::unique_ptr<InlineInstallObserver>> std::map<ExtensionId, std::unique_ptr<InlineInstallObserver>>
install_observers_; install_observers_;
// The set of extension ids that are currently being installed. // The set of extension ids that are currently being installed.
std::set<std::string> pending_inline_installations_; std::set<ExtensionId> pending_inline_installations_;
// Vend weak pointers that can be invalidated to stop in-progress loads. // Vend weak pointers that can be invalidated to stop in-progress loads.
base::WeakPtrFactory<TabHelper> image_loader_ptr_factory_; base::WeakPtrFactory<TabHelper> image_loader_ptr_factory_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment