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

Unified Diff: chrome/browser/extensions/chrome_extension_function_details.cc

Issue 1225693009: Show extension uninstall dialog in browser window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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/chrome_extension_function_details.cc
diff --git a/chrome/browser/extensions/chrome_extension_function_details.cc b/chrome/browser/extensions/chrome_extension_function_details.cc
index 922c96be53d7f720dcdcc1c6b0283b241d441893..d9ff40f253b8e2e3c91dde6d7ea91ca6a960a707 100644
--- a/chrome/browser/extensions/chrome_extension_function_details.cc
+++ b/chrome/browser/extensions/chrome_extension_function_details.cc
@@ -4,14 +4,18 @@
#include "chrome/browser/extensions/chrome_extension_function_details.h"
+#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/window_controller.h"
#include "chrome/browser/extensions/window_controller_list.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
+#include "extensions/browser/app_window/app_window.h"
+#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/extension_function.h"
#include "extensions/browser/extension_function_dispatcher.h"
@@ -113,3 +117,37 @@ ChromeExtensionFunctionDetails::GetAssociatedWebContents() {
return NULL;
return browser->tab_strip_model()->GetActiveWebContents();
}
+
+content::WebContents* ChromeExtensionFunctionDetails::GetVisibleWebContents() {
+ WebContents* contents =
+ WebContents::FromRenderFrameHost(function_->render_frame_host());
not at google - send to devlin 2015/07/10 17:02:25 You should be able to use GetSenderWebContents() h
+ web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager =
not at google - send to devlin 2015/07/10 17:02:25 Add comment: // Hack: use the existence of a WebC
+ web_modal::WebContentsModalDialogManager::FromWebContents(contents);
+ if (!web_contents_modal_dialog_manager) {
+ // If there is no WebContentsModalDialogManager, then this contents is
+ // probably the background page for an app. Try to find a app window to
+ // host the dialog.
+ contents = nullptr;
+
+ Profile* profile = GetProfile();
+ const extensions::Extension* extension = function_->extension();
+ if (extension) {
+ extensions::AppWindow* window =
not at google - send to devlin 2015/07/10 17:57:03 Actually, perhaps you should be using WindowContro
wjywbs 2015/07/10 19:54:22 Turns out that CurrentWindowForFunction() can prop
+ extensions::AppWindowRegistry::Get(profile)
+ ->GetCurrentAppWindowForApp(extension->id());
+ if (window)
+ contents = window->web_contents();
not at google - send to devlin 2015/07/10 17:02:25 Likewise, early-return (even once moved to the end
+ }
+
+ int source_tab_id = function_->source_tab_id();
not at google - send to devlin 2015/07/10 17:02:25 Tiny request: put the checks for the tab above the
+ if (!contents && source_tab_id != TabStripModel::kNoTab) {
+ // When the request originated from a background page, but there is no
+ // app window open, check to see if it originated from a tab and display
+ // the dialog in that tab.
+ extensions::ExtensionTabUtil::GetTabById(source_tab_id, profile,
+ profile->IsOffTheRecord(), NULL,
not at google - send to devlin 2015/07/10 17:02:25 just use "true" here, not "profile->IsOffTheRecord
+ NULL, &contents, NULL);
not at google - send to devlin 2015/07/10 17:02:25 always use nullptr not NULL now.
+ }
not at google - send to devlin 2015/07/10 17:02:25 and early-return.
+ }
+ return contents;
+}

Powered by Google App Engine
This is Rietveld 408576698