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

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

Issue 10961066: Revert 158199 - extensions: Add ExtensionView interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
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"
11 #include "chrome/browser/platform_util.h" 11 #include "chrome/browser/platform_util.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/views/extensions/extension_view_views.h"
16 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
17 #include "content/public/browser/notification_details.h" 16 #include "content/public/browser/notification_details.h"
18 #include "content/public/browser/notification_source.h" 17 #include "content/public/browser/notification_source.h"
19 #include "content/public/browser/render_view_host.h" 18 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
21 #include "ui/gfx/insets.h" 20 #include "ui/gfx/insets.h"
22 #include "ui/views/layout/fill_layout.h" 21 #include "ui/views/layout/fill_layout.h"
23 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
24 23
25 #if defined(USE_AURA) 24 #if defined(USE_AURA)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 views::BubbleBorder::ArrowLocation arrow_location, 68 views::BubbleBorder::ArrowLocation arrow_location,
70 ShowAction show_action) 69 ShowAction show_action)
71 : BubbleDelegateView(anchor_view, arrow_location), 70 : BubbleDelegateView(anchor_view, arrow_location),
72 extension_host_(host), 71 extension_host_(host),
73 close_bubble_factory_(this) { 72 close_bubble_factory_(this) {
74 inspect_with_devtools_ = show_action == SHOW_AND_INSPECT; 73 inspect_with_devtools_ = show_action == SHOW_AND_INSPECT;
75 // Adjust the margin so that contents fit better. 74 // Adjust the margin so that contents fit better.
76 const int margin = views::BubbleBorder::GetCornerRadius() / 2; 75 const int margin = views::BubbleBorder::GetCornerRadius() / 2;
77 set_margins(gfx::Insets(margin, margin, margin, margin)); 76 set_margins(gfx::Insets(margin, margin, margin, margin));
78 SetLayoutManager(new views::FillLayout()); 77 SetLayoutManager(new views::FillLayout());
79 AddChildView(static_cast<ExtensionViewViews*>(host->GetExtensionView())); 78 AddChildView(host->view());
80 host->GetExtensionView()->SetContainer(this); 79 host->view()->SetContainer(this);
81 // Use OnNativeFocusChange to check for child window activation on deactivate. 80 // Use OnNativeFocusChange to check for child window activation on deactivate.
82 set_close_on_deactivate(false); 81 set_close_on_deactivate(false);
83 // Make the bubble move with its anchor (during inspection, etc.). 82 // Make the bubble move with its anchor (during inspection, etc.).
84 set_move_with_anchor(true); 83 set_move_with_anchor(true);
85 84
86 // Wait to show the popup until the contained host finishes loading. 85 // Wait to show the popup until the contained host finishes loading.
87 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 86 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
88 content::Source<WebContents>(host->host_contents())); 87 content::Source<WebContents>(host->host_contents()));
89 88
90 // Listen for the containing view calling window.close(); 89 // Listen for the containing view calling window.close();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // Set inspect_with_devtools_ so the popup will be kept open while 135 // Set inspect_with_devtools_ so the popup will be kept open while
137 // the devtools are open. 136 // the devtools are open.
138 inspect_with_devtools_ = true; 137 inspect_with_devtools_ = true;
139 } 138 }
140 break; 139 break;
141 default: 140 default:
142 NOTREACHED() << L"Received unexpected notification"; 141 NOTREACHED() << L"Received unexpected notification";
143 } 142 }
144 } 143 }
145 144
146 void ExtensionPopup::OnExtensionSizeChanged(ExtensionView* view, 145 void ExtensionPopup::OnExtensionSizeChanged(ExtensionViewViews* view) {
147 const gfx::Size& new_size) {
148 SizeToContents(); 146 SizeToContents();
149 } 147 }
150 148
151 void ExtensionPopup::OnExtensionViewDidShow(ExtensionView* view) {
152 }
153
154 gfx::Size ExtensionPopup::GetPreferredSize() { 149 gfx::Size ExtensionPopup::GetPreferredSize() {
155 // Constrain the size to popup min/max. 150 // Constrain the size to popup min/max.
156 gfx::Size sz = views::View::GetPreferredSize(); 151 gfx::Size sz = views::View::GetPreferredSize();
157 sz.set_width(std::max(kMinWidth, std::min(kMaxWidth, sz.width()))); 152 sz.set_width(std::max(kMinWidth, std::min(kMaxWidth, sz.width())));
158 sz.set_height(std::max(kMinHeight, std::min(kMaxHeight, sz.height()))); 153 sz.set_height(std::max(kMinHeight, std::min(kMaxHeight, sz.height())));
159 return sz; 154 return sz;
160 } 155 }
161 156
162 void ExtensionPopup::OnNativeFocusChange(gfx::NativeView focused_before, 157 void ExtensionPopup::OnNativeFocusChange(gfx::NativeView focused_before,
163 gfx::NativeView focused_now) { 158 gfx::NativeView focused_now) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 if (inspect_with_devtools_) { 216 if (inspect_with_devtools_) {
222 DevToolsWindow::ToggleDevToolsWindow(host()->render_view_host(), 217 DevToolsWindow::ToggleDevToolsWindow(host()->render_view_host(),
223 true, 218 true,
224 DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE); 219 DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE);
225 } 220 }
226 } 221 }
227 222
228 void ExtensionPopup::CloseBubble() { 223 void ExtensionPopup::CloseBubble() {
229 GetWidget()->Close(); 224 GetWidget()->Close();
230 } 225 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_popup.h ('k') | chrome/browser/ui/views/extensions/extension_view_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698