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

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

Issue 23847004: "Redirecting URLs to Packaged Apps" implementation: revised (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comment in app_window_contents.cc Created 7 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 | 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/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 event->restrict_to_profile = profile; 54 event->restrict_to_profile = profile;
55 extensions::ExtensionSystem::Get(profile)->event_router()-> 55 extensions::ExtensionSystem::Get(profile)->event_router()->
56 DispatchEventToExtension(extension->id(), event.Pass()); 56 DispatchEventToExtension(extension->id(), event.Pass());
57 } 57 }
58 58
59 // static. 59 // static.
60 void AppEventRouter::DispatchOnLaunchedEventWithFileEntry( 60 void AppEventRouter::DispatchOnLaunchedEventWithFileEntry(
61 Profile* profile, const Extension* extension, 61 Profile* profile, const Extension* extension,
62 const std::string& handler_id, const std::string& mime_type, 62 const std::string& handler_id, const std::string& mime_type,
63 const extensions::app_file_handler_util::GrantedFileEntry& file_entry) { 63 const extensions::app_file_handler_util::GrantedFileEntry& file_entry) {
64 // TODO(sergeygs): Use the same way of creating an event (using the generated
65 // boilerplate) as below in DispatchOnLaunchedEventWithUrl.
64 scoped_ptr<base::ListValue> args(new base::ListValue()); 66 scoped_ptr<base::ListValue> args(new base::ListValue());
65 base::DictionaryValue* launch_data = new base::DictionaryValue(); 67 base::DictionaryValue* launch_data = new base::DictionaryValue();
66 launch_data->SetString("id", handler_id); 68 launch_data->SetString("id", handler_id);
67 base::DictionaryValue* launch_item = new base::DictionaryValue; 69 base::DictionaryValue* launch_item = new base::DictionaryValue;
68 launch_item->SetString("fileSystemId", file_entry.filesystem_id); 70 launch_item->SetString("fileSystemId", file_entry.filesystem_id);
69 launch_item->SetString("baseName", file_entry.registered_name); 71 launch_item->SetString("baseName", file_entry.registered_name);
70 launch_item->SetString("mimeType", mime_type); 72 launch_item->SetString("mimeType", mime_type);
71 launch_item->SetString("entryId", file_entry.id); 73 launch_item->SetString("entryId", file_entry.id);
72 base::ListValue* items = new base::ListValue; 74 base::ListValue* items = new base::ListValue;
73 items->Append(launch_item); 75 items->Append(launch_item);
74 launch_data->Set("items", items); 76 launch_data->Set("items", items);
75 args->Append(launch_data); 77 args->Append(launch_data);
76 DispatchOnLaunchedEventImpl(extension->id(), args.Pass(), profile); 78 DispatchOnLaunchedEventImpl(extension->id(), args.Pass(), profile);
77 } 79 }
78 80
81 // static.
82 void AppEventRouter::DispatchOnLaunchedEventWithUrl(
83 Profile* profile,
84 const Extension* extension,
85 const std::string& handler_id,
86 const GURL& url,
87 const GURL& referrer_url) {
88 api::app_runtime::LaunchData launch_data;
89 launch_data.id.reset(new std::string(handler_id));
90 launch_data.url.reset(new std::string(url.spec()));
91 launch_data.referrer_url.reset(new std::string(referrer_url.spec()));
92 scoped_ptr<ListValue> args(new ListValue());
93 args->Append(launch_data.ToValue().release());
94 DispatchOnLaunchedEventImpl(extension->id(), args.Pass(), profile);
95 }
96
79 } // namespace extensions 97 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698