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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 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_popup.h" 5 #include "chrome/browser/ui/views/extensions/extension_popup.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "chrome/browser/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/extensions/extension_process_manager.h" 10 #include "chrome/browser/extensions/extension_process_manager.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/views/frame/browser_view.h" 14 #include "chrome/browser/ui/views/frame/browser_view.h"
15 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
16 #include "content/browser/debugger/devtools_window.h" 17 #include "content/browser/debugger/devtools_window.h"
17 #include "content/browser/renderer_host/render_view_host.h" 18 #include "content/browser/renderer_host/render_view_host.h"
18 #include "content/browser/renderer_host/render_widget_host_view.h" 19 #include "content/browser/renderer_host/render_widget_host_view.h"
19 #include "content/common/notification_details.h" 20 #include "content/common/notification_details.h"
20 #include "content/common/notification_source.h" 21 #include "content/common/notification_source.h"
21 #include "content/common/notification_type.h"
22 #include "views/widget/root_view.h" 22 #include "views/widget/root_view.h"
23 #include "views/widget/widget.h" 23 #include "views/widget/widget.h"
24 24
25 #if defined(OS_CHROMEOS) 25 #if defined(OS_CHROMEOS)
26 #include "chrome/browser/chromeos/wm_ipc.h" 26 #include "chrome/browser/chromeos/wm_ipc.h"
27 #include "third_party/cros/chromeos_wm_ipc_enums.h" 27 #include "third_party/cros/chromeos_wm_ipc_enums.h"
28 #endif 28 #endif
29 29
30 using std::vector; 30 using std::vector;
31 using views::Widget; 31 using views::Widget;
(...skipping 21 matching lines...) Expand all
53 inspect_with_devtools_(inspect_with_devtools), 53 inspect_with_devtools_(inspect_with_devtools),
54 close_on_lost_focus_(true), 54 close_on_lost_focus_(true),
55 closing_(false), 55 closing_(false),
56 observer_(observer) { 56 observer_(observer) {
57 AddRef(); // Balanced in Close(); 57 AddRef(); // Balanced in Close();
58 set_delegate(this); 58 set_delegate(this);
59 host->view()->SetContainer(this); 59 host->view()->SetContainer(this);
60 60
61 // We wait to show the popup until the contained host finishes loading. 61 // We wait to show the popup until the contained host finishes loading.
62 registrar_.Add(this, 62 registrar_.Add(this,
63 NotificationType::EXTENSION_HOST_DID_STOP_LOADING, 63 chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
64 Source<Profile>(host->profile())); 64 Source<Profile>(host->profile()));
65 65
66 // Listen for the containing view calling window.close(); 66 // Listen for the containing view calling window.close();
67 registrar_.Add(this, NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE, 67 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
68 Source<Profile>(host->profile())); 68 Source<Profile>(host->profile()));
69 } 69 }
70 70
71 ExtensionPopup::~ExtensionPopup() { 71 ExtensionPopup::~ExtensionPopup() {
72 } 72 }
73 73
74 void ExtensionPopup::Show(bool activate) { 74 void ExtensionPopup::Show(bool activate) {
75 if (popup_->IsVisible()) 75 if (popup_->IsVisible())
76 return; 76 return;
77 77
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // because a subsequent event in this loop may also want to close this popup 109 // because a subsequent event in this loop may also want to close this popup
110 // and if so, we want to allow that. Example: Clicking the same browser 110 // and if so, we want to allow that. Example: Clicking the same browser
111 // action button that opened the popup. If we closed immediately, the 111 // action button that opened the popup. If we closed immediately, the
112 // browser action container would fail to discover that the same button 112 // browser action container would fail to discover that the same button
113 // was pressed. 113 // was pressed.
114 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(this, 114 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(this,
115 &ExtensionPopup::Close)); 115 &ExtensionPopup::Close));
116 } 116 }
117 117
118 118
119 void ExtensionPopup::Observe(NotificationType type, 119 void ExtensionPopup::Observe(int type,
120 const NotificationSource& source, 120 const NotificationSource& source,
121 const NotificationDetails& details) { 121 const NotificationDetails& details) {
122 switch (type.value) { 122 switch (type) {
123 case NotificationType::EXTENSION_HOST_DID_STOP_LOADING: 123 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING:
124 // Once we receive did stop loading, the content will be complete and 124 // Once we receive did stop loading, the content will be complete and
125 // the width will have been computed. Now it's safe to show. 125 // the width will have been computed. Now it's safe to show.
126 if (extension_host_.get() == Details<ExtensionHost>(details).ptr()) { 126 if (extension_host_.get() == Details<ExtensionHost>(details).ptr()) {
127 Show(true); 127 Show(true);
128 128
129 if (inspect_with_devtools_) { 129 if (inspect_with_devtools_) {
130 // Listen for the the devtools window closing. 130 // Listen for the the devtools window closing.
131 registrar_.Add(this, NotificationType::DEVTOOLS_WINDOW_CLOSING, 131 registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING,
132 Source<Profile>(extension_host_->profile())); 132 Source<Profile>(extension_host_->profile()));
133 DevToolsWindow::ToggleDevToolsWindow( 133 DevToolsWindow::ToggleDevToolsWindow(
134 extension_host_->render_view_host(), 134 extension_host_->render_view_host(),
135 DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE); 135 DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE);
136 } 136 }
137 } 137 }
138 break; 138 break;
139 case NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE: 139 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE:
140 // If we aren't the host of the popup, then disregard the notification. 140 // If we aren't the host of the popup, then disregard the notification.
141 if (Details<ExtensionHost>(host()) != details) 141 if (Details<ExtensionHost>(host()) != details)
142 return; 142 return;
143 Close(); 143 Close();
144 144
145 break; 145 break;
146 case NotificationType::DEVTOOLS_WINDOW_CLOSING: 146 case content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING:
147 // Make sure its the devtools window that inspecting our popup. 147 // Make sure its the devtools window that inspecting our popup.
148 if (Details<RenderViewHost>(extension_host_->render_view_host()) != 148 if (Details<RenderViewHost>(extension_host_->render_view_host()) !=
149 details) 149 details)
150 return; 150 return;
151 151
152 // If the devtools window is closing, we post a task to ourselves to 152 // If the devtools window is closing, we post a task to ourselves to
153 // close the popup. This gives the devtools window a chance to finish 153 // close the popup. This gives the devtools window a chance to finish
154 // detaching from the inspected RenderViewHost. 154 // detaching from the inspected RenderViewHost.
155 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(this, 155 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(this,
156 &ExtensionPopup::Close)); 156 &ExtensionPopup::Close));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 if (closing_) 204 if (closing_)
205 return; 205 return;
206 closing_ = true; 206 closing_ = true;
207 DetachFromBrowser(); 207 DetachFromBrowser();
208 208
209 if (observer_) 209 if (observer_)
210 observer_->ExtensionPopupIsClosing(this); 210 observer_->ExtensionPopupIsClosing(this);
211 211
212 Release(); // Balanced in ctor. 212 Release(); // Balanced in ctor.
213 } 213 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_popup.h ('k') | chrome/browser/ui/views/file_manager_dialog_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698