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

Side by Side Diff: chrome/browser/extensions/extension_function.cc

Issue 10735061: Move ExtensionWindowController and related into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for cq Created 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extension_function.h" 5 #include "chrome/browser/extensions/extension_function.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/extensions/extension_function_dispatcher.h" 9 #include "chrome/browser/extensions/extension_function_dispatcher.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_window_controller.h" 11 #include "chrome/browser/extensions/window_controller.h"
12 #include "chrome/browser/extensions/extension_window_list.h" 12 #include "chrome/browser/extensions/window_controller_list.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" 14 #include "chrome/browser/renderer_host/chrome_render_message_filter.h"
15 #include "chrome/browser/ui/browser_finder.h" 15 #include "chrome/browser/ui/browser_finder.h"
16 #include "chrome/common/extensions/extension_messages.h" 16 #include "chrome/common/extensions/extension_messages.h"
17 #include "content/public/browser/notification_source.h" 17 #include "content/public/browser/notification_source.h"
18 #include "content/public/browser/notification_types.h" 18 #include "content/public/browser/notification_types.h"
19 #include "content/public/browser/render_process_host.h" 19 #include "content/public/browser/render_process_host.h"
20 #include "content/public/browser/render_view_host.h" 20 #include "content/public/browser/render_view_host.h"
21 #include "content/public/browser/user_metrics.h" 21 #include "content/public/browser/user_metrics.h"
22 #include "content/public/common/result_codes.h" 22 #include "content/public/common/result_codes.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 void UIThreadExtensionFunction::SetRenderViewHost( 181 void UIThreadExtensionFunction::SetRenderViewHost(
182 RenderViewHost* render_view_host) { 182 RenderViewHost* render_view_host) {
183 render_view_host_ = render_view_host; 183 render_view_host_ = render_view_host;
184 tracker_.reset(render_view_host ? 184 tracker_.reset(render_view_host ?
185 new RenderViewHostTracker(this, render_view_host) : NULL); 185 new RenderViewHostTracker(this, render_view_host) : NULL);
186 } 186 }
187 187
188 // TODO(stevenjb): Replace this with GetExtensionWindowController(). 188 // TODO(stevenjb): Replace this with GetExtensionWindowController().
189 Browser* UIThreadExtensionFunction::GetCurrentBrowser() { 189 Browser* UIThreadExtensionFunction::GetCurrentBrowser() {
190 // If the delegate has an associated browser, return it. 190 // If the delegate has an associated browser, return it.
191 ExtensionWindowController* window_controller = 191 extensions::WindowController* window_controller =
192 dispatcher()->delegate()->GetExtensionWindowController(); 192 dispatcher()->delegate()->GetExtensionWindowController();
193 if (window_controller) { 193 if (window_controller) {
194 Browser* browser = window_controller->GetBrowser(); 194 Browser* browser = window_controller->GetBrowser();
195 if (browser) 195 if (browser)
196 return browser; 196 return browser;
197 } 197 }
198 198
199 // Otherwise, try to default to a reasonable browser. If |include_incognito_| 199 // Otherwise, try to default to a reasonable browser. If |include_incognito_|
200 // is true, we will also search browsers in the incognito version of this 200 // is true, we will also search browsers in the incognito version of this
201 // profile. Note that the profile may already be incognito, in which case 201 // profile. Note that the profile may already be incognito, in which case
202 // we will search the incognito version only, regardless of the value of 202 // we will search the incognito version only, regardless of the value of
203 // |include_incognito|. 203 // |include_incognito|.
204 Profile* profile = Profile::FromBrowserContext( 204 Profile* profile = Profile::FromBrowserContext(
205 render_view_host_->GetProcess()->GetBrowserContext()); 205 render_view_host_->GetProcess()->GetBrowserContext());
206 Browser* browser = browser::FindAnyBrowser(profile, include_incognito_); 206 Browser* browser = browser::FindAnyBrowser(profile, include_incognito_);
207 207
208 // NOTE(rafaelw): This can return NULL in some circumstances. In particular, 208 // NOTE(rafaelw): This can return NULL in some circumstances. In particular,
209 // a background_page onload chrome.tabs api call can make it into here 209 // a background_page onload chrome.tabs api call can make it into here
210 // before the browser is sufficiently initialized to return here. 210 // before the browser is sufficiently initialized to return here.
211 // A similar situation may arise during shutdown. 211 // A similar situation may arise during shutdown.
212 // TODO(rafaelw): Delay creation of background_page until the browser 212 // TODO(rafaelw): Delay creation of background_page until the browser
213 // is available. http://code.google.com/p/chromium/issues/detail?id=13284 213 // is available. http://code.google.com/p/chromium/issues/detail?id=13284
214 return browser; 214 return browser;
215 } 215 }
216 216
217 ExtensionWindowController* 217 extensions::WindowController*
218 UIThreadExtensionFunction::GetExtensionWindowController() { 218 UIThreadExtensionFunction::GetExtensionWindowController() {
219 // If the delegate has an associated window controller, return it. 219 // If the delegate has an associated window controller, return it.
220 ExtensionWindowController* window_controller = 220 extensions::WindowController* window_controller =
221 dispatcher()->delegate()->GetExtensionWindowController(); 221 dispatcher()->delegate()->GetExtensionWindowController();
222 if (window_controller) 222 if (window_controller)
223 return window_controller; 223 return window_controller;
224 224
225 return ExtensionWindowList::GetInstance()->CurrentWindowForFunction(this); 225 return extensions::WindowControllerList::GetInstance()->
226 CurrentWindowForFunction(this);
226 } 227 }
227 228
228 bool UIThreadExtensionFunction::CanOperateOnWindow( 229 bool UIThreadExtensionFunction::CanOperateOnWindow(
229 const ExtensionWindowController* window_controller) const { 230 const extensions::WindowController* window_controller) const {
230 const extensions::Extension* extension = GetExtension(); 231 const extensions::Extension* extension = GetExtension();
231 // |extension| is NULL for unit tests only. 232 // |extension| is NULL for unit tests only.
232 if (extension != NULL && !window_controller->IsVisibleToExtension(extension)) 233 if (extension != NULL && !window_controller->IsVisibleToExtension(extension))
233 return false; 234 return false;
234 235
235 if (profile() == window_controller->profile()) 236 if (profile() == window_controller->profile())
236 return true; 237 return true;
237 238
238 if (!include_incognito()) 239 if (!include_incognito())
239 return false; 240 return false;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 299
299 SyncIOThreadExtensionFunction::SyncIOThreadExtensionFunction() { 300 SyncIOThreadExtensionFunction::SyncIOThreadExtensionFunction() {
300 } 301 }
301 302
302 SyncIOThreadExtensionFunction::~SyncIOThreadExtensionFunction() { 303 SyncIOThreadExtensionFunction::~SyncIOThreadExtensionFunction() {
303 } 304 }
304 305
305 void SyncIOThreadExtensionFunction::Run() { 306 void SyncIOThreadExtensionFunction::Run() {
306 SendResponse(RunImpl()); 307 SendResponse(RunImpl());
307 } 308 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_function.h ('k') | chrome/browser/extensions/extension_function_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698