| 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_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/prefs/scoped_user_pref_update.h" | 13 #include "base/prefs/scoped_user_pref_update.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/extensions/api/debugger/debugger_api.h" | 20 #include "chrome/browser/extensions/api/debugger/debugger_api.h" |
| 21 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 22 #include "chrome/browser/extensions/extension_system.h" | 22 #include "chrome/browser/extensions/extension_system.h" |
| 23 #include "chrome/browser/extensions/extension_web_contents_observer.h" | 23 #include "chrome/browser/extensions/extension_web_contents_observer.h" |
| 24 #include "chrome/browser/file_select_helper.h" | 24 #include "chrome/browser/file_select_helper.h" |
| 25 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 25 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 26 #include "chrome/browser/infobars/infobar.h" | |
| 27 #include "chrome/browser/prefs/pref_service_syncable.h" | 26 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 28 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 29 #include "chrome/browser/sessions/session_tab_helper.h" | 28 #include "chrome/browser/sessions/session_tab_helper.h" |
| 30 #include "chrome/browser/themes/theme_properties.h" | 29 #include "chrome/browser/themes/theme_properties.h" |
| 31 #include "chrome/browser/themes/theme_service.h" | 30 #include "chrome/browser/themes/theme_service.h" |
| 32 #include "chrome/browser/themes/theme_service_factory.h" | 31 #include "chrome/browser/themes/theme_service_factory.h" |
| 33 #include "chrome/browser/ui/browser.h" | 32 #include "chrome/browser/ui/browser.h" |
| 34 #include "chrome/browser/ui/browser_dialogs.h" | 33 #include "chrome/browser/ui/browser_dialogs.h" |
| 35 #include "chrome/browser/ui/browser_iterator.h" | 34 #include "chrome/browser/ui/browser_iterator.h" |
| 36 #include "chrome/browser/ui/browser_list.h" | 35 #include "chrome/browser/ui/browser_list.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 public: | 78 public: |
| 80 // If |infobar_service| is NULL, runs |callback| with a single argument with | 79 // If |infobar_service| is NULL, runs |callback| with a single argument with |
| 81 // value "false". Otherwise, creates a dev tools confirm infobar and delegate | 80 // value "false". Otherwise, creates a dev tools confirm infobar and delegate |
| 82 // and adds the inofbar to |infobar_service|. | 81 // and adds the inofbar to |infobar_service|. |
| 83 static void Create(InfoBarService* infobar_service, | 82 static void Create(InfoBarService* infobar_service, |
| 84 const DevToolsWindow::InfoBarCallback& callback, | 83 const DevToolsWindow::InfoBarCallback& callback, |
| 85 const string16& message); | 84 const string16& message); |
| 86 | 85 |
| 87 private: | 86 private: |
| 88 DevToolsConfirmInfoBarDelegate( | 87 DevToolsConfirmInfoBarDelegate( |
| 88 InfoBarService* infobar_service, |
| 89 const DevToolsWindow::InfoBarCallback& callback, | 89 const DevToolsWindow::InfoBarCallback& callback, |
| 90 const string16& message); | 90 const string16& message); |
| 91 virtual ~DevToolsConfirmInfoBarDelegate(); | 91 virtual ~DevToolsConfirmInfoBarDelegate(); |
| 92 | 92 |
| 93 virtual string16 GetMessageText() const OVERRIDE; | 93 virtual string16 GetMessageText() const OVERRIDE; |
| 94 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 94 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 95 virtual bool Accept() OVERRIDE; | 95 virtual bool Accept() OVERRIDE; |
| 96 virtual bool Cancel() OVERRIDE; | 96 virtual bool Cancel() OVERRIDE; |
| 97 | 97 |
| 98 DevToolsWindow::InfoBarCallback callback_; | 98 DevToolsWindow::InfoBarCallback callback_; |
| 99 const string16 message_; | 99 const string16 message_; |
| 100 | 100 |
| 101 DISALLOW_COPY_AND_ASSIGN(DevToolsConfirmInfoBarDelegate); | 101 DISALLOW_COPY_AND_ASSIGN(DevToolsConfirmInfoBarDelegate); |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 void DevToolsConfirmInfoBarDelegate::Create( | 104 void DevToolsConfirmInfoBarDelegate::Create( |
| 105 InfoBarService* infobar_service, | 105 InfoBarService* infobar_service, |
| 106 const DevToolsWindow::InfoBarCallback& callback, | 106 const DevToolsWindow::InfoBarCallback& callback, |
| 107 const string16& message) { | 107 const string16& message) { |
| 108 if (!infobar_service) { | 108 if (!infobar_service) { |
| 109 callback.Run(false); | 109 callback.Run(false); |
| 110 return; | 110 return; |
| 111 } | 111 } |
| 112 | 112 |
| 113 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( | 113 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
| 114 scoped_ptr<ConfirmInfoBarDelegate>( | 114 new DevToolsConfirmInfoBarDelegate(infobar_service, callback, message))); |
| 115 new DevToolsConfirmInfoBarDelegate(callback, message)))); | |
| 116 } | 115 } |
| 117 | 116 |
| 118 DevToolsConfirmInfoBarDelegate::DevToolsConfirmInfoBarDelegate( | 117 DevToolsConfirmInfoBarDelegate::DevToolsConfirmInfoBarDelegate( |
| 118 InfoBarService* infobar_service, |
| 119 const DevToolsWindow::InfoBarCallback& callback, | 119 const DevToolsWindow::InfoBarCallback& callback, |
| 120 const string16& message) | 120 const string16& message) |
| 121 : ConfirmInfoBarDelegate(), | 121 : ConfirmInfoBarDelegate(infobar_service), |
| 122 callback_(callback), | 122 callback_(callback), |
| 123 message_(message) { | 123 message_(message) { |
| 124 } | 124 } |
| 125 | 125 |
| 126 DevToolsConfirmInfoBarDelegate::~DevToolsConfirmInfoBarDelegate() { | 126 DevToolsConfirmInfoBarDelegate::~DevToolsConfirmInfoBarDelegate() { |
| 127 if (!callback_.is_null()) | 127 if (!callback_.is_null()) |
| 128 callback_.Run(false); | 128 callback_.Run(false); |
| 129 } | 129 } |
| 130 | 130 |
| 131 string16 DevToolsConfirmInfoBarDelegate::GetMessageText() const { | 131 string16 DevToolsConfirmInfoBarDelegate::GetMessageText() const { |
| (...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1513 return inspected_contents_observer_ ? | 1513 return inspected_contents_observer_ ? |
| 1514 inspected_contents_observer_->web_contents() : NULL; | 1514 inspected_contents_observer_->web_contents() : NULL; |
| 1515 } | 1515 } |
| 1516 | 1516 |
| 1517 void DevToolsWindow::DocumentOnLoadCompletedInMainFrame() { | 1517 void DevToolsWindow::DocumentOnLoadCompletedInMainFrame() { |
| 1518 is_loaded_ = true; | 1518 is_loaded_ = true; |
| 1519 UpdateTheme(); | 1519 UpdateTheme(); |
| 1520 DoAction(); | 1520 DoAction(); |
| 1521 AddDevToolsExtensionsToClient(); | 1521 AddDevToolsExtensionsToClient(); |
| 1522 } | 1522 } |
| OLD | NEW |