| OLD | NEW |
| 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_tabs_module.h" | 5 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 ExtensionMsg_ExecuteCode_Params params; | 1246 ExtensionMsg_ExecuteCode_Params params; |
| 1247 params.request_id = request_id(); | 1247 params.request_id = request_id(); |
| 1248 params.extension_id = extension_id(); | 1248 params.extension_id = extension_id(); |
| 1249 params.is_javascript = true; | 1249 params.is_javascript = true; |
| 1250 params.code = url.path(); | 1250 params.code = url.path(); |
| 1251 params.all_frames = false; | 1251 params.all_frames = false; |
| 1252 params.in_main_world = true; | 1252 params.in_main_world = true; |
| 1253 | 1253 |
| 1254 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost(); | 1254 RenderViewHost* render_view_host = web_contents_->GetRenderViewHost(); |
| 1255 render_view_host->Send( | 1255 render_view_host->Send( |
| 1256 new ExtensionMsg_ExecuteCode(render_view_host->routing_id(), | 1256 new ExtensionMsg_ExecuteCode(render_view_host->GetRoutingID(), |
| 1257 params)); | 1257 params)); |
| 1258 | 1258 |
| 1259 Observe(web_contents_); | 1259 Observe(web_contents_); |
| 1260 AddRef(); // Balanced in OnExecuteCodeFinished(). | 1260 AddRef(); // Balanced in OnExecuteCodeFinished(). |
| 1261 | 1261 |
| 1262 is_async = true; | 1262 is_async = true; |
| 1263 } | 1263 } |
| 1264 | 1264 |
| 1265 controller.LoadURL( | 1265 controller.LoadURL( |
| 1266 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | 1266 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 error_ = keys::kTabStripNotEditableError; | 1573 error_ = keys::kTabStripNotEditableError; |
| 1574 return false; | 1574 return false; |
| 1575 } | 1575 } |
| 1576 | 1576 |
| 1577 // Close the tab in this convoluted way, since there's a chance that the tab | 1577 // Close the tab in this convoluted way, since there's a chance that the tab |
| 1578 // is being dragged, or we're in some other nested event loop. This code | 1578 // is being dragged, or we're in some other nested event loop. This code |
| 1579 // path should ensure that the tab is safely closed under such | 1579 // path should ensure that the tab is safely closed under such |
| 1580 // circumstances, whereas |Browser::CloseTabContents()| does not. | 1580 // circumstances, whereas |Browser::CloseTabContents()| does not. |
| 1581 RenderViewHost* render_view_host = | 1581 RenderViewHost* render_view_host = |
| 1582 contents->web_contents()->GetRenderViewHost(); | 1582 contents->web_contents()->GetRenderViewHost(); |
| 1583 render_view_host->delegate()->Close(render_view_host); | 1583 render_view_host->GetDelegate()->Close(render_view_host); |
| 1584 } | 1584 } |
| 1585 return true; | 1585 return true; |
| 1586 } | 1586 } |
| 1587 | 1587 |
| 1588 bool CaptureVisibleTabFunction::RunImpl() { | 1588 bool CaptureVisibleTabFunction::RunImpl() { |
| 1589 Browser* browser = NULL; | 1589 Browser* browser = NULL; |
| 1590 // windowId defaults to "current" window. | 1590 // windowId defaults to "current" window. |
| 1591 int window_id = extension_misc::kCurrentWindowId; | 1591 int window_id = extension_misc::kCurrentWindowId; |
| 1592 | 1592 |
| 1593 if (HasOptionalArgument(0)) | 1593 if (HasOptionalArgument(0)) |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1803 // called for every API call the extension made. | 1803 // called for every API call the extension made. |
| 1804 GotLanguage(language); | 1804 GotLanguage(language); |
| 1805 } | 1805 } |
| 1806 | 1806 |
| 1807 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1807 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
| 1808 result_.reset(Value::CreateStringValue(language.c_str())); | 1808 result_.reset(Value::CreateStringValue(language.c_str())); |
| 1809 SendResponse(true); | 1809 SendResponse(true); |
| 1810 | 1810 |
| 1811 Release(); // Balanced in Run() | 1811 Release(); // Balanced in Run() |
| 1812 } | 1812 } |
| OLD | NEW |