| 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/ui/views/extensions/extension_dialog.h" | 5 #include "chrome/browser/ui/views/extensions/extension_dialog.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/extensions/extension_view_host.h" | 8 #include "chrome/browser/extensions/extension_view_host.h" |
| 9 #include "chrome/browser/extensions/extension_view_host_factory.h" | 9 #include "chrome/browser/extensions/extension_view_host_factory.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/views/extensions/extension_dialog_observer.h" | 11 #include "chrome/browser/ui/views/extensions/extension_dialog_observer.h" |
| 12 #include "chrome/browser/ui/views/extensions/extension_view_views.h" | 12 #include "chrome/browser/ui/views/extensions/extension_view_views.h" |
| 13 #include "components/constrained_window/constrained_window_views.h" | 13 #include "components/constrained_window/constrained_window_views.h" |
| 14 #include "content/public/browser/notification_details.h" | 14 #include "content/public/browser/notification_details.h" |
| 15 #include "content/public/browser/notification_source.h" | 15 #include "content/public/browser/notification_source.h" |
| 16 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
| 17 #include "content/public/browser/render_widget_host.h" | 17 #include "content/public/browser/render_widget_host.h" |
| 18 #include "content/public/browser/render_widget_host_view.h" | 18 #include "content/public/browser/render_widget_host_view.h" |
| 19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "ui/base/base_window.h" | 20 #include "ui/base/base_window.h" |
| 21 #include "ui/gfx/screen.h" | 21 #include "ui/display/screen.h" |
| 22 #include "ui/views/background.h" | 22 #include "ui/views/background.h" |
| 23 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 | 25 |
| 26 using content::BrowserContext; | 26 using content::BrowserContext; |
| 27 using content::WebContents; | 27 using content::WebContents; |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 ExtensionViewViews* GetExtensionView(extensions::ExtensionViewHost* host) { | 31 ExtensionViewViews* GetExtensionView(extensions::ExtensionViewHost* host) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 // Center the window over the browser. | 104 // Center the window over the browser. |
| 105 views::Widget* parent_widget = | 105 views::Widget* parent_widget = |
| 106 views::Widget::GetWidgetForNativeWindow(parent); | 106 views::Widget::GetWidgetForNativeWindow(parent); |
| 107 gfx::Point center = parent_widget->GetWindowBoundsInScreen().CenterPoint(); | 107 gfx::Point center = parent_widget->GetWindowBoundsInScreen().CenterPoint(); |
| 108 int x = center.x() - width / 2; | 108 int x = center.x() - width / 2; |
| 109 int y = center.y() - height / 2; | 109 int y = center.y() - height / 2; |
| 110 // Ensure the top left and top right of the window are on screen, with | 110 // Ensure the top left and top right of the window are on screen, with |
| 111 // priority given to the top left. | 111 // priority given to the top left. |
| 112 gfx::Rect screen_rect = | 112 gfx::Rect screen_rect = |
| 113 gfx::Screen::GetScreen()->GetDisplayNearestPoint(center).bounds(); | 113 display::Screen::GetScreen()->GetDisplayNearestPoint(center).bounds(); |
| 114 gfx::Rect bounds_rect = gfx::Rect(x, y, width, height); | 114 gfx::Rect bounds_rect = gfx::Rect(x, y, width, height); |
| 115 bounds_rect.AdjustToFit(screen_rect); | 115 bounds_rect.AdjustToFit(screen_rect); |
| 116 window->SetBounds(bounds_rect); | 116 window->SetBounds(bounds_rect); |
| 117 | 117 |
| 118 window->Show(); | 118 window->Show(); |
| 119 // TODO(jamescook): Remove redundant call to Activate()? | 119 // TODO(jamescook): Remove redundant call to Activate()? |
| 120 window->Activate(); | 120 window->Activate(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void ExtensionDialog::ObserverDestroyed() { | 123 void ExtensionDialog::ObserverDestroyed() { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 if (content::Details<extensions::ExtensionHost>(host()) != details) | 222 if (content::Details<extensions::ExtensionHost>(host()) != details) |
| 223 return; | 223 return; |
| 224 if (observer_) | 224 if (observer_) |
| 225 observer_->ExtensionTerminated(this); | 225 observer_->ExtensionTerminated(this); |
| 226 break; | 226 break; |
| 227 default: | 227 default: |
| 228 NOTREACHED() << "Received unexpected notification"; | 228 NOTREACHED() << "Received unexpected notification"; |
| 229 break; | 229 break; |
| 230 } | 230 } |
| 231 } | 231 } |
| OLD | NEW |