Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: chrome/browser/ui/views/extensions/extension_popup.cc

Issue 10824030: Move ExtensionHost into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for cq Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_popup.h" 5 #include "chrome/browser/ui/views/extensions/extension_popup.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/browser/debugger/devtools_window.h" 9 #include "chrome/browser/debugger/devtools_window.h"
10 #include "chrome/browser/extensions/extension_process_manager.h" 10 #include "chrome/browser/extensions/extension_process_manager.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // The minimum/maximum dimensions of the popup. 55 // The minimum/maximum dimensions of the popup.
56 // The minimum is just a little larger than the size of the button itself. 56 // The minimum is just a little larger than the size of the button itself.
57 // The maximum is an arbitrary number that should be smaller than most screens. 57 // The maximum is an arbitrary number that should be smaller than most screens.
58 const int ExtensionPopup::kMinWidth = 25; 58 const int ExtensionPopup::kMinWidth = 25;
59 const int ExtensionPopup::kMinHeight = 25; 59 const int ExtensionPopup::kMinHeight = 25;
60 const int ExtensionPopup::kMaxWidth = 800; 60 const int ExtensionPopup::kMaxWidth = 800;
61 const int ExtensionPopup::kMaxHeight = 600; 61 const int ExtensionPopup::kMaxHeight = 600;
62 62
63 ExtensionPopup::ExtensionPopup( 63 ExtensionPopup::ExtensionPopup(
64 Browser* browser, 64 Browser* browser,
65 ExtensionHost* host, 65 extensions::ExtensionHost* host,
66 views::View* anchor_view, 66 views::View* anchor_view,
67 views::BubbleBorder::ArrowLocation arrow_location) 67 views::BubbleBorder::ArrowLocation arrow_location)
68 : BubbleDelegateView(anchor_view, arrow_location), 68 : BubbleDelegateView(anchor_view, arrow_location),
69 extension_host_(host), 69 extension_host_(host),
70 inspect_with_devtools_(false), 70 inspect_with_devtools_(false),
71 close_bubble_factory_(this) { 71 close_bubble_factory_(this) {
72 // Adjust the margin so that contents fit better. 72 // Adjust the margin so that contents fit better.
73 const int margin = views::BubbleBorder::GetCornerRadius() / 2; 73 const int margin = views::BubbleBorder::GetCornerRadius() / 2;
74 set_margins(gfx::Insets(margin, margin, margin, margin)); 74 set_margins(gfx::Insets(margin, margin, margin, margin));
75 SetLayoutManager(new views::FillLayout()); 75 SetLayoutManager(new views::FillLayout());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 const content::NotificationSource& source, 107 const content::NotificationSource& source,
108 const content::NotificationDetails& details) { 108 const content::NotificationDetails& details) {
109 switch (type) { 109 switch (type) {
110 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: 110 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME:
111 DCHECK(content::Source<WebContents>(host()->host_contents()) == source); 111 DCHECK(content::Source<WebContents>(host()->host_contents()) == source);
112 // Show when the content finishes loading and its width is computed. 112 // Show when the content finishes loading and its width is computed.
113 ShowBubble(); 113 ShowBubble();
114 break; 114 break;
115 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: 115 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE:
116 // If we aren't the host of the popup, then disregard the notification. 116 // If we aren't the host of the popup, then disregard the notification.
117 if (content::Details<ExtensionHost>(host()) == details) 117 if (content::Details<extensions::ExtensionHost>(host()) == details)
118 GetWidget()->Close(); 118 GetWidget()->Close();
119 break; 119 break;
120 case content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING: 120 case content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING:
121 // Make sure it's the devtools window that inspecting our popup. 121 // Make sure it's the devtools window that inspecting our popup.
122 // Widget::Close posts a task, which should give the devtools window a 122 // Widget::Close posts a task, which should give the devtools window a
123 // chance to finish detaching from the inspected RenderViewHost. 123 // chance to finish detaching from the inspected RenderViewHost.
124 if (content::Details<RenderViewHost>(host()->render_view_host()) == 124 if (content::Details<RenderViewHost>(host()->render_view_host()) ==
125 details) { 125 details) {
126 GetWidget()->Close(); 126 GetWidget()->Close();
127 } 127 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 172
173 // static 173 // static
174 ExtensionPopup* ExtensionPopup::ShowPopup( 174 ExtensionPopup* ExtensionPopup::ShowPopup(
175 const GURL& url, 175 const GURL& url,
176 Browser* browser, 176 Browser* browser,
177 views::View* anchor_view, 177 views::View* anchor_view,
178 views::BubbleBorder::ArrowLocation arrow_location) { 178 views::BubbleBorder::ArrowLocation arrow_location) {
179 ExtensionProcessManager* manager = 179 ExtensionProcessManager* manager =
180 browser->profile()->GetExtensionProcessManager(); 180 browser->profile()->GetExtensionProcessManager();
181 ExtensionHost* host = manager->CreatePopupHost(url, browser); 181 extensions::ExtensionHost* host = manager->CreatePopupHost(url, browser);
182 ExtensionPopup* popup = new ExtensionPopup(browser, host, anchor_view, 182 ExtensionPopup* popup = new ExtensionPopup(browser, host, anchor_view,
183 arrow_location); 183 arrow_location);
184 views::BubbleDelegateView::CreateBubble(popup); 184 views::BubbleDelegateView::CreateBubble(popup);
185 185
186 #if defined(USE_ASH) 186 #if defined(USE_ASH)
187 gfx::NativeView native_view = popup->GetWidget()->GetNativeView(); 187 gfx::NativeView native_view = popup->GetWidget()->GetNativeView();
188 ash::SetWindowVisibilityAnimationType( 188 ash::SetWindowVisibilityAnimationType(
189 native_view, 189 native_view,
190 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL); 190 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL);
191 ash::SetWindowVisibilityAnimationVerticalPosition( 191 ash::SetWindowVisibilityAnimationVerticalPosition(
(...skipping 20 matching lines...) Expand all
212 212
213 if (inspect_with_devtools_) { 213 if (inspect_with_devtools_) {
214 DevToolsWindow::ToggleDevToolsWindow(host()->render_view_host(), 214 DevToolsWindow::ToggleDevToolsWindow(host()->render_view_host(),
215 DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE); 215 DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE);
216 } 216 }
217 } 217 }
218 218
219 void ExtensionPopup::CloseBubble() { 219 void ExtensionPopup::CloseBubble() {
220 GetWidget()->Close(); 220 GetWidget()->Close();
221 } 221 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_popup.h ('k') | chrome/browser/ui/views/extensions/extension_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698