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

Side by Side Diff: chrome/browser/ui/gtk/extensions/extension_popup_gtk.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/gtk/extensions/extension_popup_gtk.h" 5 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "chrome/browser/extensions/extension_host.h" 13 #include "chrome/browser/extensions/extension_host.h"
14 #include "chrome/browser/extensions/extension_process_manager.h" 14 #include "chrome/browser/extensions/extension_process_manager.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" 16 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_window.h" 18 #include "chrome/browser/ui/browser_window.h"
19 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 19 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
20 #include "content/browser/debugger/devtools_window.h" 20 #include "content/browser/debugger/devtools_window.h"
21 #include "chrome/common/chrome_notification_types.h"
21 #include "content/browser/renderer_host/render_view_host.h" 22 #include "content/browser/renderer_host/render_view_host.h"
22 #include "content/common/notification_details.h" 23 #include "content/common/notification_details.h"
23 #include "content/common/notification_source.h" 24 #include "content/common/notification_source.h"
24 #include "googleurl/src/gurl.h" 25 #include "googleurl/src/gurl.h"
25 26
26 ExtensionPopupGtk* ExtensionPopupGtk::current_extension_popup_ = NULL; 27 ExtensionPopupGtk* ExtensionPopupGtk::current_extension_popup_ = NULL;
27 28
28 // The minimum/maximum dimensions of the extension popup. 29 // The minimum/maximum dimensions of the extension popup.
29 // The minimum is just a little larger than the size of a browser action button. 30 // The minimum is just a little larger than the size of a browser action button.
30 // The maximum is an arbitrary number that should be smaller than most screens. 31 // The maximum is an arbitrary number that should be smaller than most screens.
(...skipping 12 matching lines...) Expand all
43 anchor_(anchor), 44 anchor_(anchor),
44 being_inspected_(inspect), 45 being_inspected_(inspect),
45 method_factory_(this) { 46 method_factory_(this) {
46 host_->view()->SetContainer(this); 47 host_->view()->SetContainer(this);
47 48
48 // If the host had somehow finished loading, then we'd miss the notification 49 // If the host had somehow finished loading, then we'd miss the notification
49 // and not show. This seems to happen in single-process mode. 50 // and not show. This seems to happen in single-process mode.
50 if (host->did_stop_loading()) { 51 if (host->did_stop_loading()) {
51 ShowPopup(); 52 ShowPopup();
52 } else { 53 } else {
53 registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, 54 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
54 Source<Profile>(host->profile())); 55 Source<Profile>(host->profile()));
55 } 56 }
56 57
57 registrar_.Add(this, NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE, 58 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
58 Source<Profile>(host->profile())); 59 Source<Profile>(host->profile()));
59 } 60 }
60 61
61 ExtensionPopupGtk::~ExtensionPopupGtk() { 62 ExtensionPopupGtk::~ExtensionPopupGtk() {
62 } 63 }
63 64
64 void ExtensionPopupGtk::Observe(NotificationType type, 65 void ExtensionPopupGtk::Observe(int type,
65 const NotificationSource& source, 66 const NotificationSource& source,
66 const NotificationDetails& details) { 67 const NotificationDetails& details) {
67 switch (type.value) { 68 switch (type) {
68 case NotificationType::EXTENSION_HOST_DID_STOP_LOADING: 69 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING:
69 if (Details<ExtensionHost>(host_.get()) == details) 70 if (Details<ExtensionHost>(host_.get()) == details)
70 ShowPopup(); 71 ShowPopup();
71 break; 72 break;
72 case NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE: 73 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE:
73 if (Details<ExtensionHost>(host_.get()) == details) 74 if (Details<ExtensionHost>(host_.get()) == details)
74 DestroyPopup(); 75 DestroyPopup();
75 break; 76 break;
76 case NotificationType::DEVTOOLS_WINDOW_CLOSING: 77 case content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING:
77 // Make sure its the devtools window that inspecting our popup. 78 // Make sure its the devtools window that inspecting our popup.
78 if (Details<RenderViewHost>(host_->render_view_host()) != details) 79 if (Details<RenderViewHost>(host_->render_view_host()) != details)
79 break; 80 break;
80 81
81 // If the devtools window is closing, we post a task to ourselves to 82 // If the devtools window is closing, we post a task to ourselves to
82 // close the popup. This gives the devtools window a chance to finish 83 // close the popup. This gives the devtools window a chance to finish
83 // detaching from the inspected RenderViewHost. 84 // detaching from the inspected RenderViewHost.
84 MessageLoop::current()->PostTask(FROM_HERE, 85 MessageLoop::current()->PostTask(FROM_HERE,
85 method_factory_.NewRunnableMethod(&ExtensionPopupGtk::DestroyPopup)); 86 method_factory_.NewRunnableMethod(&ExtensionPopupGtk::DestroyPopup));
86 break; 87 break;
87 default: 88 default:
88 NOTREACHED() << "Received unexpected notification"; 89 NOTREACHED() << "Received unexpected notification";
89 } 90 }
90 } 91 }
91 92
92 void ExtensionPopupGtk::ShowPopup() { 93 void ExtensionPopupGtk::ShowPopup() {
93 if (bubble_) { 94 if (bubble_) {
94 NOTREACHED(); 95 NOTREACHED();
95 return; 96 return;
96 } 97 }
97 98
98 if (being_inspected_) { 99 if (being_inspected_) {
99 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host()); 100 DevToolsWindow::OpenDevToolsWindow(host_->render_view_host());
100 // Listen for the the devtools window closing. 101 // Listen for the the devtools window closing.
101 registrar_.Add(this, NotificationType::DEVTOOLS_WINDOW_CLOSING, 102 registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING,
102 Source<Profile>(host_->profile())); 103 Source<Profile>(host_->profile()));
103 } 104 }
104 105
105 // Only one instance should be showing at a time. Get rid of the old one, if 106 // Only one instance should be showing at a time. Get rid of the old one, if
106 // any. Typically, |current_extension_popup_| will be NULL, but it can be 107 // any. Typically, |current_extension_popup_| will be NULL, but it can be
107 // non-NULL if a browser action button is clicked while another extension 108 // non-NULL if a browser action button is clicked while another extension
108 // popup's extension host is still loading. 109 // popup's extension host is still loading.
109 if (current_extension_popup_) 110 if (current_extension_popup_)
110 current_extension_popup_->DestroyPopup(); 111 current_extension_popup_->DestroyPopup();
111 current_extension_popup_ = this; 112 current_extension_popup_ = this;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 return; 164 return;
164 165
165 ExtensionHost* host = manager->CreatePopupHost(url, browser); 166 ExtensionHost* host = manager->CreatePopupHost(url, browser);
166 // This object will delete itself when the bubble is closed. 167 // This object will delete itself when the bubble is closed.
167 new ExtensionPopupGtk(browser, host, anchor, inspect); 168 new ExtensionPopupGtk(browser, host, anchor, inspect);
168 } 169 }
169 170
170 gfx::Rect ExtensionPopupGtk::GetViewBounds() { 171 gfx::Rect ExtensionPopupGtk::GetViewBounds() {
171 return gfx::Rect(host_->view()->native_view()->allocation); 172 return gfx::Rect(host_->view()->native_view()->allocation);
172 } 173 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/extensions/extension_popup_gtk.h ('k') | chrome/browser/ui/gtk/find_bar_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698