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

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

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