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

Side by Side Diff: chrome/browser/dom_ui/app_launcher_handler.cc

Issue 3342009: Remove old debug code from ntp. (Closed)
Patch Set: Created 10 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
« no previous file with comments | « no previous file | chrome/browser/resources/new_new_tab.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/dom_ui/app_launcher_handler.h" 5 #include "chrome/browser/dom_ui/app_launcher_handler.h"
6 6
7 #include "app/animation.h" 7 #include "app/animation.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 if (registrar_.IsEmpty()) { 131 if (registrar_.IsEmpty()) {
132 registrar_.Add(this, NotificationType::EXTENSION_LOADED, 132 registrar_.Add(this, NotificationType::EXTENSION_LOADED,
133 NotificationService::AllSources()); 133 NotificationService::AllSources());
134 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, 134 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
135 NotificationService::AllSources()); 135 NotificationService::AllSources());
136 } 136 }
137 } 137 }
138 138
139 void AppLauncherHandler::HandleLaunchApp(const ListValue* args) { 139 void AppLauncherHandler::HandleLaunchApp(const ListValue* args) {
140 std::string extension_id; 140 std::string extension_id;
141 std::string launch_container;
142 int left = 0; 141 int left = 0;
143 int top = 0; 142 int top = 0;
144 int width = 0; 143 int width = 0;
145 int height = 0; 144 int height = 0;
146 145
147 if (!args->GetString(0, &extension_id) || 146 if (!args->GetString(0, &extension_id) ||
148 !args->GetString(1, &launch_container) || 147 !ExtractInt(args, 1, &left) ||
149 !ExtractInt(args, 2, &left) || 148 !ExtractInt(args, 2, &top) ||
150 !ExtractInt(args, 3, &top) || 149 !ExtractInt(args, 3, &width) ||
151 !ExtractInt(args, 4, &width) || 150 !ExtractInt(args, 4, &height)) {
152 !ExtractInt(args, 5, &height)) {
153 NOTREACHED(); 151 NOTREACHED();
154 return; 152 return;
155 } 153 }
156 154
157 // The rect we get from the client is relative to the browser client viewport. 155 // The rect we get from the client is relative to the browser client viewport.
158 // Offset the rect by the tab contents bounds. 156 // Offset the rect by the tab contents bounds.
159 gfx::Rect rect(left, top, width, height); 157 gfx::Rect rect(left, top, width, height);
160 gfx::Rect tab_contents_bounds; 158 gfx::Rect tab_contents_bounds;
161 dom_ui_->tab_contents()->GetContainerBounds(&tab_contents_bounds); 159 dom_ui_->tab_contents()->GetContainerBounds(&tab_contents_bounds);
162 rect.Offset(tab_contents_bounds.origin()); 160 rect.Offset(tab_contents_bounds.origin());
163 161
164 // Override the default launch container.
165 Extension* extension = 162 Extension* extension =
166 extensions_service_->GetExtensionById(extension_id, false); 163 extensions_service_->GetExtensionById(extension_id, false);
167 DCHECK(extension); 164 DCHECK(extension);
168
169 Profile* profile = extensions_service_->profile(); 165 Profile* profile = extensions_service_->profile();
170
171 Extension::LaunchContainer container = extension->launch_container(); 166 Extension::LaunchContainer container = extension->launch_container();
172 if (launch_container == "tab")
173 container = Extension::LAUNCH_TAB;
174 else if (launch_container == "panel")
175 container = Extension::LAUNCH_PANEL;
176 else if (launch_container == "window")
177 container = Extension::LAUNCH_WINDOW;
178 else if (!launch_container.empty())
179 NOTREACHED() << "Unexpected launch container: " << launch_container << ".";
180 167
181 // To give a more "launchy" experience when using the NTP launcher, we close 168 // To give a more "launchy" experience when using the NTP launcher, we close
182 // it automatically. 169 // it automatically.
183 Browser* browser = BrowserList::GetLastActive(); 170 Browser* browser = BrowserList::GetLastActive();
184 TabContents* old_contents = NULL; 171 TabContents* old_contents = NULL;
185 if (browser) 172 if (browser)
186 old_contents = browser->GetSelectedTabContents(); 173 old_contents = browser->GetSelectedTabContents();
187 174
188 AnimateAppIcon(extension, rect); 175 AnimateAppIcon(extension, rect);
189 Browser::OpenApplication(profile, extension, container); 176 Browser::OpenApplication(profile, extension, container);
(...skipping 21 matching lines...) Expand all
211 void AppLauncherHandler::HandleUninstallApp(const ListValue* args) { 198 void AppLauncherHandler::HandleUninstallApp(const ListValue* args) {
212 std::string extension_id = WideToUTF8(ExtractStringValue(args)); 199 std::string extension_id = WideToUTF8(ExtractStringValue(args));
213 200
214 // Make sure that the extension exists. 201 // Make sure that the extension exists.
215 Extension* extension = 202 Extension* extension =
216 extensions_service_->GetExtensionById(extension_id, false); 203 extensions_service_->GetExtensionById(extension_id, false);
217 DCHECK(extension); 204 DCHECK(extension);
218 205
219 extensions_service_->UninstallExtension(extension_id, false); 206 extensions_service_->UninstallExtension(extension_id, false);
220 } 207 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/new_new_tab.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698