Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/views/extensions/extension_dialog.h" | 5 #include "chrome/browser/ui/views/extensions/extension_dialog.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | |
| 7 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
| 8 #include "chrome/browser/extensions/extension_process_manager.h" | 9 #include "chrome/browser/extensions/extension_process_manager.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
| 12 #include "chrome/browser/ui/views/extensions/extension_dialog_observer.h" | 13 #include "chrome/browser/ui/views/extensions/extension_dialog_observer.h" |
| 13 #include "chrome/browser/ui/views/window.h" // CreateViewsWindow | 14 #include "chrome/browser/ui/views/window.h" // CreateViewsWindow |
| 14 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 15 #include "content/browser/renderer_host/render_view_host.h" | 16 #include "content/browser/renderer_host/render_view_host.h" |
| 16 #include "content/browser/renderer_host/render_widget_host_view.h" | 17 #include "content/browser/renderer_host/render_widget_host_view.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 ExtensionDialog::~ExtensionDialog() { | 57 ExtensionDialog::~ExtensionDialog() { |
| 57 } | 58 } |
| 58 | 59 |
| 59 // static | 60 // static |
| 60 ExtensionDialog* ExtensionDialog::Show( | 61 ExtensionDialog* ExtensionDialog::Show( |
| 61 const GURL& url, | 62 const GURL& url, |
| 62 Browser* browser, | 63 Browser* browser, |
| 63 TabContents* tab_contents, | 64 TabContents* tab_contents, |
| 64 int width, | 65 int width, |
| 65 int height, | 66 int height, |
| 67 std::string title, | |
|
mazda
2011/11/09 04:49:43
const string16& title
yoshiki
2011/11/09 15:06:39
Done.
| |
| 66 ExtensionDialogObserver* observer) { | 68 ExtensionDialogObserver* observer) { |
| 67 CHECK(browser); | 69 CHECK(browser); |
| 68 ExtensionHost* host = CreateExtensionHost(url, browser); | 70 ExtensionHost* host = CreateExtensionHost(url, browser); |
| 69 if (!host) | 71 if (!host) |
| 70 return NULL; | 72 return NULL; |
| 71 host->set_associated_tab_contents(tab_contents); | 73 host->set_associated_tab_contents(tab_contents); |
| 72 | 74 |
| 73 ExtensionDialog* dialog = new ExtensionDialog(host, observer); | 75 ExtensionDialog* dialog = new ExtensionDialog(host, observer); |
| 76 dialog->set_title(title); | |
| 74 dialog->InitWindow(browser, width, height); | 77 dialog->InitWindow(browser, width, height); |
| 75 // Ensure the DOM JavaScript can respond immediately to keyboard shortcuts. | 78 // Ensure the DOM JavaScript can respond immediately to keyboard shortcuts. |
| 76 host->render_view_host()->view()->Focus(); | 79 host->render_view_host()->view()->Focus(); |
| 77 return dialog; | 80 return dialog; |
| 78 } | 81 } |
| 79 | 82 |
| 80 // static | 83 // static |
| 81 ExtensionHost* ExtensionDialog::CreateExtensionHost(const GURL& url, | 84 ExtensionHost* ExtensionDialog::CreateExtensionHost(const GURL& url, |
| 82 Browser* browser) { | 85 Browser* browser) { |
| 83 ExtensionProcessManager* manager = | 86 ExtensionProcessManager* manager = |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 | 125 |
| 123 bool ExtensionDialog::CanResize() const { | 126 bool ExtensionDialog::CanResize() const { |
| 124 return false; | 127 return false; |
| 125 } | 128 } |
| 126 | 129 |
| 127 bool ExtensionDialog::IsModal() const { | 130 bool ExtensionDialog::IsModal() const { |
| 128 return true; | 131 return true; |
| 129 } | 132 } |
| 130 | 133 |
| 131 bool ExtensionDialog::ShouldShowWindowTitle() const { | 134 bool ExtensionDialog::ShouldShowWindowTitle() const { |
| 132 return false; | 135 return (window_title_ == "") ? false : true; |
|
mazda
2011/11/09 04:49:43
return !window_title_.empty();
yoshiki
2011/11/09 15:06:39
Done.
| |
| 136 } | |
| 137 | |
| 138 string16 ExtensionDialog::GetWindowTitle() const { | |
| 139 return UTF8ToUTF16(window_title_); | |
| 133 } | 140 } |
| 134 | 141 |
| 135 void ExtensionDialog::DeleteDelegate() { | 142 void ExtensionDialog::DeleteDelegate() { |
| 136 // The window has finished closing. Allow ourself to be deleted. | 143 // The window has finished closing. Allow ourself to be deleted. |
| 137 Release(); | 144 Release(); |
| 138 } | 145 } |
| 139 | 146 |
| 140 views::Widget* ExtensionDialog::GetWidget() { | 147 views::Widget* ExtensionDialog::GetWidget() { |
| 141 return extension_host_->view()->GetWidget(); | 148 return extension_host_->view()->GetWidget(); |
| 142 } | 149 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 160 // If we aren't the host of the popup, then disregard the notification. | 167 // If we aren't the host of the popup, then disregard the notification. |
| 161 if (content::Details<ExtensionHost>(host()) != details) | 168 if (content::Details<ExtensionHost>(host()) != details) |
| 162 return; | 169 return; |
| 163 Close(); | 170 Close(); |
| 164 break; | 171 break; |
| 165 default: | 172 default: |
| 166 NOTREACHED() << L"Received unexpected notification"; | 173 NOTREACHED() << L"Received unexpected notification"; |
| 167 break; | 174 break; |
| 168 } | 175 } |
| 169 } | 176 } |
| OLD | NEW |