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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/extensions/chrome_extension_function_details.h" 5 #include "chrome/browser/extensions/chrome_extension_function_details.h"
6 6
7 #include "chrome/browser/extensions/extension_tab_util.h"
7 #include "chrome/browser/extensions/window_controller.h" 8 #include "chrome/browser/extensions/window_controller.h"
8 #include "chrome/browser/extensions/window_controller_list.h" 9 #include "chrome/browser/extensions/window_controller_list.h"
9 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_finder.h" 12 #include "chrome/browser/ui/browser_finder.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "components/web_modal/web_contents_modal_dialog_manager.h"
13 #include "content/public/browser/render_frame_host.h" 15 #include "content/public/browser/render_frame_host.h"
14 #include "content/public/browser/render_process_host.h" 16 #include "content/public/browser/render_process_host.h"
17 #include "extensions/browser/app_window/app_window.h"
18 #include "extensions/browser/app_window/app_window_registry.h"
15 #include "extensions/browser/extension_function.h" 19 #include "extensions/browser/extension_function.h"
16 #include "extensions/browser/extension_function_dispatcher.h" 20 #include "extensions/browser/extension_function_dispatcher.h"
17 21
18 using content::WebContents; 22 using content::WebContents;
19 using content::RenderViewHost; 23 using content::RenderViewHost;
20 using extensions::WindowController; 24 using extensions::WindowController;
21 25
22 ChromeExtensionFunctionDetails::ChromeExtensionFunctionDetails( 26 ChromeExtensionFunctionDetails::ChromeExtensionFunctionDetails(
23 UIThreadExtensionFunction* function) 27 UIThreadExtensionFunction* function)
24 : function_(function) { 28 : function_(function) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 ChromeExtensionFunctionDetails::GetAssociatedWebContents() { 110 ChromeExtensionFunctionDetails::GetAssociatedWebContents() {
107 content::WebContents* web_contents = function_->GetAssociatedWebContents(); 111 content::WebContents* web_contents = function_->GetAssociatedWebContents();
108 if (web_contents) 112 if (web_contents)
109 return web_contents; 113 return web_contents;
110 114
111 Browser* browser = GetCurrentBrowser(); 115 Browser* browser = GetCurrentBrowser();
112 if (!browser) 116 if (!browser)
113 return NULL; 117 return NULL;
114 return browser->tab_strip_model()->GetActiveWebContents(); 118 return browser->tab_strip_model()->GetActiveWebContents();
115 } 119 }
120
121 content::WebContents* ChromeExtensionFunctionDetails::GetVisibleWebContents() {
122 WebContents* contents =
123 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
124 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
125 web_modal::WebContentsModalDialogManager::FromWebContents(contents);
126 if (!web_contents_modal_dialog_manager) {
127 // If there is no WebContentsModalDialogManager, then this contents is
128 // probably the background page for an app. Try to find a app window to
129 // host the dialog.
130 contents = nullptr;
131
132 Profile* profile = GetProfile();
133 const extensions::Extension* extension = function_->extension();
134 if (extension) {
135 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
136 extensions::AppWindowRegistry::Get(profile)
137 ->GetCurrentAppWindowForApp(extension->id());
138 if (window)
139 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
140 }
141
142 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
143 if (!contents && source_tab_id != TabStripModel::kNoTab) {
144 // When the request originated from a background page, but there is no
145 // app window open, check to see if it originated from a tab and display
146 // the dialog in that tab.
147 extensions::ExtensionTabUtil::GetTabById(source_tab_id, profile,
148 profile->IsOffTheRecord(), NULL,
not at google - send to devlin 2015/07/10 17:02:25 just use "true" here, not "profile->IsOffTheRecord
149 NULL, &contents, NULL);
not at google - send to devlin 2015/07/10 17:02:25 always use nullptr not NULL now.
150 }
not at google - send to devlin 2015/07/10 17:02:25 and early-return.
151 }
152 return contents;
153 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698