diff options
author | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-19 15:22:20 +0000 |
---|---|---|
committer | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-19 15:22:20 +0000 |
commit | 9bf14a24e1de759fddfbbee8050d65ef2d95ef18 (patch) | |
tree | 24aa03d05b22be52366d8baf06dab96638ecf71b /chrome/browser | |
parent | e685fc4178818c026f1498461edb3f2bfeff5722 (diff) | |
download | chromium_src-9bf14a24e1de759fddfbbee8050d65ef2d95ef18.zip chromium_src-9bf14a24e1de759fddfbbee8050d65ef2d95ef18.tar.gz chromium_src-9bf14a24e1de759fddfbbee8050d65ef2d95ef18.tar.bz2 |
Revert 42091 - Refactor apprelated manifest properties so that they don't
include the name 'app'. I think these will be useful for normal
extensions, too.
Also extract an ExtensionExtent class out of Extension. I think
this will be useful for passing by value to the IO thread.
Review URL: http://codereview.chromium.org/1025006
TBR=aa@chromium.org
Review URL: http://codereview.chromium.org/1120005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42104 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser.cc | 19 | ||||
-rw-r--r-- | chrome/browser/download/download_manager.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/crx_installer.cc | 12 | ||||
-rw-r--r-- | chrome/browser/extensions/crx_installer.h | 12 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service.cc | 13 | ||||
-rw-r--r-- | chrome/browser/extensions/sandboxed_extension_unpacker.cc | 18 | ||||
-rw-r--r-- | chrome/browser/extensions/sandboxed_extension_unpacker.h | 14 | ||||
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 4 | ||||
-rw-r--r-- | chrome/browser/tabs/pinned_tab_codec.cc | 2 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/extensions/extension_install_prompt.cc | 5 |
12 files changed, 55 insertions, 50 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 378d86e..61de33c 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -381,9 +381,9 @@ bool Browser::OpenApplication(Profile* profile, const std::string& app_id) { return false; // TODO(erikkay): Support refocus. - Extension::LaunchContainer launch_container = - extension_app->launch_container(); - switch (launch_container) { + Extension::AppLaunchType launch_type = + extension_app->app_launch_type(); + switch (launch_type) { case Extension::LAUNCH_WINDOW: case Extension::LAUNCH_PANEL: Browser::OpenApplicationWindow(profile, extension_app); @@ -421,9 +421,8 @@ void Browser::OpenApplicationWindow(Profile* profile, const GURL& url, // Set UPDATE_SHORTCUT as the pending web app action. This action is picked // up in LoadingStateChanged to schedule a GetApplicationInfo. And when // the web app info is available, TabContents notifies Browser via - // OnDidGetApplicationInfo, which calls - // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as - // pending web app action. + // OnDidGetApplicationInfo, which calls web_app::UpdateShortcutForTabContents + // when it sees UPDATE_SHORTCUT as pending web app action. browser->pending_web_app_action_ = UPDATE_SHORTCUT; } } @@ -431,13 +430,13 @@ void Browser::OpenApplicationWindow(Profile* profile, const GURL& url, // static void Browser::OpenApplicationWindow(Profile* profile, Extension* extension) { OpenApplicationWindow(profile, - extension->GetFullLaunchURL(), - (extension->launch_container() == Extension::LAUNCH_PANEL)); + extension->app_launch_url(), + (extension->app_launch_type() == Extension::LAUNCH_PANEL)); } // static bool Browser::OpenApplicationTab(Profile* profile, Extension* extension) { - DCHECK_EQ(extension->launch_container(), Extension::LAUNCH_TAB); + DCHECK_EQ(extension->app_launch_type(), Extension::LAUNCH_TAB); Browser* browser = BrowserList::GetLastActiveWithProfile(profile); if (!browser || browser->type() != Browser::TYPE_NORMAL) @@ -445,7 +444,7 @@ bool Browser::OpenApplicationTab(Profile* profile, Extension* extension) { // TODO(erikkay): This doesn't seem like the right transition in all cases. PageTransition::Type transition = PageTransition::START_PAGE; - GURL url = extension->GetFullLaunchURL(); + GURL url = extension->app_launch_url(); TabContents* tab_contents = browser->CreateTabContentsForURL(url, GURL(), profile, transition, false, NULL); diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index 0075352..cc47bea 100644 --- a/chrome/browser/download/download_manager.cc +++ b/chrome/browser/download/download_manager.cc @@ -1457,7 +1457,7 @@ void DownloadManager::OpenChromeExtension(const FilePath& full_path, } else { installer->set_allow_privilege_increase(true); installer->set_original_url(download_url); - installer->set_force_web_origin_to_download_url(true); + installer->set_force_app_origin_to_download_url(true); installer->InstallCrx(full_path); } } else { diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc index 93ec0bb..02bc700 100644 --- a/chrome/browser/extensions/crx_installer.cc +++ b/chrome/browser/extensions/crx_installer.cc @@ -39,7 +39,7 @@ CrxInstaller::CrxInstaller(const FilePath& install_directory, install_source_(Extension::INTERNAL), delete_source_(false), allow_privilege_increase_(false), - force_web_origin_to_download_url_(false), + force_app_origin_to_download_url_(false), create_app_shortcut_(false), frontend_(frontend), client_(client) { @@ -72,8 +72,8 @@ void CrxInstaller::InstallCrx(const FilePath& source_file) { g_browser_process->resource_dispatcher_host(), this)); - if (force_web_origin_to_download_url_ && original_url_.is_valid()) { - unpacker->set_web_origin(original_url_.GetOrigin()); + if (force_app_origin_to_download_url_ && original_url_.is_valid()) { + unpacker->set_app_origin_override(original_url_.GetOrigin()); } ChromeThread::PostTask( @@ -142,7 +142,7 @@ void CrxInstaller::OnUnpackSuccess(const FilePath& temp_dir, return; } - if (client_.get() || extension_->GetFullLaunchURL().is_valid()) { + if (client_.get() || extension_->IsApp()) { Extension::DecodeIcon(extension_.get(), Extension::EXTENSION_ICON_LARGE, &install_icon_); } @@ -177,7 +177,7 @@ void CrxInstaller::ConfirmInstall() { void CrxInstaller::InstallUIProceed(bool create_app_shortcut) { if (create_app_shortcut) { - DCHECK(extension_->GetFullLaunchURL().is_valid()); + DCHECK(extension_->IsApp()); create_app_shortcut_ = true; } @@ -233,7 +233,7 @@ void CrxInstaller::CompleteInstall() { IDR_EXTENSION_DEFAULT_ICON); ShellIntegration::ShortcutInfo shortcut_info; - shortcut_info.url = extension_->GetFullLaunchURL(); + shortcut_info.url = extension_->app_launch_url(); shortcut_info.extension_id = UTF8ToUTF16(extension_->id()); shortcut_info.title = UTF8ToUTF16(extension_->name()); shortcut_info.description = UTF8ToUTF16(extension_->description()); diff --git a/chrome/browser/extensions/crx_installer.h b/chrome/browser/extensions/crx_installer.h index bb109c2..9e4990e 100644 --- a/chrome/browser/extensions/crx_installer.h +++ b/chrome/browser/extensions/crx_installer.h @@ -83,11 +83,11 @@ class CrxInstaller allow_privilege_increase_ = val; } - bool force_web_origin_to_download_url() const { - return force_web_origin_to_download_url_; + bool force_app_origin_to_download_url() const { + return force_app_origin_to_download_url_; } - void set_force_web_origin_to_download_url(bool val) { - force_web_origin_to_download_url_ = val; + void set_force_app_origin_to_download_url(bool val) { + force_app_origin_to_download_url_ = val; } private: @@ -153,9 +153,9 @@ class CrxInstaller // either. Defaults to false. bool allow_privilege_increase_; - // If true and the installed extension uses web content, the web origin will + // If true and the installed extension is an app, the origin of that app will // be forced to the origin of |original_url_|. Defaults to false. - bool force_web_origin_to_download_url_; + bool force_app_origin_to_download_url_; // Whether to create an app shortcut after successful installation. This is // set based on the user's selection in the UI and can only ever be true for diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index 3d72258..62432b5 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -216,7 +216,7 @@ void ExtensionsService::UpdateExtension(const std::string& id, NULL)); // no client (silent install) installer->set_expected_id(id); installer->set_delete_source(true); - installer->set_force_web_origin_to_download_url(true); + installer->set_force_app_origin_to_download_url(true); installer->set_original_url(download_url); installer->InstallCrx(extension_path); } @@ -511,7 +511,7 @@ void ExtensionsService::NotifyExtensionLoaded(Extension* extension) { new ChromeURLRequestContext::ExtensionInfo( extension->path(), extension->default_locale(), - std::vector<URLPattern>(), + extension->app_extent(), extension->api_permissions()))); } @@ -706,6 +706,15 @@ void ExtensionsService::OnExtensionLoaded(Extension* extension, // The extension is now loaded, remove its data from unloaded extension map. unloaded_extension_paths_.erase(extension->id()); + if (extension->IsApp() && + !CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableExtensionApps)) { + ReportExtensionLoadError(extension->path(), errors::kAppsDisabled, + NotificationType::EXTENSION_INSTALL_ERROR, + true); // be noisy + return; + } + // TODO(aa): Need to re-evaluate this branch. Does this still make sense now // that extensions are enabled by default? if (extensions_enabled() || diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.cc b/chrome/browser/extensions/sandboxed_extension_unpacker.cc index 427b864..1cbd932 100644 --- a/chrome/browser/extensions/sandboxed_extension_unpacker.cc +++ b/chrome/browser/extensions/sandboxed_extension_unpacker.cc @@ -255,18 +255,16 @@ DictionaryValue* SandboxedExtensionUnpacker::RewriteManifestFile( static_cast<DictionaryValue*>(manifest.DeepCopy())); final_manifest->SetString(extension_manifest_keys::kPublicKey, public_key_); - // Override the origin if appropriate. - bool web_content_enabled = false; - if (final_manifest->GetBoolean(extension_manifest_keys::kWebContentEnabled, - &web_content_enabled) && - web_content_enabled && - web_origin_.is_valid()) { - if (final_manifest->HasKey(extension_manifest_keys::kWebOrigin)) { - ReportFailure("Unexpected 'web_content.origin' key in manifest."); + // Override the app origin if appropriate. + DictionaryValue* app = NULL; + if (final_manifest->GetDictionary(extension_manifest_keys::kApp, &app) && + !app_origin_override_.is_empty()) { + if (app->HasKey(extension_manifest_keys::kAppOrigin)) { + ReportFailure("Unexpected 'origin' key in manifest."); return NULL; } - final_manifest->SetString(extension_manifest_keys::kWebOrigin, - web_origin_.spec()); + app->SetString(extension_manifest_keys::kAppOrigin, + app_origin_override_.spec()); } std::string manifest_json; diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.h b/chrome/browser/extensions/sandboxed_extension_unpacker.h index a3b190c..25d77b6 100644 --- a/chrome/browser/extensions/sandboxed_extension_unpacker.h +++ b/chrome/browser/extensions/sandboxed_extension_unpacker.h @@ -96,9 +96,9 @@ class SandboxedExtensionUnpacker : public UtilityProcessHost::Client { ResourceDispatcherHost* rdh, SandboxedExtensionUnpackerClient* cilent); - const GURL& web_origin() const { return web_origin_; } - void set_web_origin(const GURL& val) { - web_origin_ = val; + const GURL& app_origin_override() const { return app_origin_override_; } + void set_app_origin_override(const GURL& val) { + app_origin_override_ = val; } // Start unpacking the extension. The client is called with the results. @@ -169,10 +169,10 @@ class SandboxedExtensionUnpacker : public UtilityProcessHost::Client { // The public key that was extracted from the CRX header. std::string public_key_; - // If the unpacked extension uses web content, its origin will be set to this - // value. This is used when an app is self-hosted. The only valid origin is - // the origin it is served from. - GURL web_origin_; + // If the unpacked extension is an app, its origin will be forced to this + // value. This is used when an app is self-hosted. The only valid origin + // is the origin it is served from. + GURL app_origin_override_; }; #endif // CHROME_BROWSER_EXTENSIONS_SANDBOXED_EXTENSION_UNPACKER_H_ diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index f19bd08..81b9fb5 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -854,7 +854,7 @@ ChromeURLRequestContextFactory::ChromeURLRequestContextFactory(Profile* profile) new ChromeURLRequestContext::ExtensionInfo( (*iter)->path(), (*iter)->default_locale(), - std::vector<URLPattern>(), + (*iter)->app_extent(), (*iter)->api_permissions())); } } diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 384cdd1..a869687 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -478,7 +478,7 @@ RenderProcessHost* TabContents::GetRenderProcessHost() const { } void TabContents::SetAppExtension(Extension* extension) { - DCHECK(!extension || extension->GetFullLaunchURL().is_valid()); + DCHECK(!extension || extension->IsApp()); app_extension_ = extension; NotificationService::current()->Notify( @@ -1284,7 +1284,7 @@ TabContents* TabContents::CloneAndMakePhantom() { NavigationEntry* entry = controller().GetActiveEntry(); if (app_extension_) - tab_nav.set_url(app_extension_->GetFullLaunchURL()); + tab_nav.set_url(app_extension_->app_launch_url()); else if (entry) tab_nav.SetFromNavigationEntry(*entry); diff --git a/chrome/browser/tabs/pinned_tab_codec.cc b/chrome/browser/tabs/pinned_tab_codec.cc index df096fc..51b8fd2 100644 --- a/chrome/browser/tabs/pinned_tab_codec.cc +++ b/chrome/browser/tabs/pinned_tab_codec.cc @@ -50,7 +50,7 @@ static void EncodePinnedTab(TabStripModel* model, // . the user is effectively restarting the app, so that returning them to // the app's launch page seems closest to what they expect. // . we do the same when restoring a phantom tab. - value->SetString(kURL, extension->GetFullLaunchURL().spec()); + value->SetString(kURL, extension->app_launch_url().spec()); values->Append(value.release()); } else { NavigationEntry* entry = tab_contents->controller().GetActiveEntry(); diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index ac5881a2..4b67a43 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -1362,7 +1362,7 @@ TEST_F(TabStripModelTest, Apps) { FilePath path(FILE_PATH_LITERAL("/foo")); #endif Extension app_extension(path); - app_extension.launch_web_url_ = "http://www.google.com"; + app_extension.app_launch_url_ = GURL("http://www.google.com"); TabContents* contents1 = CreateTabContents(); contents1->SetAppExtension(&app_extension); TabContents* contents2 = CreateTabContents(); diff --git a/chrome/browser/views/extensions/extension_install_prompt.cc b/chrome/browser/views/extensions/extension_install_prompt.cc index 7e45c67..482cb3c 100644 --- a/chrome/browser/views/extensions/extension_install_prompt.cc +++ b/chrome/browser/views/extensions/extension_install_prompt.cc @@ -44,7 +44,7 @@ class InstallDialogContent : public views::View, public views::DialogDelegate { ExtensionInstallUI::PromptType type) : delegate_(delegate), icon_(NULL), warning_(NULL), create_shortcut_(NULL), type_(type) { - if (extension->GetFullLaunchURL().is_valid()) { + if (extension->IsApp()) { icon_size_ = kIconSizeApp; right_column_width_ = kRightColumnWidthApp; } else { @@ -69,8 +69,7 @@ class InstallDialogContent : public views::View, public views::DialogDelegate { heading_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); AddChildView(heading_); - if (type_ == ExtensionInstallUI::INSTALL_PROMPT && - extension->GetFullLaunchURL().is_valid()) { + if (type_ == ExtensionInstallUI::INSTALL_PROMPT && extension->IsApp()) { create_shortcut_ = new views::Checkbox( l10n_util::GetString(IDS_EXTENSION_PROMPT_CREATE_SHORTCUT)); create_shortcut_->SetChecked(true); |