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

Side by Side Diff: chrome/browser/ui/extensions/shell_window.cc

Issue 10436015: Remove chrome.windows.* support for platform apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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/extensions/shell_window.h" 5 #include "chrome/browser/ui/extensions/shell_window.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/extensions/extension_process_manager.h" 8 #include "chrome/browser/extensions/extension_process_manager.h"
9 #include "chrome/browser/extensions/extension_tabs_module_constants.h" 9 #include "chrome/browser/extensions/extension_tabs_module_constants.h"
10 #include "chrome/browser/extensions/extension_window_controller.h"
11 #include "chrome/browser/extensions/shell_window_registry.h" 10 #include "chrome/browser/extensions/shell_window_registry.h"
12 #include "chrome/browser/file_select_helper.h" 11 #include "chrome/browser/file_select_helper.h"
13 #include "chrome/browser/intents/web_intents_util.h" 12 #include "chrome/browser/intents/web_intents_util.h"
14 #include "chrome/browser/lifetime/application_lifetime.h" 13 #include "chrome/browser/lifetime/application_lifetime.h"
15 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/sessions/session_id.h" 15 #include "chrome/browser/sessions/session_id.h"
17 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" 17 #include "chrome/browser/ui/intents/web_intent_picker_controller.h"
19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
20 #include "chrome/browser/view_type_utils.h" 19 #include "chrome/browser/view_type_utils.h"
(...skipping 13 matching lines...) Expand all
34 #include "content/public/common/renderer_preferences.h" 33 #include "content/public/common/renderer_preferences.h"
35 34
36 using content::SiteInstance; 35 using content::SiteInstance;
37 using content::WebContents; 36 using content::WebContents;
38 37
39 namespace { 38 namespace {
40 static const int kDefaultWidth = 512; 39 static const int kDefaultWidth = 512;
41 static const int kDefaultHeight = 384; 40 static const int kDefaultHeight = 384;
42 } // namespace 41 } // namespace
43 42
44 namespace internal {
45
46 class ShellWindowController : public ExtensionWindowController {
47 public:
48 ShellWindowController(ShellWindow* shell_window, Profile* profile);
49
50 // Overriden from ExtensionWindowController
51 virtual int GetWindowId() const OVERRIDE;
52 virtual std::string GetWindowTypeText() const OVERRIDE;
53 virtual base::DictionaryValue* CreateWindowValueWithTabs() const OVERRIDE;
54 virtual bool CanClose(Reason* reason) const OVERRIDE;
55 virtual void SetFullscreenMode(bool is_fullscreen,
56 const GURL& extension_url) const OVERRIDE;
57 virtual bool IsVisibleToExtension(
58 const extensions::Extension* extension) const OVERRIDE;
59
60 private:
61 ShellWindow* shell_window_;
62
63 DISALLOW_COPY_AND_ASSIGN(ShellWindowController);
64 };
65
66 ShellWindowController::ShellWindowController(
67 ShellWindow* shell_window,
68 Profile* profile)
69 : ExtensionWindowController(shell_window, profile),
70 shell_window_(shell_window) {
71 }
72
73 int ShellWindowController::GetWindowId() const {
74 return static_cast<int>(shell_window_->session_id().id());
75 }
76
77 std::string ShellWindowController::GetWindowTypeText() const {
78 return extension_tabs_module_constants::kWindowTypeValueShell;
79 }
80
81 base::DictionaryValue* ShellWindowController::CreateWindowValueWithTabs()
82 const {
83 return CreateWindowValue();
84 }
85
86 bool ShellWindowController::CanClose(Reason* reason) const {
87 return true;
88 }
89
90 void ShellWindowController::SetFullscreenMode(bool is_fullscreen,
91 const GURL& extension_url) const {
92 // TODO(mihaip): implement
93 }
94
95 bool ShellWindowController::IsVisibleToExtension(
96 const extensions::Extension* extension) const {
97 return shell_window_->extension() == extension;
98 }
99
100 } // namespace internal
101
102 ShellWindow::CreateParams::CreateParams() 43 ShellWindow::CreateParams::CreateParams()
103 : frame(ShellWindow::CreateParams::FRAME_CUSTOM), 44 : frame(ShellWindow::CreateParams::FRAME_CUSTOM),
104 bounds(10, 10, kDefaultWidth, kDefaultHeight) { 45 bounds(10, 10, kDefaultWidth, kDefaultHeight) {
105 } 46 }
106 47
107 ShellWindow* ShellWindow::Create(Profile* profile, 48 ShellWindow* ShellWindow::Create(Profile* profile,
108 const extensions::Extension* extension, 49 const extensions::Extension* extension,
109 const GURL& url, 50 const GURL& url,
110 const ShellWindow::CreateParams params) { 51 const ShellWindow::CreateParams params) {
111 // This object will delete itself when the window is closed. 52 // This object will delete itself when the window is closed.
(...skipping 25 matching lines...) Expand all
137 content::Source<Profile>(profile_)); 78 content::Source<Profile>(profile_));
138 // Close when the browser is exiting. 79 // Close when the browser is exiting.
139 // TODO(mihaip): we probably don't want this in the long run (when platform 80 // TODO(mihaip): we probably don't want this in the long run (when platform
140 // apps are no longer tied to the browser process). 81 // apps are no longer tied to the browser process).
141 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, 82 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING,
142 content::NotificationService::AllSources()); 83 content::NotificationService::AllSources());
143 84
144 // Prevent the browser process from shutting down while this window is open. 85 // Prevent the browser process from shutting down while this window is open.
145 browser::StartKeepAlive(); 86 browser::StartKeepAlive();
146 87
147 // Make this window available to the extension API.
148 extension_window_controller_.reset(
149 new internal::ShellWindowController(this, profile_));
150
151 ShellWindowRegistry::Get(profile_)->AddShellWindow(this); 88 ShellWindowRegistry::Get(profile_)->AddShellWindow(this);
152 } 89 }
153 90
154 ShellWindow::~ShellWindow() { 91 ShellWindow::~ShellWindow() {
155 // Unregister now to prevent getting NOTIFICATION_APP_TERMINATING if we're the 92 // Unregister now to prevent getting NOTIFICATION_APP_TERMINATING if we're the
156 // last window open. 93 // last window open.
157 registrar_.RemoveAll(); 94 registrar_.RemoveAll();
158 95
159 ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this); 96 ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this);
160 97
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 FileSelectHelper::RunFileChooser(tab, params); 143 FileSelectHelper::RunFileChooser(tab, params);
207 } 144 }
208 145
209 bool ShellWindow::IsPopupOrPanel(const WebContents* source) const { 146 bool ShellWindow::IsPopupOrPanel(const WebContents* source) const {
210 DCHECK(source == web_contents_); 147 DCHECK(source == web_contents_);
211 return true; 148 return true;
212 } 149 }
213 150
214 void ShellWindow::MoveContents(WebContents* source, const gfx::Rect& pos) { 151 void ShellWindow::MoveContents(WebContents* source, const gfx::Rect& pos) {
215 DCHECK(source == web_contents_); 152 DCHECK(source == web_contents_);
216 extension_window_controller_->window()->SetBounds(pos); 153 SetBounds(pos);
217 } 154 }
218 155
219 void ShellWindow::NavigationStateChanged( 156 void ShellWindow::NavigationStateChanged(
220 const content::WebContents* source, unsigned changed_flags) { 157 const content::WebContents* source, unsigned changed_flags) {
221 DCHECK(source == web_contents_); 158 DCHECK(source == web_contents_);
222 if (changed_flags & content::INVALIDATE_TYPE_TITLE) 159 if (changed_flags & content::INVALIDATE_TYPE_TITLE)
223 UpdateWindowTitle(); 160 UpdateWindowTitle();
224 } 161 }
225 162
226 void ShellWindow::Observe(int type, 163 void ShellWindow::Observe(int type,
(...skipping 10 matching lines...) Expand all
237 } 174 }
238 case content::NOTIFICATION_APP_TERMINATING: 175 case content::NOTIFICATION_APP_TERMINATING:
239 Close(); 176 Close();
240 break; 177 break;
241 default: 178 default:
242 NOTREACHED() << "Received unexpected notification"; 179 NOTREACHED() << "Received unexpected notification";
243 } 180 }
244 } 181 }
245 182
246 ExtensionWindowController* ShellWindow::GetExtensionWindowController() const { 183 ExtensionWindowController* ShellWindow::GetExtensionWindowController() const {
247 return extension_window_controller_.get(); 184 return NULL;
248 } 185 }
249 186
250 void ShellWindow::OnRequest(const ExtensionHostMsg_Request_Params& params) { 187 void ShellWindow::OnRequest(const ExtensionHostMsg_Request_Params& params) {
251 extension_function_dispatcher_.Dispatch(params, 188 extension_function_dispatcher_.Dispatch(params,
252 web_contents_->GetRenderViewHost()); 189 web_contents_->GetRenderViewHost());
253 } 190 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/extensions/shell_window.h ('k') | chrome/common/extensions/api/_permission_features.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698