Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/window_controller.h" | 7 #include "chrome/browser/extensions/window_controller.h" |
| 8 #include "chrome/browser/extensions/window_controller_list.h" | 8 #include "chrome/browser/extensions/window_controller_list.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 | 47 |
| 48 return GetProfile()->HasOffTheRecordProfile() && | 48 return GetProfile()->HasOffTheRecordProfile() && |
| 49 GetProfile()->GetOffTheRecordProfile() == window_controller->profile(); | 49 GetProfile()->GetOffTheRecordProfile() == window_controller->profile(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // TODO(stevenjb): Replace this with GetExtensionWindowController(). | 52 // TODO(stevenjb): Replace this with GetExtensionWindowController(). |
| 53 Browser* ChromeExtensionFunctionDetails::GetCurrentBrowser() const { | 53 Browser* ChromeExtensionFunctionDetails::GetCurrentBrowser() const { |
| 54 // If the delegate has an associated browser, return it. | 54 // If the delegate has an associated browser, return it. |
| 55 if (function_->dispatcher()) { | 55 if (function_->dispatcher()) { |
| 56 extensions::WindowController* window_controller = | 56 extensions::WindowController* window_controller = |
| 57 function_->dispatcher()->delegate()->GetExtensionWindowController(); | 57 function_->dispatcher()->GetExtensionWindowController(); |
|
not at google - send to devlin
2015/06/10 20:48:12
It would be nice if this were just function_->GetW
Devlin
2015/06/10 20:59:20
Agreed - I intend to try and clean up ExtensionFun
| |
| 58 if (window_controller) { | 58 if (window_controller) { |
| 59 Browser* browser = window_controller->GetBrowser(); | 59 Browser* browser = window_controller->GetBrowser(); |
| 60 if (browser) | 60 if (browser) |
| 61 return browser; | 61 return browser; |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 // Otherwise, try to default to a reasonable browser. If |include_incognito_| | 65 // Otherwise, try to default to a reasonable browser. If |include_incognito_| |
| 66 // is true, we will also search browsers in the incognito version of this | 66 // is true, we will also search browsers in the incognito version of this |
| 67 // profile. Note that the profile may already be incognito, in which case | 67 // profile. Note that the profile may already be incognito, in which case |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 86 // TODO(rafaelw): Delay creation of background_page until the browser | 86 // TODO(rafaelw): Delay creation of background_page until the browser |
| 87 // is available. http://code.google.com/p/chromium/issues/detail?id=13284 | 87 // is available. http://code.google.com/p/chromium/issues/detail?id=13284 |
| 88 return NULL; | 88 return NULL; |
| 89 } | 89 } |
| 90 | 90 |
| 91 extensions::WindowController* | 91 extensions::WindowController* |
| 92 ChromeExtensionFunctionDetails::GetExtensionWindowController() const { | 92 ChromeExtensionFunctionDetails::GetExtensionWindowController() const { |
| 93 // If the delegate has an associated window controller, return it. | 93 // If the delegate has an associated window controller, return it. |
| 94 if (function_->dispatcher()) { | 94 if (function_->dispatcher()) { |
| 95 extensions::WindowController* window_controller = | 95 extensions::WindowController* window_controller = |
| 96 function_->dispatcher()->delegate()->GetExtensionWindowController(); | 96 function_->dispatcher()->GetExtensionWindowController(); |
| 97 if (window_controller) | 97 if (window_controller) |
| 98 return window_controller; | 98 return window_controller; |
| 99 } | 99 } |
| 100 | 100 |
| 101 return extensions::WindowControllerList::GetInstance() | 101 return extensions::WindowControllerList::GetInstance() |
| 102 ->CurrentWindowForFunction(*this); | 102 ->CurrentWindowForFunction(*this); |
| 103 } | 103 } |
| 104 | 104 |
| 105 content::WebContents* | 105 content::WebContents* |
| 106 ChromeExtensionFunctionDetails::GetAssociatedWebContents() { | 106 ChromeExtensionFunctionDetails::GetAssociatedWebContents() { |
| 107 content::WebContents* web_contents = function_->GetAssociatedWebContents(); | 107 content::WebContents* web_contents = function_->GetAssociatedWebContents(); |
| 108 if (web_contents) | 108 if (web_contents) |
| 109 return web_contents; | 109 return web_contents; |
| 110 | 110 |
| 111 Browser* browser = GetCurrentBrowser(); | 111 Browser* browser = GetCurrentBrowser(); |
| 112 if (!browser) | 112 if (!browser) |
| 113 return NULL; | 113 return NULL; |
| 114 return browser->tab_strip_model()->GetActiveWebContents(); | 114 return browser->tab_strip_model()->GetActiveWebContents(); |
| 115 } | 115 } |
| OLD | NEW |