| 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 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/extensions/api/debugger/debugger_api.h" | 17 #include "chrome/browser/extensions/api/debugger/debugger_api.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/extensions/extension_system.h" | 19 #include "chrome/browser/extensions/extension_system.h" |
| 20 #include "chrome/browser/file_select_helper.h" | 20 #include "chrome/browser/file_select_helper.h" |
| 21 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 21 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 22 #include "chrome/browser/infobars/infobar.h" |
| 22 #include "chrome/browser/prefs/pref_service_syncable.h" | 23 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 23 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 24 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/sessions/session_tab_helper.h" | 26 #include "chrome/browser/sessions/session_tab_helper.h" |
| 26 #include "chrome/browser/themes/theme_properties.h" | 27 #include "chrome/browser/themes/theme_properties.h" |
| 27 #include "chrome/browser/themes/theme_service.h" | 28 #include "chrome/browser/themes/theme_service.h" |
| 28 #include "chrome/browser/themes/theme_service_factory.h" | 29 #include "chrome/browser/themes/theme_service_factory.h" |
| 29 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
| 30 #include "chrome/browser/ui/browser_dialogs.h" | 31 #include "chrome/browser/ui/browser_dialogs.h" |
| 31 #include "chrome/browser/ui/browser_iterator.h" | 32 #include "chrome/browser/ui/browser_iterator.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 public: | 73 public: |
| 73 // If |infobar_service| is NULL, runs |callback| with a single argument with | 74 // If |infobar_service| is NULL, runs |callback| with a single argument with |
| 74 // value "false". Otherwise, creates a dev tools confirm infobar and delegate | 75 // value "false". Otherwise, creates a dev tools confirm infobar and delegate |
| 75 // and adds the inofbar to |infobar_service|. | 76 // and adds the inofbar to |infobar_service|. |
| 76 static void Create(InfoBarService* infobar_service, | 77 static void Create(InfoBarService* infobar_service, |
| 77 const DevToolsWindow::InfoBarCallback& callback, | 78 const DevToolsWindow::InfoBarCallback& callback, |
| 78 const string16& message); | 79 const string16& message); |
| 79 | 80 |
| 80 private: | 81 private: |
| 81 DevToolsConfirmInfoBarDelegate( | 82 DevToolsConfirmInfoBarDelegate( |
| 82 InfoBarService* infobar_service, | |
| 83 const DevToolsWindow::InfoBarCallback& callback, | 83 const DevToolsWindow::InfoBarCallback& callback, |
| 84 const string16& message); | 84 const string16& message); |
| 85 virtual ~DevToolsConfirmInfoBarDelegate(); | 85 virtual ~DevToolsConfirmInfoBarDelegate(); |
| 86 | 86 |
| 87 virtual string16 GetMessageText() const OVERRIDE; | 87 virtual string16 GetMessageText() const OVERRIDE; |
| 88 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 88 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 89 virtual bool Accept() OVERRIDE; | 89 virtual bool Accept() OVERRIDE; |
| 90 virtual bool Cancel() OVERRIDE; | 90 virtual bool Cancel() OVERRIDE; |
| 91 | 91 |
| 92 DevToolsWindow::InfoBarCallback callback_; | 92 DevToolsWindow::InfoBarCallback callback_; |
| 93 const string16 message_; | 93 const string16 message_; |
| 94 | 94 |
| 95 DISALLOW_COPY_AND_ASSIGN(DevToolsConfirmInfoBarDelegate); | 95 DISALLOW_COPY_AND_ASSIGN(DevToolsConfirmInfoBarDelegate); |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 void DevToolsConfirmInfoBarDelegate::Create( | 98 void DevToolsConfirmInfoBarDelegate::Create( |
| 99 InfoBarService* infobar_service, | 99 InfoBarService* infobar_service, |
| 100 const DevToolsWindow::InfoBarCallback& callback, | 100 const DevToolsWindow::InfoBarCallback& callback, |
| 101 const string16& message) { | 101 const string16& message) { |
| 102 if (!infobar_service) { | 102 if (!infobar_service) { |
| 103 callback.Run(false); | 103 callback.Run(false); |
| 104 return; | 104 return; |
| 105 } | 105 } |
| 106 | 106 |
| 107 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( | 107 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( |
| 108 new DevToolsConfirmInfoBarDelegate(infobar_service, callback, message))); | 108 scoped_ptr<ConfirmInfoBarDelegate>( |
| 109 new DevToolsConfirmInfoBarDelegate(callback, message)))); |
| 109 } | 110 } |
| 110 | 111 |
| 111 DevToolsConfirmInfoBarDelegate::DevToolsConfirmInfoBarDelegate( | 112 DevToolsConfirmInfoBarDelegate::DevToolsConfirmInfoBarDelegate( |
| 112 InfoBarService* infobar_service, | |
| 113 const DevToolsWindow::InfoBarCallback& callback, | 113 const DevToolsWindow::InfoBarCallback& callback, |
| 114 const string16& message) | 114 const string16& message) |
| 115 : ConfirmInfoBarDelegate(infobar_service), | 115 : ConfirmInfoBarDelegate(), |
| 116 callback_(callback), | 116 callback_(callback), |
| 117 message_(message) { | 117 message_(message) { |
| 118 } | 118 } |
| 119 | 119 |
| 120 DevToolsConfirmInfoBarDelegate::~DevToolsConfirmInfoBarDelegate() { | 120 DevToolsConfirmInfoBarDelegate::~DevToolsConfirmInfoBarDelegate() { |
| 121 if (!callback_.is_null()) | 121 if (!callback_.is_null()) |
| 122 callback_.Run(false); | 122 callback_.Run(false); |
| 123 } | 123 } |
| 124 | 124 |
| 125 string16 DevToolsConfirmInfoBarDelegate::GetMessageText() const { | 125 string16 DevToolsConfirmInfoBarDelegate::GetMessageText() const { |
| (...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 | 1333 |
| 1334 void DevToolsWindow::Restore() { | 1334 void DevToolsWindow::Restore() { |
| 1335 if (dock_side_ == DEVTOOLS_DOCK_SIDE_MINIMIZED) | 1335 if (dock_side_ == DEVTOOLS_DOCK_SIDE_MINIMIZED) |
| 1336 SetDockSide(SideToString(dock_side_before_minimized_)); | 1336 SetDockSide(SideToString(dock_side_before_minimized_)); |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 content::WebContents* DevToolsWindow::GetInspectedWebContents() { | 1339 content::WebContents* DevToolsWindow::GetInspectedWebContents() { |
| 1340 return inspected_contents_observer_ ? | 1340 return inspected_contents_observer_ ? |
| 1341 inspected_contents_observer_->web_contents() : NULL; | 1341 inspected_contents_observer_->web_contents() : NULL; |
| 1342 } | 1342 } |
| OLD | NEW |