OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/web_app_launcher.h" | 5 #include "chrome/browser/web_app_launcher.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
10 #include "chrome/browser/web_app.h" | 10 #include "chrome/browser/web_app.h" |
11 | 11 |
12 // static | 12 // static |
13 void WebAppLauncher::Launch(Profile* profile, | 13 void WebAppLauncher::Launch(Profile* profile, const GURL& url) { |
14 const GURL& url, | 14 (new WebAppLauncher(profile, url))->Run(); |
15 int show_command) { | |
16 (new WebAppLauncher(profile, url, show_command))->Run(); | |
17 } | 15 } |
18 | 16 |
19 WebAppLauncher::WebAppLauncher(Profile* profile, | 17 WebAppLauncher::WebAppLauncher(Profile* profile, const GURL& url) |
20 const GURL& url, | |
21 int show_command) | |
22 : profile_(profile), | 18 : profile_(profile), |
23 url_(url), | 19 url_(url) { |
24 show_command_(show_command) { | |
25 } | 20 } |
26 | 21 |
27 void WebAppLauncher::Run() { | 22 void WebAppLauncher::Run() { |
28 GearsQueryShortcuts(NewCallback(this, &WebAppLauncher::OnGotApps)); | 23 GearsQueryShortcuts(NewCallback(this, &WebAppLauncher::OnGotApps)); |
29 } | 24 } |
30 | 25 |
31 void WebAppLauncher::OnGotApps(GearsShortcutList* apps) { | 26 void WebAppLauncher::OnGotApps(GearsShortcutList* apps) { |
32 WebApp* app = NULL; | 27 WebApp* app = NULL; |
33 | 28 |
34 if (apps) { | 29 if (apps) { |
35 for (size_t i = 0; i < apps->num_shortcuts; ++i) { | 30 for (size_t i = 0; i < apps->num_shortcuts; ++i) { |
36 if (apps->shortcuts[i].url && GURL(apps->shortcuts[i].url) == url_) { | 31 if (apps->shortcuts[i].url && GURL(apps->shortcuts[i].url) == url_) { |
37 app = new WebApp(profile_, apps->shortcuts[i]); | 32 app = new WebApp(profile_, apps->shortcuts[i]); |
38 break; | 33 break; |
39 } | 34 } |
40 } | 35 } |
41 } | 36 } |
42 | 37 |
43 if (!app) { | 38 if (!app) { |
44 // Gears doesn't know about this app. Create one anyway. | 39 // Gears doesn't know about this app. Create one anyway. |
45 app = new WebApp(profile_, url_, std::wstring()); | 40 app = new WebApp(profile_, url_, std::wstring()); |
46 } | 41 } |
47 | 42 |
48 Browser::OpenWebApplication(profile_, app, show_command_); | 43 Browser::OpenWebApplication(profile_, app); |
49 | 44 |
50 delete this; | 45 delete this; |
51 } | 46 } |
52 | 47 |
OLD | NEW |