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

Side by Side Diff: chrome/browser/extensions/api/app_runtime/app_runtime_api.cc

Issue 22944002: Implementation of the "Redirect URLs to Packaged Apps" feature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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/extensions/api/app_runtime/app_runtime_api.h" 5 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 30 matching lines...) Expand all
41 system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); 41 system->event_router()->DispatchEventToExtension(extension_id, event.Pass());
42 system->event_router()->RemoveLazyEventListener(kOnLaunchedEvent, 42 system->event_router()->RemoveLazyEventListener(kOnLaunchedEvent,
43 extension_id); 43 extension_id);
44 } 44 }
45 45
46 } // anonymous namespace 46 } // anonymous namespace
47 47
48 // static. 48 // static.
49 void AppEventRouter::DispatchOnLaunchedEvent( 49 void AppEventRouter::DispatchOnLaunchedEvent(
50 Profile* profile, const Extension* extension) { 50 Profile* profile, const Extension* extension) {
51 scoped_ptr<ListValue> arguments(new ListValue()); 51 scoped_ptr<ListValue> args(new ListValue());
52 DispatchOnLaunchedEventImpl(extension->id(), arguments.Pass(), profile); 52 DispatchOnLaunchedEventImpl(extension->id(), args.Pass(), profile);
53 } 53 }
54 54
55 DictionaryValue* DictionaryFromSavedFileEntry( 55 DictionaryValue* DictionaryFromSavedFileEntry(
56 const app_file_handler_util::GrantedFileEntry& file_entry) { 56 const app_file_handler_util::GrantedFileEntry& file_entry) {
57 DictionaryValue* result = new DictionaryValue(); 57 DictionaryValue* result = new DictionaryValue();
58 result->SetString("id", file_entry.id); 58 result->SetString("id", file_entry.id);
59 result->SetString("fileSystemId", file_entry.filesystem_id); 59 result->SetString("fileSystemId", file_entry.filesystem_id);
60 result->SetString("baseName", file_entry.registered_name); 60 result->SetString("baseName", file_entry.registered_name);
61 return result; 61 return result;
62 } 62 }
(...skipping 12 matching lines...) Expand all
75 scoped_ptr<ListValue> arguments(new ListValue()); 75 scoped_ptr<ListValue> arguments(new ListValue());
76 arguments->Append(file_entries_list); 76 arguments->Append(file_entries_list);
77 scoped_ptr<Event> event(new Event(kOnRestartedEvent, arguments.Pass())); 77 scoped_ptr<Event> event(new Event(kOnRestartedEvent, arguments.Pass()));
78 event->restrict_to_profile = profile; 78 event->restrict_to_profile = profile;
79 extensions::ExtensionSystem::Get(profile)->event_router()-> 79 extensions::ExtensionSystem::Get(profile)->event_router()->
80 DispatchEventToExtension(extension->id(), event.Pass()); 80 DispatchEventToExtension(extension->id(), event.Pass());
81 } 81 }
82 82
83 // static. 83 // static.
84 void AppEventRouter::DispatchOnLaunchedEventWithFileEntry( 84 void AppEventRouter::DispatchOnLaunchedEventWithFileEntry(
85 Profile* profile, const Extension* extension, 85 Profile* profile,
86 const std::string& handler_id, const std::string& mime_type, 86 const Extension* extension,
87 const std::string& file_system_id, const std::string& base_name) { 87 const std::string& handler_id,
88 const std::string& mime_type,
89 const std::string& file_system_id,
90 const std::string& base_name) {
88 scoped_ptr<ListValue> args(new ListValue()); 91 scoped_ptr<ListValue> args(new ListValue());
89 DictionaryValue* launch_data = new DictionaryValue(); 92 DictionaryValue* launch_data = new DictionaryValue();
90 launch_data->SetString("id", handler_id); 93 launch_data->SetString("id", handler_id);
91 DictionaryValue* launch_item = new DictionaryValue; 94 DictionaryValue* launch_item = new DictionaryValue;
92 launch_item->SetString("fileSystemId", file_system_id); 95 launch_item->SetString("fileSystemId", file_system_id);
93 launch_item->SetString("baseName", base_name); 96 launch_item->SetString("baseName", base_name);
94 launch_item->SetString("mimeType", mime_type); 97 launch_item->SetString("mimeType", mime_type);
95 ListValue* items = new ListValue; 98 ListValue* items = new ListValue;
96 items->Append(launch_item); 99 items->Append(launch_item);
97 launch_data->Set("items", items); 100 launch_data->Set("items", items);
98 args->Append(launch_data); 101 args->Append(launch_data);
99 DispatchOnLaunchedEventImpl(extension->id(), args.Pass(), profile); 102 DispatchOnLaunchedEventImpl(extension->id(), args.Pass(), profile);
100 } 103 }
101 104
105 // static.
106 void AppEventRouter::DispatchOnLaunchedEventWithURL(
107 Profile* profile,
108 const Extension* extension,
109 const std::string& handler_id,
110 const GURL& url,
111 const GURL& referrer_url) {
112 scoped_ptr<ListValue> args(new ListValue());
113 DictionaryValue* launch_data = new DictionaryValue();
114 launch_data->SetString("id", handler_id);
115 launch_data->SetString("url", url.spec());
116 launch_data->SetString("referrerUrl", referrer_url.spec());
117 args->Append(launch_data);
118 DispatchOnLaunchedEventImpl(extension->id(), args.Pass(), profile);
119 }
120
102 } // namespace extensions 121 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698