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/devtools/devtools_window.h" | 5 #include "chrome/browser/devtools/devtools_window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
15 #include "base/metrics/user_metrics.h" | 15 #include "base/metrics/user_metrics.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/certificate_viewer.h" | 18 #include "chrome/browser/certificate_viewer.h" |
19 #include "chrome/browser/data_use_measurement/data_use_web_contents_observer.h" | 19 #include "chrome/browser/data_use_measurement/data_use_web_contents_observer.h" |
| 20 #include "chrome/browser/devtools/devtools_eye_dropper.h" |
20 #include "chrome/browser/file_select_helper.h" | 21 #include "chrome/browser/file_select_helper.h" |
21 #include "chrome/browser/infobars/infobar_service.h" | 22 #include "chrome/browser/infobars/infobar_service.h" |
22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/sessions/session_tab_helper.h" | 24 #include "chrome/browser/sessions/session_tab_helper.h" |
24 #include "chrome/browser/task_manager/web_contents_tags.h" | 25 #include "chrome/browser/task_manager/web_contents_tags.h" |
25 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_dialogs.h" | 27 #include "chrome/browser/ui/browser_dialogs.h" |
27 #include "chrome/browser/ui/browser_list.h" | 28 #include "chrome/browser/ui/browser_list.h" |
28 #include "chrome/browser/ui/browser_tabstrip.h" | 29 #include "chrome/browser/ui/browser_tabstrip.h" |
29 #include "chrome/browser/ui/browser_window.h" | 30 #include "chrome/browser/ui/browser_window.h" |
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 chrome::AddSelectedTabWithURL(displayer.browser(), GURL(url), | 1239 chrome::AddSelectedTabWithURL(displayer.browser(), GURL(url), |
1239 ui::PAGE_TRANSITION_LINK); | 1240 ui::PAGE_TRANSITION_LINK); |
1240 } | 1241 } |
1241 } | 1242 } |
1242 | 1243 |
1243 void DevToolsWindow::SetWhitelistedShortcuts( | 1244 void DevToolsWindow::SetWhitelistedShortcuts( |
1244 const std::string& message) { | 1245 const std::string& message) { |
1245 event_forwarder_->SetWhitelistedShortcuts(message); | 1246 event_forwarder_->SetWhitelistedShortcuts(message); |
1246 } | 1247 } |
1247 | 1248 |
| 1249 void DevToolsWindow::SetEyeDropperActive(bool active) { |
| 1250 WebContents* web_contents = GetInspectedWebContents(); |
| 1251 if (!web_contents) |
| 1252 return; |
| 1253 if (active) { |
| 1254 eye_dropper_.reset(new DevToolsEyeDropper( |
| 1255 web_contents, base::Bind(&DevToolsWindow::ColorPickedInEyeDropper, |
| 1256 base::Unretained(this)))); |
| 1257 } else { |
| 1258 eye_dropper_.reset(); |
| 1259 } |
| 1260 } |
| 1261 |
| 1262 void DevToolsWindow::ColorPickedInEyeDropper(int r, int g, int b, int a) { |
| 1263 base::DictionaryValue color; |
| 1264 color.SetInteger("r", r); |
| 1265 color.SetInteger("g", g); |
| 1266 color.SetInteger("b", b); |
| 1267 color.SetInteger("a", a); |
| 1268 bindings_->CallClientFunction("DevToolsAPI.eyeDropperPickedColor", &color, |
| 1269 nullptr, nullptr); |
| 1270 } |
| 1271 |
1248 void DevToolsWindow::InspectedContentsClosing() { | 1272 void DevToolsWindow::InspectedContentsClosing() { |
1249 if (!close_on_detach_) | 1273 if (!close_on_detach_) |
1250 return; | 1274 return; |
1251 intercepted_page_beforeunload_ = false; | 1275 intercepted_page_beforeunload_ = false; |
1252 life_stage_ = kClosing; | 1276 life_stage_ = kClosing; |
1253 main_web_contents_->ClosePage(); | 1277 main_web_contents_->ClosePage(); |
1254 } | 1278 } |
1255 | 1279 |
1256 InfoBarService* DevToolsWindow::GetInfoBarService() { | 1280 InfoBarService* DevToolsWindow::GetInfoBarService() { |
1257 return is_docked_ ? | 1281 return is_docked_ ? |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { | 1433 bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { |
1410 // Only route reload via front-end if the agent is attached. | 1434 // Only route reload via front-end if the agent is attached. |
1411 WebContents* wc = GetInspectedWebContents(); | 1435 WebContents* wc = GetInspectedWebContents(); |
1412 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) | 1436 if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) |
1413 return false; | 1437 return false; |
1414 base::Value bypass_cache_value(bypass_cache); | 1438 base::Value bypass_cache_value(bypass_cache); |
1415 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", | 1439 bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", |
1416 &bypass_cache_value, nullptr, nullptr); | 1440 &bypass_cache_value, nullptr, nullptr); |
1417 return true; | 1441 return true; |
1418 } | 1442 } |
OLD | NEW |